von phi » Di 16. Feb 2010, 15:20
Verwende nicht \ifthenelse, es ist nicht expandierbar, expandiert aber sein Argument, was je nach Situation zu verschiedenen Problemen führen kann. Verwende stattdessen expandierbare Tests aus moderneren Paketen wie etoolbox oder expl3 oder primitive TeX-Tests wie \ifnum. Die sind gleich mächtig wie \ifthenelse, aber die Syntax ist anders.
Die Probleme des ifthen-Pakets werden auch in der Dokumentation erwähnt: „It is unfortunate that in order to remain compatible with ifthen syntax, it is necessary to have a two pass system. The first pass inside an \edef ‘exposes’ the \if. . . \fi tokens, so the corect clauses may be skipped on the second pass. This means that the whole \ifthenelse command does not work by expansion, and so possibly has only limited usefulness for macro code writers. The main problem with the ifthen: syntax is that (unique for LATEX) it does not uses a brace delimited argument form, and exposes the primitive TEX syntax for ⟨number⟩. Pretty much the only way of parsing 1 > 2 \or 2 < 1 is to actually evaluate the
primitive \ifnums. A syntax such as: \or{\numtest{1<2}}{\lengthtest{1pt<1in}} could easily be evaluated in a one pass way, operating directly via expansion, and leaving no extra tokens in the token stream.“
Wie genau sieht denn dein Vergleich aus? 1<2 wird es ja kaum sein.
Verwende nicht \ifthenelse, es ist nicht expandierbar, expandiert aber sein Argument, was je nach Situation zu verschiedenen Problemen führen kann. Verwende stattdessen expandierbare Tests aus moderneren Paketen wie etoolbox oder expl3 oder primitive TeX-Tests wie \ifnum. Die sind gleich mächtig wie \ifthenelse, aber die Syntax ist anders.
Die Probleme des ifthen-Pakets werden auch in der Dokumentation erwähnt: „It is unfortunate that in order to remain compatible with ifthen syntax, it is necessary to have a two pass system. The first pass inside an \edef ‘exposes’ the \if. . . \fi tokens, so the corect clauses may be skipped on the second pass. This means that the whole \ifthenelse command does not work by expansion, and so possibly has only limited usefulness for macro code writers. The main problem with the ifthen: syntax is that (unique for LATEX) it does not uses a brace delimited argument form, and exposes the primitive TEX syntax for ⟨number⟩. Pretty much the only way of parsing 1 > 2 \or 2 < 1 is to actually evaluate the
primitive \ifnums. A syntax such as: \or{\numtest{1<2}}{\lengthtest{1pt<1in}} could easily be evaluated in a one pass way, operating directly via expansion, and leaving no extra tokens in the token stream.“
Wie genau sieht denn dein Vergleich aus? 1<2 wird es ja kaum sein.