gpt4 book ai didi

r - bookdown - 使用 word_document2 时如何获得图上方的图标题和图下方的图注释

转载 作者:行者123 更新时间:2023-12-05 03:36:28 25 4
gpt4 key购买 nike

在撰写包含表格和数字的论文时,我正在尝试从 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(请参阅 Caption above figure using knitr (LaTeX/PDF)):

```{r figure-label, fig.cap="Figure Title", fig.width=6, fig.height=3.7, fig.align="center"}
...

这在创建 Word 文档时似乎不起作用。

最佳答案

yihui 在他的文档中说,我们可以使用 officedown² 包来影响文字布局。它有 Plot- 选项 topcaption:您可以将其设置为 true,如下所示。

---
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。

关于r - bookdown - 使用 word_document2 时如何获得图上方的图标题和图下方的图注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69588154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com