RMarkdown xelatex!缺少&已插入 [英] RMarkdown xelatex !Missing & Inserted

查看:200
本文介绍了RMarkdown xelatex!缺少&已插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最初在此处发布问题:

I originally posted with issues here:

带xelatex的Rmarkdown

此后,我已经重新安装,但是现在我遇到了一个全新的问题.

I have since reinstalled, but now I'm having an entirely new issue.

使用以下代码(在.Rmd文件中):

Using the following code (inside a .Rmd file):

---
header-includes:
- \usepackage{graphicx}
output: 
  pdf_document:
    latex_engine: xelatex
---

```{r}


knitr::include_graphics("F:/Big Folder/My Folder/image.png")

```

我收到以下错误:

! Missing $ inserted.
<inserted text> 
            $
l.134 .../Big Folder/My Folder/image}

pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43

我认为这与路径中的空间有关,因为当我将图像直接放在F中时,它可以正常工作.

I think it has something to do with the space in the path, because when I put the image directly in F, it works fine.

不幸的是,该项目要求我使用名称中带有空格的文件夹.

Unfortunately, this project requires that I use folders with spaces in the name.

我在Windows 10 64位上,使用更新的软件包(包括fontspec)运行MikTex 2.9. Miktex已安装在程序文件中,但我也尝试将其安装到其他文件夹,但结果相同.

I'm on Windows 10 64 bit, running MikTex 2.9 with updated packages (including fontspec). Miktex is installed in program files, but I also tried an install to a different folder but had the same result.

我还在运行最近安装/更新的带有更新的knitr和rmarkdown软件包的rstudio.

I'm also running a recently installed/updated rstudio with updated knitr and rmarkdown packages.

可以在pdflatex上起作用,即使文件名中有空格也是如此.

This does work on pdflatex, even with spaces in the file name.

推荐答案

知道了,实际的图像文件被格式化为image_something.png.

Got it, the actual image file was formatted as image_something.png.

"_"被扔掉并移除后修复了它.

The "_" was throwing it off and removing it fixed it.

此外,如果要保留下划线,则需要添加两个转义字符"\\".

Also, if I want to keep the underscore I need to add two escape characters "\\".

F:/Big Folder/image\\_something.png

这与非rmarkdown乳胶解决方案有些不同,因为它仅需要一个转义字符.

This is somewhat different than the non rmarkdown latex solution in that it only requires a single escape character.

此解决方案已从我仍然对为什么为什么允许在pdflatex而不是xelatex上使用空格感到好奇.

I would still be curious as to why spaces are allowed on pdflatex but not xelatex.

这篇关于RMarkdown xelatex!缺少&amp;已插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆