TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Can you give an example of your code? – egreg Feb 27 '13 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. – Peter Grill Feb 27 '13 at 21:10
Yes, it is possible. ;) – mbork Feb 27 '13 at 21:13
I've added what I would do, but I already know that it won't work. – user17786 Feb 27 '13 at 21:19
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 ` – clemens Feb 27 '13 at 21:29
up vote 8 down vote accepted

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}

share|improve this answer
Thanks! It is really simple. – user17786 Feb 27 '13 at 21:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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