【问题标题】:Add line break after caption title in R Markdown在 R Markdown 中的标题标题后添加换行符
【发布时间】:2018-07-02 20:20:50
【问题描述】:

我想更改 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)

【问题讨论】:

  • 描述你的问题到底是什么。

标签: r latex r-markdown kable


【解决方案1】:

您可以使用 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

【讨论】:

  • 如何通过“表 1”添加文本。即“表 1:很棒的表”。
  • 不包括'labelsep = newline'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-20
  • 1970-01-01
  • 1970-01-01
  • 2023-02-11
  • 2016-01-13
相关资源
最近更新 更多