我正在尝试使用以下方法使用beamer包插入背景图像:
\usebackgroundtemplate{%
\includegraphics[width=\paperwidth,keepaspectratio]{/path/to_file/background.png}%
}
我遇到的问题是我的后台文件路径中有一个下划线,正如我在上面的示例中所做的那样。 (这是我在OS X上的主目录,所以我无法真正改变它。)当我通过pandoc生成这个时,生成的乳胶文件的下划线转义为\,所以它看起来像这样:
\usebackgroundtemplate{%
\includegraphics[width=\paperwidth,keepaspectratio]{/path/to\_file/background.png}%
}
但这使得includegraphics无法找到该文件,因此它在那时失败了。
如果我手动从乳胶中删除\,或者将文件移动到根目录,以便路径中没有下划线,一切都很好。这是确切的错误:
LaTeX Warning: File `/Users/my\_name/Downloads/background.png' not fou
nd on input line 102.
! Package pdftex.def Error: File `/Users/my\T1\textunderscorename/Down
loads/background.png' not found: using draft setting.
那么有什么我可以告诉includegraphics名称是转义,还是删除转义?
这是YAML:
---
name: John Doe
backgroundImage: /Users/my_name/Downloads/background.png
---
要添加到模板的文本:
$if(backgroundImage)$
\usebackgroundtemplate{%
\includegraphics[width=\paperwidth]{$backgroundImage$}%
}
除非另有说明,否则YAML值将被解释为Markdown。因此,当在backgroundImage
中使用时,$backgroundImage$
被翻译成LaTeX。
解决方案是通过告诉pandoc您知道自己在做什么来强制对输入进行文字解释,并且输入已经格式化为LaTeX:
---
name: John Doe
backgroundImage: '`/Users/my_name/Downloads/background.png`{=latex}'
---
这是基于raw attribute extension,默认为pandoc风味的Markdown启用。