How to change the font colour used inside the chunks when building a tufte book using bookdown?

℡╲_俬逩灬. 提交于 2019-12-24 11:27:38

问题


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.

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"

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"]
---

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.


回答1:


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]


来源:https://stackoverflow.com/questions/56297474/how-to-change-the-font-colour-used-inside-the-chunks-when-building-a-tufte-book

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!