I’ve had a few chances in recent weeks to promote the xparse
package. Regular readers will know that xparse
is part of the efforts of the LaTeX3 Project, and is meant to provide a replacement for \newcommand
, etc., for creating document macros. The promotions have come up where there are things that are hard to do with \newcommand
but easy with xparse
. One example was creating an optional argument for a macro but giving it in normal braces. With xparse
, this is pretty straight forward
\documentclass{article}
\usepackage{xparse}
\NewDocumentCommand\en{g}{%
\IfNoValueTF{#1}{\epsilon}{\epsilon_{#1}}%
}
\begin{document}
\( \en \) and \( \en{stuff} \).
\end{document}
This is clear, and does not need any knowledge of the internals of the LaTeX3 approach. So I’m going to keep promoting xparse
for day to day LaTeX users, even if they aren’t using much code. Hopefully this will make life easier for them, and for me, and will be a real benefit now from the LaTeX3 work.