# Do all starred commands have anything in common?

\section* produces an unnumbered section, align* makes the environment unnumbered, which is comparable in a way. \newcommand* doesn't accept \par in its argument, which is different.

Stefan Kottwitz wrote:

Commonly, a star symbol * means a version of a command that behaves differently from the original. That often means suppressing numbering but could also refer to special features.

This might answer my question, but perhaps there's more to say (and it's nice to have it as a separate question).

Is there anything all starred commands have in common? Why would one define a starred command as opposed to another, differently named command indicating their semantic difference in the names? It seems that their definitions are usually entirely independent from each other.

-
There was some discussion going on earlier (here on TeX.SX, but I do not remember exactly where...) and I remember having read something - it came from @Joseph Wright - about starred commands expanding differently than their counterparts... maybe I'm saying something stupid here. I'm sorry if that's too little information... –  Count Zero Oct 4 '11 at 16:22

Why do we give commands names? To indicate, ideally as clearly as possible, what it is that they do.

If you have two things that do very similar things, it makes sense to give them very similar names. On the other hand, if they do one thing significantly differently, you would like to be able to easily tell the two names apart, despite those names being similar. As an asterisk is a non-alphabetical character, and fairly dense, it stands out. It is therefore a reasonable way to modify the name of one command, to obtain a similar but easily distinguished command name.

But no, there isn't anything which all starred variants have in common. The command \section*, the amsthm command \newtheorem*, and the amsmath environment align* are un-numbered variants of their un-starred cousins. However:

• \newcommand* creates a macro which will not accept carriage returns in any of its arguments.
• \vspace* adds vertical space which will not be suppressed at the beginning or end of a page.
• \\* creates a new line which will not cause a page break.
• \tag* (in amsmath) allows you to add a visual label, comment, or other number-replacement for an equation, without the usual parentheses.

There is a bit of a theme of negation here, but it's not clear that these negations are of anything in common (aside, trivially, from "default" behaviours).

-
small adjustment: \vspace* adds vertical space that will not disappear at the beginning of a page. similarly, \hspace* adds horizontal space that will not disappear at the beginning of a line. –  barbara beeton Oct 4 '11 at 17:14
Hm. The internets are not proving very reliable on indicating that, at least not if one searches for \vspace LaTeX on Google. –  Niel de Beaudrap Oct 4 '11 at 17:25
haven't tried any internet searches, but the statements on p.102 of lamport's manual are definitive. (\hspace* is "never removed, even when it comes at the beginning or end of a line." comparable behavior for \vspace* on a page. spaces at the end of a line or page usually aren't as obvious as ones at the beginning, though.) have edited in "or end" to dexcription of \vspace* in question, since it affects both. –  barbara beeton Oct 4 '11 at 17:45

Mmm, \section* is simply easier to write than \sectionnotnumbered. Note that there aren't actual two macros defined, \section simply checks if a stars follows or not and branches accordantly. (Starred environment however, are defined independently from the normal version.) They can behave almost the same or completely different depending how they are coded. There is no official logical guideline about that and the documentation of that macros must explain what the different is.

The benefits to use starred versions IMHO are that you still have the same macro name but you can create a normally slightly different behavior. For example in my adjustbox package I have \clipbox and \clipbox* which both trim but the first takes the amounts to clip and the other one the viewport instead. I could have had \clipviewport as well of course.

-


-

Most commands that offer starred versions * are defined internally as two commands (although this is not necessary) based on their semantic meaning. For example, consider \section and \section* in article.cls - in fact, the formal definition of these macros are contained in latex.ltx. The choice between the starred an unstarred version is based on the condition:

\@ifstar
{\@ssect{#3}{#4}{#5}{#6}}%
{\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}


As such, either \@ssect or \@sect is executed.

From a personal perspective, this conditioning, is made programmatically easier by means of the xparse package \...DocumentCommand{s ..} macros and using \IfBooleanTF. Here the argument specifier s allows for convenient condition on whether the macro is supplied with/without *.

Perhaps, as an elaborate example of multiple macro definitions based on starred/unstarred versions of \section`, Vincent Zoonekynd's LaTeX page on sections epitomizes this.

-