【发布时间】:2015-08-05 06:42:28
【问题描述】:
我正在使用 Rstudio 编写一个 RMarkdown 文档,我通过 knitr 和 pandoc 在 Windows 上使用 MiKTeX 将其转换为 PDF。 LaTeX 引擎是 xelatex。
我的 .Rmd 文件 YAML 标头:
---
title: "My Title"
author: "Me"
geometry: margin=2cm
output:
pdf_document:
fig_caption: no
fig_height: 4
fig_width: 6
latex_engine: xelatex
html_document:
css: styles.css
keep_md: no
fontsize: 10pt
---
在我的文字中
...parameter $\lambda=0.2$ with...
我得到“参数 = 0 2 with”——lambda 甚至点都丢失了。
这一行
mean of $\frac{1}{\lambda}=5$ of the
变成
编辑:当我尝试添加为实验时(我在 Windows 上)
mainfont: Arial
到 YAML 标头我得到一个 pandoc 错误
! Undefined control sequence.
\fontspec_calc_scale:n ...ec_tmpb_dim }\fp_div:Nn
\l_fontspec_tmpa_fp {\l_fo...
l.18 \setmainfont{Arial}
pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
更新:
运行 pdflatex report1.pdf 会生成正确的 PDF。
RStudio 运行 "C:/Program Files/RStudio/bin/pandoc/pandoc" report1.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output report1.pdf --template "D:\Documents\R\win-library\3.2\rmarkdown\rmd\latex\default.tex" --highlight-style tango --latex-engine xelatex
因此,其他地方推荐的引擎“xelatex”似乎产生了错误的输出,而“pdflatex”则有效。不幸的是,我忘记了一些来源给出的原因,包括。所以几天前我在切换到 xelatex 时遵循,我只记得强烈建议在 RStudio 中使用 knitr 而不是 pdflatex。
【问题讨论】:
-
它适用于我的电脑(Linux、livetex)。你能不能一步一步来试试:先用
knitr::knit把你的Rmd转换成md,然后用pandoc把md转换成latex,然后用xelatex把latex转换成pdf? -
这是 LaTeX,看起来不错:pastebin.com/J9LY53gS 所以我猜这是 MiKTeX/Windows 问题。
-
我无法在 Linux 或 Windows 上重现此内容。我也猜这是 MikTeX 安装的问题。您没有提供 MikTeX 的版本(如果不是最新版本,请尝试升级)。您可能还想升级 RStudio (rstudio.com/products/rstudio/download/preview) 和您的 R 包。顺便说一句,除非您使用 CJK 字符,否则我对使用 xelatex 没有强烈的论据。对于纯英文文档,我不知道为什么 pdflatex 可能是一个不好的选择。
-
最新的 MiKTeX,前几天才安装的。我也运行了包更新。
-
@lihang 我不确定它是否完全相同,但我解决了我的问题:在目录
C:\Program Files\MiKTeX 2.9\miktex\bin\x64我运行了 updmap.exe。之后,奇怪的方程的问题就解决了。
标签: r latex knitr pandoc miktex