# How to include files from a directory specified by a concatenation of text and a macro?

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.

## 1 Answer

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

• I did read the space gobbling but forgot about it ... thanks! – bbarker Apr 21 '14 at 23:47