For several years I've used the following in most LaTeX documents to input a macros file that lives in different folders on my Mac and my Linux machine:
\InputIfFileExists{/Mac/path/macros.tex}%
{\input{/Mac/path/macros.tex}}
{\input{/linux/path/macros.tex}}
It worked splendidly until I recently updated my TeX distribution. After updating, I got an error even with this MWE:
\documentclass{amsart}
\InputIfFileExists{/Mac/path/macros.tex}%
{\input{/Mac/path/macros.tex}}
{\input{/linux/path/macros.tex}}
\begin{document}
text
\end{document}
The error reads:
Command \first already defined. Or name \end... illegal, see p. 192 of the manual.
(Here \first
is the first command defined in my file macros.tex
.)
I see now that changing to \IfFileExists
fixes everything, and I'm happy to do that. I'm curious, though, why does \InputIfFileExists
throw this error?
A quick Something search for \InputIfFileExists
didn't turn up much useful, just this old TeX.SE question.
\input{macros}
the test should not be needed, presumablyamsart.cls
is in a different location on the two machines but you do not need to refer to the path at all, just the local file name and arrange the search paths are set up correctly in both cases.