繁体   English   中英

在R Markdown中的标题标题后添加换行符

[英]Add line break after caption title in R Markdown

我想在R Markdown输出中更改字幕的样式,并有两个请求:

  1. 如何使标题标签加粗?
  2. 如何在标题标签后添加换行符? 例如,我要在“表1”和标题之间输入一行。

这是一个例子:

caption <- 
  " April is the cruellest month, breeding
    Lilacs out of the dead land, mixing
    Memory and desire, stirring
    Dull roots with spring rain.
    Winter kept us warm, covering
    Earth in forgetful snow, feeding
    A little life with dried tubers.
    Summer surprised us, coming over the Starnbergersee
    With a shower of rain; we stopped in the colonnade,
    And went on in sunlight, into the Hofgarten,
    And drank coffee, and talked for an hour.
    Bin gar keine Russin, stamm’ aus Litauen, echt deutsch.
    And when we were children, staying at the arch-duke’s,
    My cousin’s, he took me out on a sled,
    And I was frightened. He said, Marie,
    Marie, hold on tight. And down we went.
    In the mountains, there you feel free.
    I read, much of the night, and go south in the winter."

kable(mtcars, format = 'latex', caption = caption)

您可以使用LaTeX的caption包来控制输出到PDF。 我们需要更改此文件的某些设置以完成您的更改,但是这些可以作为单独的.tex文件包含,或者在这种情况下只需进行少量更改,我们可以将它们插入到直接问题。 这是一个最小的示例:

---
output: pdf_document
header-includes:
   - \usepackage{caption}
   - \captionsetup{labelfont=bf, labelsep = newline}
---

```{r table1}
caption <- "your long long long caption"
knitr::kable(mtcars, caption = caption)
```

在此处输入图片说明

此方法仅适用于LaTeX输出(即PDF)。

如果要对样式进行更多更改,请在此处查看包装文档: http : //anorien.csc.warwick.ac.uk/mirrors/CTAN/macros/latex/contrib/caption/caption-eng.pdf

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM