# [Tex/LaTex] Meaning of an asterisk (*) in a macro name

macrosstarred-version



Are there any guidelines about how to chose which version of a macro should be the starred condition?

As far as I know there are no such guidelines. As the author (and user) of a macro, you can decide how to use the starred version. But for a little consistency I’d use the star as mark for not numbered if the macro does something with numbering (as in your example).

Otherwise I’d prefer to use the non starred version as default (often used) and the starred version as special.


To define a starred macro one can use the LaTeX way with \@ifstar or the xparse package, which I prefer since you need no helper macros:

\documentclass{article}

\usepackage{xparse}

\NewDocumentCommand\foo{ s m }{% s = star, m = mandatory arg
\IfBooleanTF{#1}{%
Argument: #2 (starred)%
}{%
Argument: #2 (non-starred)%
}%
}

\begin{document}
\foo{Test}

\foo*{Test}
\end{document}