使用 bookdown 构建 tufte book 时如何更改块内使用的字体颜色? [英] How to change the font colour used inside the chunks when building a tufte book using bookdown?
问题描述
我正在尝试制作一本书,有 9 章.我为此使用了 bookdown::bookdown_site 包,它已包含在 index.Rmd 的 YAML 标头中.但是当我使用 bookdown::tufte_book2 编织这本书时,pdf 文件会在块内生成具有不同字体颜色的文本.
I am trying to build a book, with 9 chapters. I am using the bookdown::bookdown_site package for that, which I have included in the YAML header in index.Rmd. But when I knit the book, using bookdown::tufte_book2, the pdf file generate the text inside the chunks with different font colors.
当我尝试使用tufte_handout"单独运行每一章时,结果如预期.主要文本和内部块文本是单色和 TimesNewRoman.在 rStudio 中,在构建本书之前,我尝试在 Sweave/Program 默认设置中同时使用 Latex 引擎,xeLaTex"和pdfLaTex"
When I try to run each chapter individually, using "tufte_handout", the outcome is as expected. Main text and inside chunk text is monochrome and TimesNewRoman. In rStudio, before build the book, I have tried in Sweave/Program defaults to use both Latex Engines, "xeLaTex" and "pdfLaTex"
index.Rmd 中的 YAML 标头
YAML header in index.Rmd
---
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 标头:
YAML header in each individual ChapterX.Rmd file:
---
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
---
我希望所有文档都具有相同的字体类型和单色.
I expect all document with the same font type and monochrome.
推荐答案
由于 bookdown::tufte_book2
未在您的主要 YAML 标头中指定,我假设您有一个 _output.yml
定义输出格式的文件.在这种情况下,您必须在那里添加 highlicht: monochrome
,即:
Since bookdown::tufte_book2
is not specified in your main YAML header, I assume you have an _output.yml
file that defines the output format. In that case, you have to add highlicht: monochrome
there, i.e.:
bookdown::tufte_book2:
highlight: monochrome
[other options]
这篇关于使用 bookdown 构建 tufte book 时如何更改块内使用的字体颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!