簡體   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