# how to comment text depending on a number

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.

\newcommand\qone[1]{\ifstrequal{label}{1}{#1}{}}
\newcommand\qtwo[1]{\ifstrequal{label}{2}{#1}{}}
\newcommand\qthree[1]{\ifstrequal{label}{3}{#1}{}}
\newcommand\qfour[1]{\ifstrequal{label}{4}{#1}{}}
\newcommand\qfive[1]{\ifstrequal{label}{5}{#1}{}}
\newcommand\qsix[1]{\ifstrequal{label}}{6}{#1}{}}
\newcommand\qseven[1]{\ifstrequal{label}{7}{#1}{}}
\newcommand\qeight[1]{\ifstrequal{label}{8}{#1}{}}


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.

-
Can you give an example of your code? –  egreg Feb 27 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 at 21:10
Yes, it is possible. ;) –  mbork Feb 27 at 21:13
I've added what I would do, but I already know that it won't work. –  user17786 Feb 27 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  –  cgnieder Feb 27 at 21:29
show 1 more comment

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

\documentclass{article}

\newcommand\usequestion{2}

\newcommand\question[2]{\ifnum\usequestion=#1\relax#2\fi}

\begin{document}

\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}

\end{document}
`
-
Thanks! It is really simple. –  user17786 Feb 27 at 21:47