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 am using nested loop conditional \iftoggle of etoolbox, is there any other generalized conditional? Usually it works as:

\iftoggle{name}{do if name is true}{do if name is false}

Now, I would like something like:

\newtoggle{name} % with 5 options, for example
\settoggle{name}{option3} % all the other option are false
\iftoggle{name}{do if option1 is true}{do if option2 is true}{do if option3 is true}{do if option4 is true}{do if option5 is true}

I know there is a solution with nested conditional, but maybe there is other direct solution. Any idea?

share|improve this question
A toggle can be true or false, so this does not seem to make sense. It sounds as if you want something more like a keyval option which takes a number of choices: is that a reasonable description? – Joseph Wright Jan 26 '13 at 14:16
up vote 1 down vote accepted

Here is a key-value interface, which, as Joseph Wright has said, appears to be the way to get a solution to your problem.

\def\msg#1{\ifkrdindef\else Option chosen: #1\endgraf\fi}
% Example command, to reformat the list, process the keys, and print the results:

% Examples:
share|improve this answer

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.