I have the following latex file structure (for a good reason) and I would like to use preamble in both main.tex
and other_main.tex
|-main.tex
|-subsections
|-preamble.tex
|-input1.tex
|-other_main
|-other_main.tex
However, the issue is that preamble inputs input1.tex
. For main.tex
to be compiled, preamble.tex needs to use
\input{subsections/input1}
While for other_main.tex
to be compiles, preamble.tex
needs to use
\input{../subsections/input1}
What I've tried: using versions
package with the following files:
preamble.tex
\begin{main}
\input{subsections/input1}
\end{main}
\begin{other}
\input{../subsections/input1}
\end{other}
input1.tex
\newcommand{\hi}{hi}
main.tex
\documentclass{article}
\usepackage{versions}
\includeversion{main}
\excludeversion{other}
\input{preamble}
\begin{document}
\hi
\end{document}
But I'm getting ! Undefined control sequence. \hi
error.
I could make a copy of preamble.tex
with the different input location, but that is not desirable as the contents of preamble may change over time.
Any idea how to tackle this problem? Thanks in advance!