\newfontfamily 未定义控制序列

\newfontfamily 未定义控制序列

我正在 rmarkdown 中制作一份 latex 文档。我想更改表格中使用的字体。我正在关注 stack overflow 上的这个答案:https://stackoverflow.com/questions/54720299/rmarkdown-different-font-types-in-table-using-kable

但是,我甚至无法让第一部分工作。我收到错误:

! Undefined control sequence.
<recently read> \newfontfamily 

这是我的 YAML:

---
title: "Queries"
header-includes:
- \usepackage{pdflscape}
- \usepackage{longtable}
- \usepackage{xcolor}
- \newfontfamily\helvetica[Path= Fonts/, ItalicFont = {Helvetica italic}, BoldFont = {Helvetica bold}]{Helvetica}
- \newenvironment{ctable}{\helvetica }{}
- \newenvironment{capctable}[1][t]{\begin{table}[#1]\centering\helvetica}{\end{table}}
output: 
  pdf_document:
    toc: false
---

我对 \newfontfamily 做错了什么?我也尝试过删除,, ItalicFont = {Helvetica italic}, BoldFont = {Helvetica bold}但出现同样的错误

header-includes如果我按如下方式重新排列参数的顺序

---
title: "Queries"
header-includes:
- \newfontfamily\helvetica[Path= Fonts/ ]{Helvetica}
- \newenvironment{ctable}{\helvetica }{}
- \newenvironment{capctable}[1][t]{\begin{table}[#1]\centering\helvetica}{\end{table}}
- \usepackage{pdflscape}
- \usepackage{longtable}
- \usepackage{xcolor}
output: 
  pdf_document:
    toc: false
---

我收到类似但不同的错误:

! Undefined control sequence.
l.61 \newfontfamily
                   \helvetica[Path= Fonts/ ]{Helvetica} 

相关内容