在 R markdown 中对齐左图标题
align left figure caption in R markdown
R markdown 到 PDF 中的图形标题默认居中。这是一个例子:
---
title: "test"
output: pdf_document
---

(其中test_pic.jpg
为本地jpg文件)
关于如何将标题左对齐有什么想法吗?
我找到了如何使用特殊属性更改大小:
{#id .class width=30%}
但是左对齐的特殊属性是什么?
是的,为了对齐来自 Rmarkdown 的 PDF 输出中左侧的标题,我们可以为每个图像使用一个块,在块中使用 knitr::include_graphics
来显示图像(这会为图像创建 LaTeX),以及一个控制标题对齐的小 LaTeX:
---
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")
```
这里是file.tex
,它应该和RMarkdown文件在同一个目录:
\usepackage[font=small,format=plain,labelfont=bf,up,textfont=normal,up,justification=justified,singlelinecheck=false]{caption}
这是部分输出的屏幕截图:
R markdown 到 PDF 中的图形标题默认居中。这是一个例子:
---
title: "test"
output: pdf_document
---

(其中test_pic.jpg
为本地jpg文件)
关于如何将标题左对齐有什么想法吗?
我找到了如何使用特殊属性更改大小:
{#id .class width=30%}
但是左对齐的特殊属性是什么?
是的,为了对齐来自 Rmarkdown 的 PDF 输出中左侧的标题,我们可以为每个图像使用一个块,在块中使用 knitr::include_graphics
来显示图像(这会为图像创建 LaTeX),以及一个控制标题对齐的小 LaTeX:
---
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")
```
这里是file.tex
,它应该和RMarkdown文件在同一个目录:
\usepackage[font=small,format=plain,labelfont=bf,up,textfont=normal,up,justification=justified,singlelinecheck=false]{caption}
这是部分输出的屏幕截图: