r-使用自定义LaTeX样式文件使用rmarkdown渲染PDF时出错
基于user3143179的命令,我创建了custom.sty来指定字体和LaTeX包,用于使用rmarkdown呈现PDF custom.sty的内容如下: 我使用fontspec手册创建了上面关于特定系统字体的代码 我运行了以下R代码:r-使用自定义LaTeX样式文件使用rmarkdown渲染PDF时出错,r,pdf,latex,r-markdown,R,Pdf,Latex,R Markdown,基于user3143179的命令,我创建了custom.sty来指定字体和LaTeX包,用于使用rmarkdown呈现PDF custom.sty的内容如下: 我使用fontspec手册创建了上面关于特定系统字体的代码 我运行了以下R代码: rmarkdown::render("custom.Rmd", pdf_document(highlight = "kate", fig_caption = FALSE, latex_engine = "lualatex", keep_tex = TRUE,
rmarkdown::render("custom.Rmd", pdf_document(highlight = "kate",
fig_caption = FALSE, latex_engine = "lualatex", keep_tex = TRUE, includes
= includes(in_header = "custom.sty")))
这是运行R代码的输出:
processing file: custom.Rmd
|.................................................................| 100%
ordinary text without R code
output file: custom.knit.md
/usr/bin/pandoc +RTS -K512m -RTS custom.utf8.md --to latex
--from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures
--output custom.tex --template /rmarkdown/rmd/latex/default.tex --highlight-style kate
--latex-engine lualatex --include-in-header custom.sty --variable graphics=yes
/usr/bin/pandoc +RTS -K512m -RTS custom.utf8.md --to latex
--from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures
--output custom.pdf --template /rmarkdown/rmd/latex/default.tex --highlight-style kate
--latex-engine lualatex --include-in-header custom.sty --variable graphics=yes
错误
我还有原始的.tex文件,以防你也需要查看它。.tex文件中有\begin{document}
.sty文件中还需要哪些其他组件,以便使用rmarkdown将LaTeX文件正确地呈现为PDF格式
在调用rmarkdown::render时还需要其他什么吗?当我从custom.sty中删除\endinput时,它对我很有用。问题是include就像\include in TeX一样逐字输入文件。因此,将custom.sty重命名为header.tex更有意义 你指的是哪一个答案?没有工作链接。我再次将链接添加到答案。感谢您建议将文件命名为header.tex。
processing file: custom.Rmd
|.................................................................| 100%
ordinary text without R code
output file: custom.knit.md
/usr/bin/pandoc +RTS -K512m -RTS custom.utf8.md --to latex
--from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures
--output custom.tex --template /rmarkdown/rmd/latex/default.tex --highlight-style kate
--latex-engine lualatex --include-in-header custom.sty --variable graphics=yes
/usr/bin/pandoc +RTS -K512m -RTS custom.utf8.md --to latex
--from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures
--output custom.pdf --template /rmarkdown/rmd/latex/default.tex --highlight-style kate
--latex-engine lualatex --include-in-header custom.sty --variable graphics=yes
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.95 \setmainfont{LiberationSerif-Regular.ttf}[
pandoc: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43