TransWikia.com

Include specific parts of a standalone subfile

TeX - LaTeX Asked by kuzdogan on January 26, 2021

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!

One Answer

This could work:

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

begin{document}
  begin{questions}
  begingroup
     renewenvironment{questions}{}{}
     input{exercise1}
     input{exercise1}
     input{exercise1}
  endgroup
  end{questions}
end{document}

Correct answer by koleygr on January 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP