1

I have been banging my head on this problem for a few days, trying many combinations of \def, \edef, \noexpand, \expandafter, etc.

Say I have a module at /tmp/module/ which contains module.tex and image.png. In module.tex I define a macro which, among other things, uses \includegraphics to pull in the image within this submodule with a relative path:

% module.tex
\newcommand{\myQuizHeader}[1]{
  Quiz #1
  \includegraphics[width=1.5in]{image.png}
}

And then from my main document I do an \import or \subimport, and then try to use the \myQuizHeader macro:

% main.tex
\documentclass[11pt,letterpaper]{article}
\usepackage{graphicx}
\usepackage{import}

\begin{document}
  \import{/tmp/module/}{module.tex}
  \myQuizHeader{27}
\end{document}

While import correctly prepends the module path in order to find files and images relative to the module while inside module.tex, those paths get removed when leaving the module, so the macros defined in that module don't work correctly anymore. When I call \myQuizHeader{27} from the main file the image is not found.

What is the correct way to solve this? I tried playing tricks with saving the \Ginput@path variable to a local variable within the module, but then I got into \edef and \noexpand hell.

Many thanks!

  • If you just prepend /tmp/module/: to TEXINPUTS environment variable (or the \Ginput@path) you don't need \import to do anything just \includegraphics{image} should find image.png – David Carlisle Mar 25 '14 at 21:30

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.