从RMarkdown生成PDF时,RStudio会更改文本和图像的顺序(用于分页?)
在我的机器上,我有一个RMarkdown文档,看起来像这样:从RMarkdown生成PDF时,RStudio会更改文本和图像的顺序(用于分页?),pdf,pagination,r-markdown,Pdf,Pagination,R Markdown,在我的机器上,我有一个RMarkdown文档,看起来像这样: --- title: "My title" author: "Me" date: "October 6, 2017" output: pdf_document: fig_caption: yes number_sections: yes --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` Block of text here
---
title: "My title"
author: "Me"
date: "October 6, 2017"
output:
pdf_document:
fig_caption: yes
number_sections: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Block of text here, call it text A.
![My caption](myimage.png)
Block of text here, call it text B.
这里的意图是先有文本A,然后是图像,然后是文本B
如果分页工作正常,那么它就会消失
然而,我不希望它以这种方式改变事情的顺序。HTML输出的行为与此不同,这是有道理的,因为它不处理页面。奇怪的是,如果我将
fig_caption
设置为no
,它似乎也会停止这样的行为。但是我当然想要字幕。LaTex会自动选择放置图像的最佳位置。您可以使用带有选项H
(此处适用)的float
软件包,强制将图像放置在源中的正确位置。请查看此示例:
---
title: "My title"
author: "Me"
date: "October 6, 2017"
header-includes:
- \usepackage{float}
output:
pdf_document:
fig_caption: yes
number_sections: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Block of text here, call it text A.
\begin{figure}[H]
\includegraphics{myimage.png}
\end{figure}
Block of text here, call it text B.
谢谢如何使用此方法使图像居中?是否有更新的解决方案来解决此“浮动”问题?似乎一个非常基本的呈现过程将保持内容的顺序。