RMarkdown: пробел в выводе LaTeX в месте кода для float - PullRequest
0 голосов
/ 11 мая 2018

При включении кода для фигуры между двумя абзацами в RMarkdown, плавающая в результате кода может быть размещена в другом месте документа, оставляя пространство между абзацами в выходном файле LaTeX / PDF.

Следующий минимальный пример иллюстрирует проблему:

---
output: pdf_document
---

This is my first paragraph. 
Next in the Rmd file would be the code for the figure.  
The figure is correctly treated as a float by LaTeX, meaning that LaTeX will put it to the next suitable position.
```{r pressure, echo=FALSE, fig.cap="Example", out.width='0.5\\textwidth', fig.pos='B'}
  plot(pressure)
```
The problem now is, that this leaves space to my second paragraph.
Usually, this should not be the case.
In pure LaTeX, there is a linebreak, of course, but no vertical space in addition.

1 Ответ

0 голосов
/ 11 мая 2018

Если вы поставите \vspace{-\parsep} в начале следующего текста, вы получите разрыв строки без лишнего пробела.То есть,

---
output: pdf_document
---

This is my first paragraph. 
Next in the Rmd file would be the code for the figure. 
The figure is correctly treated as a float by LaTeX, meaning that LaTeX will put it to the next suitable position.
```{r pressure, echo=FALSE, fig.cap="Example", out.width='0.5\\textwidth', fig.pos='B'}
  plot(pressure)
```
\vspace{-\parsep}The problem is now fixed.

Я не вижу другого способа сделать это: knitr ставит пустые строки вокруг среды фигуры, когда генерирует LaTeX.

...