I'm trying to compile one main file of exercises where each exercise is a standalone TeX file. standalone
is the perfect package for that but it lacks the customizability to choose a specific part of the subfile to be added.
In this case, I'm using documentclass{exam}
which takes individual questions in \question
and enumerates them. The problem with the standalone
is when each exercise is a standalone TeX file, combining them assigns each of the exercises in the main file the number 1., they won't enumerate.
My goal main file:
\documentclass{exam}
\usepackage{standalone} %or any suitable package
\begin{document}
\begin{questions}
\input{exercise1}
\input{exercise2}
\input{exercise3}
\end{questions}
\end{document}
A sample exercise file:
% exercise1.tex
\documentclass{exam}
\begin{document}
\begin{questions}
\question A sample question
\begin{solution}
Solution Here
\end{solution}
\end{questions}
\end{document}
Since this approach includes \begin{questions}
field to the main file it does not work. It ends up with two nested \begin{questions}
So is there a package to include what's inside a specific tag or environment (question
env. in my case) or another workaround for this. Thanks!