【发布时间】:2021-02-05 00:30:36
【问题描述】:
我正在编织这个 .Rmd,但结果将副标题“## PLOTS”与我制作的三个数字分开。
第一种方法
计算页面中的扩展空间并将其除以 3。 out.height='\dimexpr ((\textheight -3\baselineskip -\parskip -.2em -\abovecaptionskip -\belowcaptionskip)/3)'
第二种方法
将 out.height 的大小调整为 25% 会减少并将空间引向字幕,但没有任何反应。
---
title: "My report"
output:
pdf_document:
keep_tex: yes
latex_engine: pdflatex
header-includes:
- \usepackage{subfig}
- \usepackage{calc}
- \renewcommand{\figurename}{Fig.}
---
```{r setup, include=FALSE}
options(tinytex.verbose = TRUE)
knitr::opts_chunk$set(echo = FALSE, message = FALSE)
```
First page. Leaving alone. No figures here
\newpage
## PLOTS
```{r plots, fig.cap = 'My plots', fig.subcap=c('top', 'mid', 'down'), fig.ncol = 1, out.height='\\dimexpr ((\\textheight -3\\baselineskip -\\parskip -.2em -\\abovecaptionskip -\\belowcaptionskip)/3)', out.extra='keepaspectratio'}
plot(-1:-10)
plot(1:10)
plot(iris$Sepal.Width)
```
【问题讨论】:
-
看来您使用的是 LaTeX。我通常通过单独生成每个图来解决这些问题,并使用 LaTeX 包 subfigure 进行布局。这也会创建与文档字体和大小一致的图形标题。
标签: r latex r-markdown knitr tex