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

Is there some way to create more advanced conditional statements that can evaluate a logic expression and decide what to do based on the value of the expression? For example like in the following very simple pseudocode:

if A or B then
    do something
    do something else
end if

where A and B are flags or booleans. Or maybe A is a logic expression, checking if x > y, where x and y are real numbers. Is there some simple way to do this?

share|improve this question
You can do anything you can do with else and or with a bit of thought and nested conditionals. – Seamus Jun 28 '12 at 11:42
Look at the package ctan.org/pkg/etoolbox – Herbert Jun 28 '12 at 11:54
See also LaTeX conditional expression – Leo Liu Jun 28 '12 at 12:03
Here's a nice write up on a blog. – Seamus Jul 2 '12 at 11:29
up vote 5 down vote accepted

You could use the standard latex ifthen package (or there are more efficient and expandable ways to do the same thing, if that is needed).

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.