# Using \subimport inside \newcommand

I am using the command \subimport and I am very happy with it. However, it doesn't seem to work when I use it inside a \newcommand environment.

My file structure is as follows:

./main.tex
./Macros/macros.tex
./Macros/Submodules/stringdiagrams.tex
./Macros/Submodules/symbols/somefile.tex

./main.tex is as follows:

\documentclass{article}

\usepackage{import}
\usepackage{tikz}

\import{Macros/}{macros}

\begin{document}

$\MyInlineFigure$
$\test$
\end{document}

My macros are written in a modular style, and every macro submodule is called from ./Macros/macros.tex, that looks as follows (it is a one-line file for this MWE):

\subimport{Submodules/}{stringdiagrams}

The file ./Macros/Submodules/stringdiagrams.tex contains some commands to display tikz figures in an inline environment. These files are kept in the folder ./Macros/Submodules/symbols. ./Macros/Submodules/stringdiagrams.tex looks as follows:

\newcommand{\MyInlineFigure}{
\subimport{symbols/}{somefile}
}

\newcommand{\test}{
\begin{tikzpicture} [scale=1,transform shape]
\node [fill=red] (mult) at (0,0) {};
\end{tikzpicture}
}

Finally, ./Macros/Submodules/symbols/somefile.tex is just

\begin{tikzpicture} [scale=1,transform shape]
\node [fill=red] (mult) at (0,0) {};
\end{tikzpicture}

Theoretically, the commands $\MyInlineFigure$ and $\test$ should produce the same output, and I should see two red squares. However, when I try to compile LaTeX cannot find somefile.tex.

If in ./Macros/Submodules/stringdiagrams.tex I replace \subimport{symbols/}{somefile.tex} with \input{Macros/Submodules/symbols/somefile.tex} then everything works.

If in main.tex I comment out $\MyInlineFigure$ then it compiles and correctly shows a red square, proving that

• \subimport is able to reach ./Macros/Submodules/stringdiagrams.tex
• The problem is not tikz.

In the end, it looks like \subimport is not working when I call it inside a \newcommand. Is there a way to fix it?

• It's very difficult to answer this question in the present form. You know your setup, we don't. Can you please add a simple example starting from \documentclass up to \end{document}? – egreg Apr 18 '17 at 8:56
• I edited my question, now it is a MWE. You can just copy-paste the contents of every file ad arrange them in the same file hierarchy I gave and the problem should be reproducible. Thanks, Fab – – Nigredo Apr 20 '17 at 18:49