![](/img/trans.png)
[英]How remove colon in figure caption when using pandoc and bookdown in Rmarkdown?
[英]How to get a newline in a figure caption in Rmarkdown bookdown pdf:document2
我正在使用RStudio中的knitr编写一份rmarkdown bookdown:pdf:document2文档。 我有两个绘图,与gridExtra并排绘制,并标记为A和B.我想在图标题的输出中添加换行符,如图cap所定义,在A的标题和B的标题之间,但我很难过。 我努力了:
\\ n - 被忽略,好像它不在那里
\\\\ n - 未定义的控制序列
\\\\\\ n - @tempf的参数有一个额外的}。
\\ n \\ n打印“\\ n”(这里有点傻)
双倍空间 - 什么都不做
我甚至在绝望中尝试过HTML样式换行符,我无法弄清楚如何在这里显示,但我没想到它们会起作用而它们却没有。
在LaTeX中可以肯定有一种方法......
注意:这不是在knitr中的行之间的Split r chunk标题的重复,因为它询问如何在代码中的行中拆分块标题中的长标题,并且我在输出中询问如何执行此操作。
苏珊娜
---
title: "MRR captions"
author: "Susannah Cowtan"
date: "14 December 2018"
output:
bookdown::pdf_document2:
citation_package: natbib
number_sections: no
toc: no
keep_tex: true
bookdown::html_document2: null
header-includes:
- \usepackage{float}
- \usepackage{booktabs}
fontsize: 11pt
papersize: A4
---
```{r knitr_setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r plot-mtcars, fig.height = 3, fig.width = 4, fig.cap = "A: foo bar baz \nB: foobar"}
plot(mpg ~ wt, data = mtcars)
```
你可以通过插入适当的LaTeX命令来做到这一点,但是根据我的拙见,输出看起来不是很愉快。
通过在header-includes中添加- \\usepackage{caption}
来包含标题包,然后在标题中使用\\newline
命令。
```{r plot-mtcars, fig.height = 3, fig.width = 4, fig.cap = "A: foo bar baz \\newline{}B: foobar"}
plot(mpg ~ wt, data = mtcars)
```
添加足够的水平空白区域也会导致换行。 但是,标题将不再显示为中心。
```{r plot-mtcars, fig.height = 3, fig.width = 4, fig.cap = "A: foo bar baz \\hspace{\\textwidth}B: foobar"}
plot(mpg ~ wt, data = mtcars)
```
有关详细信息,请参阅TeX stackexchange 。
您可以考虑使用子图,而不是换行符
---
title: "MRR captions"
author: "Susannah Cowtan"
date: "14 December 2018"
output:
bookdown::pdf_document2:
keep_tex: true
header-includes:
- \usepackage{subfig}
---
See Figure \@ref(fig:plot-cars), which contains Figure \@ref(fig:plot-cars1) and Figure \@ref(fig:plot-cars2).
```{r plot-cars, fig.height = 3, fig.width = 4,, out.width='49%', fig.cap='Two plots', fig.subcap = c('foo bar baz', 'foobar')}
plot(mpg ~ wt, data = mtcars)
plot(cars)
```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.