[Tex/LaTex] Conditional typesetting / build


Let's say I have .tex file which is a set of problems and solutions, of which I want to make two pdf files, one which includes the solutions and one which doesn't. so I need to build the .tex file under two different modes, and specify that parts of the document be ignored under one of the modes.

This is something common in programming context. e.g. in C++ i can code

#ifdef DEBUG
  // do this additional stuff ...

How can I do something equivalent in latex?

Best Answer

As I mentioned here, the simplest way might be conditionals:

\answerstrue % comment out to hide answers