I have a latex document with 24 questions labeled with numbers from 1 to 8. I want to give a number x between 1 and 8 to latex in the preamble so that all the questions become commented except the ones numbered by x. Is it possible to do that?

My idea was to write something like:

\def\label{3} %this number says which question is not going to be commented.


and then enclose question 1 in \qone{...}, question 2 in \qtwo{...} and so on. I know that this won't work, but I can't figure how to write it from the etoolbox userguide.

  • 1
    Can you give an example of your code?
    – egreg
    Feb 27, 2013 at 21:10
  • That is going to depend on exactly how you have labelled them. It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. Feb 27, 2013 at 21:10
  • Yes, it is possible. ;)
    – mbork
    Feb 27, 2013 at 21:13
  • I've added what I would do, but I already know that it won't work.
    – user17786
    Feb 27, 2013 at 21:19
  • 1
    Since \ifbool suggests you're already using the etoolbox package you might want \ifnumequal{<num>}{<num>}{<true<}{<false>}. And then there's of course TeX's \ifnum<num>=<num>\relax <true>\else <false>\fi `
    – cgnieder
    Feb 27, 2013 at 21:29

1 Answer 1


don't use \label that is a standard latex command.

I would use a single command with the question type/number as an argument rather than lots of commands, something like this





\question{1}{this is a one qn}

\question{2}{this is a two qn}

\question{3}{this is a three qn}

\question{1}{this is another one qn}

\question{2}{this is another two qn}

\question{3}{this is another three qn}


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .