如果横向太长,Bookdown 图形标题会失败?

Bookdown figure caption fails if too long in landscape?

我有一个大到需要在 RStudio 中使用 (PDF) bookdown 绘制横向文档的绘图。图中内容很多,所以图文很长,实在没法再缩减文字了。

这是我一直在使用的示例代码:

```{r qtl-pleiotropy, out.extra='angle=90', fig.width=25/2.54, fig.height=16.9/2.54, 
     fig.cap="QTL for fruit number per reproductive plant (Fruits/RP), seed number per fruit (Seeds/fr), seed number per reproductive plant (Seeds/RP), seed mass (Sd mass) and survival (Surv). Arrows indicate most-likely QTL position with the 95% Bayesian credible intervals, and the effect of the Swedish genotype (upward: increased phenotype; downward: decreased phenotype) in Italy (red) and Sweden (blue). Open arrows show QTL with credible intervals >15.2cM. Labels on the right of chromosome indicate QTL with pleiotropic effects on components of fecundity (c), fecundity and survival (s) and fecundity and seed mass (m). Grey boxes indicate the range of colocalising QTL for a single trait across site-year combinations."}
hist(rnorm(100)
```

问题是这会输出风景图,但标题在 PDF 输出中呈现为 body 文本(即不是图形标题):

\begin{figure} \caption{QTL for fruit number per reproductive plant (Fruits/RP), seed number per fruit (Seeds/fr), seed number per reproductive plant (Seeds/RP), seed mass (Sd mass) and survival (Surv). Arrows indicate most-likely QTL position with the 95% Bayesian credible intervals, and the effect of the Swedish genotype (upward: increased phenotype; downward: decreased phenotype) in Italy (red) and Sweden (blue). Open arrows show QTL with credible intervals >15.2cM. Labels on the right of chromosome indicate QTL with pleiotropic effects on components of fecundity (c), fecundity and survival (s) and fecundity and seed mass (m). Grey boxes indicate the range of colocalising QTL for a single trait across site-year combinations.} \end{figure}

如果我不使用横向(即省去 out.extra='angle=90'),这会起作用。如果我使用较短的标题块,它也可以正确呈现。这有效,例如:

```{r qtl-pleiotropy, out.extra='angle=90', fig.width=25/2.54, fig.height=16.9/2.54, 
     fig.cap="Open arrows show QTL with credible intervals >15.2cM. Labels on the right of chromosome indicate QTL with pleiotropic effects on components of fecundity (c), fecundity and survival (s) and fecundity and seed mass (m). Grey boxes indicate the range of colocalising QTL for a single trait across site-year combinations."}
hist(rnorm(100))
```

out.extra='angle=90'时字幕长度是否有上限?

任何人都可以为此建议 work-around 吗?

问题不是标题的长度引起的,而是未转义的 %。以下对我有用:

```{r qtl-pleiotropy1, out.extra='angle=90', fig.width=25/2.54, fig.height=16.9/2.54, fig.cap="QTL for fruit number per reproductive plant (Fruits/RP), seed number per fruit (Seeds/fr), seed number per reproductive plant (Seeds/RP), seed mass (Sd mass) and survival (Surv). Arrows indicate most-likely QTL position with the 95\% Bayesian credible intervals, and the effect of the Swedish genotype (upward: increased phenotype; downward: decreased phenotype) in Italy (red) and Sweden (blue). Open arrows show QTL with credible intervals >15.2cM. Labels on the right of chromosome indicate QTL with pleiotropic effects on components of fecundity (c), fecundity and survival (s) and fecundity and seed mass (m). Grey boxes indicate the range of colocalising QTL for a single trait across site-year combinations."}
hist(rnorm(100))
```