Take the 2-minute tour ×

In the LaTeX companion, the authors recommend to use the package ifthen for complex conditional.

But in his answer to LaTeX conditional expression Will Robertson doesn't mention it, and in the comments, Philipp says that the package is obsolete.

The question is in which way ifthen is obsolete and what are the risk to use it in a document.

share|improve this question
Note that my comment is only a one-liner, not an exhaustive explanation. "Obsolete" here just means "for many problems there exist better solutions nowadays." –  Philipp Mar 19 '11 at 14:32
add comment

2 Answers

up vote 48 down vote accepted

The main reason why people may consider ifthen obsolete (last version is of 2001/05/26 with about one page of user manual plus four pages of code documentation) is that it is superseded by e.g. etoolbox, which uses the advanced possibilities of eTeX. Using these allows faster processing. You still can use ifthen for your existing and new documents if you like and I don't think there is a risk in doing so. However for new code, especially new packages which use a lot of boolean expression using the more modern alternatives is recommended.

share|improve this answer
Not to mention that etoolbox is fantastically useful for other things too. –  TH. Mar 19 '11 at 11:10
Perhaps to have some faster codes, the better solution is to use TeX's primtives or eTeX's primitives directly –  Alain Matthes Mar 19 '11 at 12:16
@Altermundus: I prefer \if-switches before booleans as well, but I see also the drawbacks. The way TeX is skipping false branches has its drawbacks. Also for more complex expressions a framework is very handy. –  Martin Scharrer Mar 19 '11 at 12:38
@Martin: I agree that for more complex expressions, a framework is very handy. Do you know some packages that use etoolbox (for examples)? –  Alain Matthes Mar 19 '11 at 13:20
On the other hand, \ifstrequal from etoolbox doesn’t work in all circumstances where \ifthenelse{\equal…} works. –  Konrad Rudolph Mar 19 '11 at 14:22
show 2 more comments

From my experience in various forums and newsgroups, ifthen often seems to do more harm than good, especially when used by newbies. The main \ifthenelse command is fragile, so something like


doesn't work. The comparison is not expandable, so that the command "possibly has only limited usefulness for macro code writers" (quoted from the ifthen manual). Plus I find the syntax quite cumbersome compared to e.g.


This is not a diss of the ifthen package; its weaknesses are known and unavoidable because it had to be compatible to an older macro package and was written long before e-TeX was implemented. I just conclude that for many problems there exist solutions with fewer problems. If you want to use the ifthen package, then that is fine, but you should know about its limitations.

share|improve this answer
I don't know etoolbox so perhaps my answer will be different in several months, but actually I know some limitations of ifthen and I know the problems with fragile commands (it's not possible to avoid all of them), so my first idea would be : \DeclareRobustCommand\title{\ifthenelse{\equal{a}{a}}{b}{c}} \section{\title}. Now it will be interesting to know the limitation of etoolbox. I agree that etex is virtually indispensable. –  Alain Matthes Mar 19 '11 at 15:32
add comment

Your Answer


