如何将选项传递给 R Markdown 中的 LaTeX 字体?

How to pass options to a LaTeX font in R Markdown?

rmarkdown,在 {xe|lua}latex 之后,允许为主要文本、sans-serif 文本、等宽文本(最显着的代码块!)和数学字体指定字体在 YAML header 中。至少对于通过 xetex 呈现的 PDF,这是有效的。

但是,我发现没有(已记录的)方法可以将选项传递给基础 setxxxfont \LaTeX 命令。例如,YAML 片段:

```
monofont: Inconsolata
```

生成以下 \LaTeX 片段:

\setmonofont[Mapping=tex-ansi]{Inconsolata}

我有两个问题:

  1. 为什么要添加 Mapping=tex-ansi?以及如何控制它? (我在 UTF8 中工作...)。
  2. 如何为字体选项设置额外的参数,即 \setmonofont[Scale=0.91]{TeX Gyre Cursor}

R Markdown book and the Pandoc's User's Guide 没有透露任何相关内容。

背景:

R Markdown 将 knitted 代码转换为输出格式(PDF)时,使用了 pandoc 模板。模板存储 within the package,任何被 YAML 变量替换的变量都包含在 $$ 符号

1.编码

Mapping=tex-ansi 作为解决方法添加到代码中,作为 GitHub 上报告的问题。因此,出于潜在的副作用,我会谨慎删除它。

如果您确实希望更改此代码,则必须复制一份用于转换文档的 LaTeX 模板文件。您可以找到默认模板 here. See here for some more information on providing custom templates.

2。其他字体选项

您可以使用 monofontoptions YAML 参数为字体选项添加额外的参数。

Documentation of the variables which can be parsed by the LaTeX output are available in the pandoc documentation