0

Using a command within subimport leads to problems.

Consider the following files, which have to lay side-by-side in the same folder. test.tex:

\documentclass[]{letter}
\usepackage{import}

\def\AV{510}
\def\AVVers{4}

\begin{document}
The test-values are AV \AV{} V\AVVers{}.
\subimport{}{Test AV \AV{} V\AVVers{}.tex}
%\subimport{}{Test AV 510 V4.tex}

\end{document}

Test AV 510 V4.tex:

17

Using the first, unexpanded call of \subimport, we get the error message

! LaTeX Error: File `Test AV 510{} V4{}.tex' not found.

Using the second, expanded one, we get the expected result, namely enter image description here

I am aware that LaTeX macros use the first token as argument, such that one should use {} to prevent that the macro devours the first white space after it. But why is the macro evaluated somehow else within \subimport and what do I have to do to prevent it?

5
  • Does it work with \space instead of the first {}. (the second {} is anyway not needed) Commented Jul 1 at 11:30
  • @samcarter_is_at_topanswers.xyz Yes, it works visually, thanks! Are the two spaces ("\space" + " ") reduced into one and how could I change the definition of \AV (into something like: If the next token is a space, add \space before it? Commented Jul 1 at 12:09
  • There are no two spaces. Just like your \AV macro, \space will swallow the space after it. Commented Jul 1 at 12:13
  • 1
    The best way to fix this problem is to stop using spaces in file names. Commented Jul 1 at 12:13
  • Ok, I will do it this way. :-D I found it relatively curious that there are problems with spaces in file names as late as 2024, but not using them will not harm the project. Thanks for your prompt help and workaround. Write it as an answer and I will accept it. Commented Jul 1 at 13:18

1 Answer 1

0

TeXnically, you could use a \space instead of {}:

\documentclass[]{letter}
\usepackage{import}

\def\AV{510}
\def\AVVers{4}

\begin{document}
The test-values are AV \AV\space V\AVVers.
\subimport{}{Test AV \AV\space V\AVVers.tex}

\end{document}

The better solution would be to ditch using spaces in file names.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .