尝试使用自定义 mystyles.sty 文件从 RStudio 编织为 pdf。这曾经工作正常,但现在我已经升级到 RStudio 1.044,我收到错误。
Example:
---
title: "Test"
output:
pdf_document:
includes:
in_header: mystyles.sty
---
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
使用此样式文件:
\usepackage{titlesec}
\definecolor{airforceblue}{rgb}{0.36, 0.54, 0.66}
\definecolor{coolblack}{rgb}{0.0, 0.18, 0.39}
\titleformat{\title}
{\color{airforceblue}\normalfont\Large\bfseries}
{\color{airforceblue}\thesection}{1em}{}
\titleformat{\section}
{\color{coolblack}\normalfont\Large\bfseries}
{\color{coolblack}\thesection}{1em}{}
给我这个错误:
output file: test.knit.md
! Argument of \paragraph has an extra }.
<inserted text>
\par
l.1290 \ttl@extract\paragraph
pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted
如果我查看它生成的 tex 文件,我看不到任何缺失的大括号,并且没有第 1290 行。这是使用 RStudio、R 和 MacTex 的最新版本。正如我所说,这曾经适用于旧版本的 RStudio,但现在不行了。如果我从 YAML 中取出 include:... 位,它就会毫无怨言地呈现。有人能帮忙吗?
该问题与rmarkdown 乳胶模板 https://github.com/rstudio/rmarkdown/blob/master/inst/rmd/latex/default-1.17.0.2.tex重新定义\subparagraph{}
在某种方式titlesec
不喜欢,正如这个答案所暗示的那样tex.SE https://tex.stackexchange.com/questions/103020/extra-when-use-titlesec-package。这是导致问题的模板部分:
$if(subparagraph)$
$else$
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
$endif$
自从\subparagraph
仅当没有设置子段落变量时才会发生重新定义,一个简单的解决方法是将其设置在 yaml 前面的内容中。这编译得很好:
---
title: "Test"
output:
pdf_document:
includes:
in_header: mystyles.sty
subparagraph: true
---
然而,这可能不是最好的解决方案:最好从模板中修复子段落定义。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)