align left figure caption in R markdown












0















figure captions in R markdown to PDF are centered by default. here's an example:



---
title: "test"
output: pdf_document
---


![Caption](test_pic.jpg)


(where test_pic.jpg is a local jpg file)



any ideas how to align the caption left?



I found how to change the size, using special attributes:



![Caption](test_pic.jpg){#id .class width=30%} 


but what's the special attribute to align left?










share|improve this question

























  • Please place a sample of the R markdown. I'm assuming (by the antiquated font) that this is a PDF but not all R markdown files produce PDFs so it would help the latex-rmarkdown-ers help you faster (and, perhaps, add a latex tag)

    – hrbrmstr
    Nov 14 '18 at 11:54











  • done...........

    – Tony D
    Nov 15 '18 at 4:51
















0















figure captions in R markdown to PDF are centered by default. here's an example:



---
title: "test"
output: pdf_document
---


![Caption](test_pic.jpg)


(where test_pic.jpg is a local jpg file)



any ideas how to align the caption left?



I found how to change the size, using special attributes:



![Caption](test_pic.jpg){#id .class width=30%} 


but what's the special attribute to align left?










share|improve this question

























  • Please place a sample of the R markdown. I'm assuming (by the antiquated font) that this is a PDF but not all R markdown files produce PDFs so it would help the latex-rmarkdown-ers help you faster (and, perhaps, add a latex tag)

    – hrbrmstr
    Nov 14 '18 at 11:54











  • done...........

    – Tony D
    Nov 15 '18 at 4:51














0












0








0








figure captions in R markdown to PDF are centered by default. here's an example:



---
title: "test"
output: pdf_document
---


![Caption](test_pic.jpg)


(where test_pic.jpg is a local jpg file)



any ideas how to align the caption left?



I found how to change the size, using special attributes:



![Caption](test_pic.jpg){#id .class width=30%} 


but what's the special attribute to align left?










share|improve this question
















figure captions in R markdown to PDF are centered by default. here's an example:



---
title: "test"
output: pdf_document
---


![Caption](test_pic.jpg)


(where test_pic.jpg is a local jpg file)



any ideas how to align the caption left?



I found how to change the size, using special attributes:



![Caption](test_pic.jpg){#id .class width=30%} 


but what's the special attribute to align left?







r markdown r-markdown pandoc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 8:06







Tony D

















asked Nov 14 '18 at 11:53









Tony DTony D

1118




1118













  • Please place a sample of the R markdown. I'm assuming (by the antiquated font) that this is a PDF but not all R markdown files produce PDFs so it would help the latex-rmarkdown-ers help you faster (and, perhaps, add a latex tag)

    – hrbrmstr
    Nov 14 '18 at 11:54











  • done...........

    – Tony D
    Nov 15 '18 at 4:51



















  • Please place a sample of the R markdown. I'm assuming (by the antiquated font) that this is a PDF but not all R markdown files produce PDFs so it would help the latex-rmarkdown-ers help you faster (and, perhaps, add a latex tag)

    – hrbrmstr
    Nov 14 '18 at 11:54











  • done...........

    – Tony D
    Nov 15 '18 at 4:51

















Please place a sample of the R markdown. I'm assuming (by the antiquated font) that this is a PDF but not all R markdown files produce PDFs so it would help the latex-rmarkdown-ers help you faster (and, perhaps, add a latex tag)

– hrbrmstr
Nov 14 '18 at 11:54





Please place a sample of the R markdown. I'm assuming (by the antiquated font) that this is a PDF but not all R markdown files produce PDFs so it would help the latex-rmarkdown-ers help you faster (and, perhaps, add a latex tag)

– hrbrmstr
Nov 14 '18 at 11:54













done...........

– Tony D
Nov 15 '18 at 4:51





done...........

– Tony D
Nov 15 '18 at 4:51












1 Answer
1






active

oldest

votes


















0














Yes, to align the caption left in PDF output from Rmarkdown we can use one chunk per image, with knitr::include_graphics in the chunk to display the image (this creates the LaTeX for the image), and a little LaTeX that controls the alignment of the caption:



---
title: "Untitled"
output:
pdf_document:
includes:
in_header: file.tex
---

Here are some examples of `knitr::include_graphics` with the code chunk options being used to control the size and location:

```{r fig.align="left", out.width = "50%", fig.cap="left-aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="center", out.width = "30%", fig.cap="center aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="right", out.width = "20%", fig.cap="right aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```


And here is file.tex, which should be in the same directory as the RMarkdown file:



usepackage[font=small,format=plain,labelfont=bf,up,textfont=normal,up,justification=justified,singlelinecheck=false]{caption}


And here's a screenshot of part of the output:



enter image description here






share|improve this answer


























  • thanks! is there any resources where I can learn what the arguments in the TeX file mean? I need one chunk per image, right? I can't have one chunk for several images (since the caption is in the header of the chunk)?

    – Tony D
    Nov 16 '18 at 23:54













  • yes, one chunk per caption. Though you could have multiple images produced by one chunk. As for a resource... google? Honestly, LaTeX is might as well be a bunch hopeful incantations to me, and I usually end up getting them from tex.stackexchange.com after googling

    – Ben
    Nov 17 '18 at 17:09











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299645%2falign-left-figure-caption-in-r-markdown%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Yes, to align the caption left in PDF output from Rmarkdown we can use one chunk per image, with knitr::include_graphics in the chunk to display the image (this creates the LaTeX for the image), and a little LaTeX that controls the alignment of the caption:



---
title: "Untitled"
output:
pdf_document:
includes:
in_header: file.tex
---

Here are some examples of `knitr::include_graphics` with the code chunk options being used to control the size and location:

```{r fig.align="left", out.width = "50%", fig.cap="left-aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="center", out.width = "30%", fig.cap="center aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="right", out.width = "20%", fig.cap="right aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```


And here is file.tex, which should be in the same directory as the RMarkdown file:



usepackage[font=small,format=plain,labelfont=bf,up,textfont=normal,up,justification=justified,singlelinecheck=false]{caption}


And here's a screenshot of part of the output:



enter image description here






share|improve this answer


























  • thanks! is there any resources where I can learn what the arguments in the TeX file mean? I need one chunk per image, right? I can't have one chunk for several images (since the caption is in the header of the chunk)?

    – Tony D
    Nov 16 '18 at 23:54













  • yes, one chunk per caption. Though you could have multiple images produced by one chunk. As for a resource... google? Honestly, LaTeX is might as well be a bunch hopeful incantations to me, and I usually end up getting them from tex.stackexchange.com after googling

    – Ben
    Nov 17 '18 at 17:09
















0














Yes, to align the caption left in PDF output from Rmarkdown we can use one chunk per image, with knitr::include_graphics in the chunk to display the image (this creates the LaTeX for the image), and a little LaTeX that controls the alignment of the caption:



---
title: "Untitled"
output:
pdf_document:
includes:
in_header: file.tex
---

Here are some examples of `knitr::include_graphics` with the code chunk options being used to control the size and location:

```{r fig.align="left", out.width = "50%", fig.cap="left-aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="center", out.width = "30%", fig.cap="center aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="right", out.width = "20%", fig.cap="right aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```


And here is file.tex, which should be in the same directory as the RMarkdown file:



usepackage[font=small,format=plain,labelfont=bf,up,textfont=normal,up,justification=justified,singlelinecheck=false]{caption}


And here's a screenshot of part of the output:



enter image description here






share|improve this answer


























  • thanks! is there any resources where I can learn what the arguments in the TeX file mean? I need one chunk per image, right? I can't have one chunk for several images (since the caption is in the header of the chunk)?

    – Tony D
    Nov 16 '18 at 23:54













  • yes, one chunk per caption. Though you could have multiple images produced by one chunk. As for a resource... google? Honestly, LaTeX is might as well be a bunch hopeful incantations to me, and I usually end up getting them from tex.stackexchange.com after googling

    – Ben
    Nov 17 '18 at 17:09














0












0








0







Yes, to align the caption left in PDF output from Rmarkdown we can use one chunk per image, with knitr::include_graphics in the chunk to display the image (this creates the LaTeX for the image), and a little LaTeX that controls the alignment of the caption:



---
title: "Untitled"
output:
pdf_document:
includes:
in_header: file.tex
---

Here are some examples of `knitr::include_graphics` with the code chunk options being used to control the size and location:

```{r fig.align="left", out.width = "50%", fig.cap="left-aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="center", out.width = "30%", fig.cap="center aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="right", out.width = "20%", fig.cap="right aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```


And here is file.tex, which should be in the same directory as the RMarkdown file:



usepackage[font=small,format=plain,labelfont=bf,up,textfont=normal,up,justification=justified,singlelinecheck=false]{caption}


And here's a screenshot of part of the output:



enter image description here






share|improve this answer















Yes, to align the caption left in PDF output from Rmarkdown we can use one chunk per image, with knitr::include_graphics in the chunk to display the image (this creates the LaTeX for the image), and a little LaTeX that controls the alignment of the caption:



---
title: "Untitled"
output:
pdf_document:
includes:
in_header: file.tex
---

Here are some examples of `knitr::include_graphics` with the code chunk options being used to control the size and location:

```{r fig.align="left", out.width = "50%", fig.cap="left-aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="center", out.width = "30%", fig.cap="center aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```

```{r fig.align="right", out.width = "20%", fig.cap="right aligned"}
knitr::include_graphics("rrtools-steps-carbon.png")
```


And here is file.tex, which should be in the same directory as the RMarkdown file:



usepackage[font=small,format=plain,labelfont=bf,up,textfont=normal,up,justification=justified,singlelinecheck=false]{caption}


And here's a screenshot of part of the output:



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 17 '18 at 17:06

























answered Nov 16 '18 at 8:37









BenBen

31.7k1398169




31.7k1398169













  • thanks! is there any resources where I can learn what the arguments in the TeX file mean? I need one chunk per image, right? I can't have one chunk for several images (since the caption is in the header of the chunk)?

    – Tony D
    Nov 16 '18 at 23:54













  • yes, one chunk per caption. Though you could have multiple images produced by one chunk. As for a resource... google? Honestly, LaTeX is might as well be a bunch hopeful incantations to me, and I usually end up getting them from tex.stackexchange.com after googling

    – Ben
    Nov 17 '18 at 17:09



















  • thanks! is there any resources where I can learn what the arguments in the TeX file mean? I need one chunk per image, right? I can't have one chunk for several images (since the caption is in the header of the chunk)?

    – Tony D
    Nov 16 '18 at 23:54













  • yes, one chunk per caption. Though you could have multiple images produced by one chunk. As for a resource... google? Honestly, LaTeX is might as well be a bunch hopeful incantations to me, and I usually end up getting them from tex.stackexchange.com after googling

    – Ben
    Nov 17 '18 at 17:09

















thanks! is there any resources where I can learn what the arguments in the TeX file mean? I need one chunk per image, right? I can't have one chunk for several images (since the caption is in the header of the chunk)?

– Tony D
Nov 16 '18 at 23:54







thanks! is there any resources where I can learn what the arguments in the TeX file mean? I need one chunk per image, right? I can't have one chunk for several images (since the caption is in the header of the chunk)?

– Tony D
Nov 16 '18 at 23:54















yes, one chunk per caption. Though you could have multiple images produced by one chunk. As for a resource... google? Honestly, LaTeX is might as well be a bunch hopeful incantations to me, and I usually end up getting them from tex.stackexchange.com after googling

– Ben
Nov 17 '18 at 17:09





yes, one chunk per caption. Though you could have multiple images produced by one chunk. As for a resource... google? Honestly, LaTeX is might as well be a bunch hopeful incantations to me, and I usually end up getting them from tex.stackexchange.com after googling

– Ben
Nov 17 '18 at 17:09


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299645%2falign-left-figure-caption-in-r-markdown%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python