【问题标题】:Change font and color for figure captions in Rmarkdown in PDF output在 PDF 输出中更改 Rmarkdown 中图形标题的字体和颜色
【发布时间】:2021-06-13 02:37:12
【问题描述】:

我想知道如何在 Rmarkdown 中专门为 PDF 输出中的图形标题更改字体和颜色。我知道如何为单词输出执行此操作(创建单独的文档),但通常将数字作为 PDF 提交给期刊。

请注意,这不是您是否可以更改 PDF 中文本的颜色,此处回答:Changing the font size of figure captions in RMarkdown pdf output。如果我在 fig.cap = "fig text here.\\label{...}" 中尝试此操作,则会收到以下错误:

! Undefined control sequence.
<recently read> \cellcolor 

这可能是最接近的:Changing the font size of figure captions in RMarkdown pdf output,但我去了 CTAN 并下载了包,但不确定是否必须找到我的 R 库并将其拖到那里,或者什么。也许这是唯一/最简单的解决方案,如果是这样,您能否建议我应该如何处理下载的包。没有在 Latex 方面做过很多工作,所以它可能会发现在 Latex 中颜色是如何定义的?

非常感谢!

詹姆斯

这是我的标题:

output:
  pdf_document: 
    keep_tex: true
  html_document: default
header-includes:
  \usepackage{placeins}

---

【问题讨论】:

    标签: r r-markdown


    【解决方案1】:

    你可以试试这个:

    ---
    title: "Untitled"
    author: "bttomio"
    date: "6/13/2021"
    output: pdf_document
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    ```
    
    ```{r pressure, echo=FALSE, fig.cap="\\textcolor{red}{This is red} and \\textcolor{blue}{this is blue}"}
    plot(pressure)
    ```
    

    -输出

    【讨论】:

    • 啊——太好了!换个字体怎么样?
    • 很好,很高兴为您提供帮助。你能查一下this吗?
    • 非常感谢!该链接很有帮助。
    猜你喜欢
    • 2019-10-09
    • 2017-12-15
    • 2017-12-14
    • 2015-05-16
    • 2021-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-18
    相关资源
    最近更新 更多