[texhax] How to structure conditionals?
Karl Berry
karl at freefriends.org
Sun Oct 23 20:48:49 CEST 2005
Hi Chris,
\newcommand{\question}[3]{
\samepage{}
\thequestionnum) #1 #2
\addtocounter{questionnum}{1}
}
I'm not sure from your description how you intend \question to be
called. Could you give an example?
But I can't for the life of me figure out how to put in a
conditional, either checking a defined string at the beginning
I don't know how to use LaTeX conditionals, but the primitives \if and
\ifx can check these things, or maybe \ifcase would be better. For
example, you gave this example:
tells TeX "when you're in the first question, use the second question
conclusion; when you're in the second question, use the second question
conclusion; when you're in the third question, use the first question
conclusion".
And here is a sketch of some code, assuming some other counter like
\conclusion to tell you which conclusion to use.
\ifcase\questionnum
% q0, impossible
\or \conclusion=2 % q1
\or \conclusion=2 % q2
\or \conclusion=1 % q3
\fi
Hope this helps,
Karl
More information about the texhax
mailing list