3

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 standaloneis 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!

2

This could work:

\documentclass{exam}
\usepackage{standalone} %or any suitable package

\begin{document}
  \begin{questions}
  \renewenvironment{questions}{}{}
     \input{exercise1}
     \input{exercise1}
     \input{exercise1}
  \end{questions}
\end{document}
|improve this answer|||||
  • Welcome... Happy TeXing! – koleygr Mar 4 '19 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.