【问题标题】:How to change the font colour used inside the chunks when building a tufte book using bookdown?使用 bookdown 构建簇绒书时如何更改块内使用的字体颜色?
【发布时间】:2019-10-11 08:12:05
【问题描述】:

我正在尝试制作一本书,共有 9 章。我为此使用了 bookdown::bookdown_site 包,我已将其包含在 index.Rmd 的 YAML 标头中。但是当我使用 bookdown::tufte_book2 编织这本书时,pdf 文件会在块内生成具有不同字体颜色的文本。

当我尝试使用“tufte_handout”单独运行每一章时,结果符合预期。正文和内部块文本是单色和 TimesNewRoman。 在 rStudio 中,在编写本书之前,我尝试在 Sweave/Program 默认中同时使用 Latex 引擎“xeLaTex”和“pdfLaTex”

index.Rmd 中的 YAML 标头

---
title: "Operations Research Using R<br />"
author: "Timothy R. Anderson"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
monofont: Times New Roman
highlight: monochrome
documentclass: book
bibliography: ["Master4Bookdowns.bib"]
---

每个单独的 ChapterX.Rmd 文件中的 YAML 标头:

---
title: 'Chapter 3: More LP Models'
header-includes:
- \usepackage{longtable}
- \usepackage{caption}
monofont: Times New Roman
output:
  tufte::tufte_handout:
    citation_package: natbib
    latex_engine: xelatex
    toc: TRUE
    number_sections: true
    highlight: monochrome
  tufte::tufte_html: default
  tufte::tufte_book:
    citation_package: natbib
    latex_engine: xelatex
    highlight: monochrome
---

我希望所有文档都具有相同的字体类型和单色。

【问题讨论】:

    标签: r-markdown bookdown tufte


    【解决方案1】:

    由于您的主要 YAML 标头中未指定 bookdown::tufte_book2,我假设您有一个定义输出格式的 _output.yml 文件。在这种情况下,您必须在此处添加highlicht: monochrome,即:

    bookdown::tufte_book2:
      highlight: monochrome
      [other options]
    

    【讨论】:

    • 再次感谢您!它完全按照您之前的评论所预测的那样工作。有没有可以推荐的书来学习 YAML 或 *.yml 文件中的所有这些配置步骤?
    • @monzarrate 我学习了使用bookdown.org/yihui/bookdownbookdown.org/yihui/rmarkdown、通用 Rmarkdown 文档、pandoc 的手册等。各种示例文档的来源也很有帮助。
    猜你喜欢
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-14
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    相关资源
    最近更新 更多