Code: Select all
ifx&%
\else{something\fi}
and what is the difference with:
Code: Select all
\ifthenelse{\equal{#1}{}}{}{something}
Code: Select all
ifx&%
\else{something\fi}
Code: Select all
\ifthenelse{\equal{#1}{}}{}{something}
NEW: TikZ book now 40% off at Amazon.com for a short time.
\ifx
tests if the two following tokens are equal:
Code: Select all
\ifx<1><2>
true
\else
false
\fi
Code: Select all
\ifx&
true
\else
false
\fi
#1
is empty or not. An empty #1
would mean that \ifx
sees two »&« directly after one another which would lead to »true«.
Code: Select all
\documentclass{article}
\begin{document}
\newcommand\test[1]{%
\ifx&%
true%
\else
false%
\fi}
\test{} % true
blank is \emph{not} empty:
\test{ } % false
\test{a} % false
\end{document}
Code: Select all
\documentclass{article}
\usepackage{ifthen}
\begin{document}
\newcommand\test[1]{%
\ifthenelse{\equal{#1}{}}{true}{false}}
\test{} % true
\test{ } % false
\test{a} % false
\end{document}
\ifthenelse
is defined I might be mistaken, though.NEW: TikZ book now 40% off at Amazon.com for a short time.