【问题标题】:Add multiple plots vertically in the remaining space of page在页面的剩余空间中垂直添加多个绘图
【发布时间】: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


【解决方案1】:

在块选项中使用fig.pos='H' 为我解决了这个问题。它需要- \usepackage{float} 中的header-includesRef

【讨论】:

    猜你喜欢
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    • 2014-06-16
    • 2015-09-06
    • 1970-01-01
    相关资源
    最近更新 更多