这几乎肯定是某个地方犯了一个愚蠢的错误。我本质上是在尝试做正在做的事情这里. 我的 MWE 项目:
$ find ./
./
./common
./common/preambleCommon.tex
./mydoc
./mydoc/mydoc.tex
mydoc.tex:
\documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\newcommand*{\commonDir}{../common/}% %
\input{\commonDir{preambleCommon}} %
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
Hello!
\mytestcmd
\end{document}
序言Common.tex:
\newcommand*{\mytestcmd}{Hello, from my test cmd.}
当我运行时latex mydoc.tex
,出现了以下情况:
! LaTeX Error: File `../common/preambleCommon.tex' not found.
但如果我ls ../common/preambleCommon.tex
这样做,它就会出现。
答案1
LaTeX的错误信息是错误的,应该是:
! LaTeX Error: File `../common/{preambleCommon}.tex' not found.
错误很明显:花括号。它们没有作为参数括号被删除,因为\commonDir
中不接受参数\input{\commonDir{preambleCommon}}
。
更正:
\newcommand*{\commonDir}{../common/}%
\input{\commonDir preambleCommon}% space is automatically gobbled after command name