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 is as follows:






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):


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:


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

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

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

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?

  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.