5

This is almost certainly a silly mistake somewhere. I'm essentially trying to do what is being done here. My MWE project:

$ 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}

preambleCommon.tex:

\newcommand*{\mytestcmd}{Hello, from my test cmd.}

When I run latex mydoc.tex, this comes up:

! LaTeX Error: File `../common/preambleCommon.tex' not found.

But if I do ls ../common/preambleCommon.tex it shows up.

bbarker
  • 1,177

1 Answers1

5

The error message of LaTeX is wrong, it should read:

! LaTeX Error: File `../common/{preambleCommon}.tex' not found.

The the error is clear: the curly braces. They are not removed as argument braces, because \commonDir does not take an argument in \input{\commonDir{preambleCommon}}.

Corrected:

\newcommand*{\commonDir}{../common/}%
\input{\commonDir preambleCommon}% space is automatically gobbled after command name
Heiko Oberdiek
  • 271,626