Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
else
    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
1  
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
1  
Look at the package ctan.org/pkg/etoolbox –  Herbert Jun 28 '12 at 11:54
1  
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

1 Answer 1

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

 
discard

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.