![](/img/trans.png)
[英]How to create a figure note below the figure caption in r markdown and bookdown
[英]bookdown - how to get figure title above figure and figure notes below figure when using word_document2
在寫包含表格和數字的論文時,我試圖從 LaTeX 切換到 RMarkdown+bookdown。 一個主要動機是能夠創建 Word 文檔和 PDF 文檔。
對於word_document2
,如何在圖形上方添加圖形標題/標題以及在同一圖形下方添加圖形注釋?
這是我在 LaTeX 中的做法(並且繼續使用 LaTeX 會很方便,因為我將所有內容從 LaTeX 轉移到 RMarkdown)。
\begin{figure}
\caption{Figure Title...}
\label{figure_label}
\vspace*{.2cm}
\includegraphics[width=7in]{figure_name.png}\\
\caption*{Figure Notes...}
\end{figure}
更廣泛地說,是否可以將 LaTeX 代碼與 word_document2 一起使用?
請注意,我的序言目前看起來像:
---
title: "..."
author: "..."
date: "10/14/2021"
output:
bookdown::word_document2:
number_sections: false
bookdown::pdf_document2:
number_sections: false
header-includes:
- \usepackage{floatrow}
- \floatsetup[figure]{capposition=top}
citation_package: default
bibliography: ../references.bib
always_allow_html: true
---
我目前能夠獲得圖上方的標題,但僅適用於pdf_document2
( 使用 knitr (LaTeX/PDF)參見上圖的標題):
```{r figure-label, fig.cap="Figure Title", fig.width=6, fig.height=3.7, fig.align="center"}
...
創建 Word 文檔時,這似乎不起作用。
yihui 在他的文檔¹ 中說我們可以使用 officedown² 包來影響文字布局。 它具有繪圖選項 topcaption:您可以將其設置為 true,如下所示。
[¹] https://bookdown.org/yihui/rmarkdown-cookbook/word-officedown.html
[²] https://cran.r-project.org/web/packages/officedown/index.html
---
title: "..."
author: "..."
date: "10/14/2021"
output:
officedown::rdocx_document:
plots:
style: Normal
align: center
topcaption: true
bookdown::pdf_document2:
number_sections: false
header-includes:
- \usepackage{floatrow}
- \floatsetup[figure]{capposition=top}
citation_package: default
---
```{r figure-label, fig.cap="Top Caption", fig.width=6, fig.height=3.7}
plot(rnorm(1000,300,32))
library(officedown)
``
這應該會給你一個頂部帶有圖形標題的 docx。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.