我愚蠢地在文件路径中添加了 #(数字符号)。每当我引用它时,都会生成以下错误:
Illegal parameter number in definition of \reserved@a. [.../Paper#1/2016-02-14/paper1_2016-02-14.pdf}]
有没有比重命名文件夹更简单的解决方案,然后更改其中的所有代码来反映这一点?
\documentclass[a4paper,12pt]{article}
\begin{document}
\includepdf[pages=-]{../../Paper#1/2016-02-14/paper1_2016-02-14.pdf}
\end{document}
答案1
\documentclass[a4paper,12pt]{article}
\begin{document}
\begingroup\catcode`\#=12
\newcommand\hashchar{}%check that is doesn't exist
\gdef\hashchar{#}
\endgroup
\input{paper\hashchar 1/test}
%or change the catcode locally:
\begingroup
\catcode`\#=12
\input{paper#1/test}
\endgroup
\end{document}
答案2
如果您的调用\includepdf
从未成为另一个命令的参数,您可以通过吸收文件名作为逐字参数来实现:
\documentclass[a4paper,12pt]{article}
\usepackage{pdfpages,xparse,letltxmacro}
\LetLtxMacro\originalincludepdf\includepdf
\RenewDocumentCommand\includepdf{O{}v}{\originalincludepdf[#1]{#2}}
\begin{document}
\includepdf[pages=-]{../../Paper#1/2016-02-14/paper1_2016-02-14.pdf}
\end{document}