TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to define a *'d version of a command, something like


If I try to do this, LaTeX complains that I'm trying to redefine \foo, so I guess I need to do something special to handle *s. But what?

share|improve this question
Of the different replies given: what is currently the recommended answer to this question? – ClintEastwood Feb 23 at 7:49
up vote 53 down vote accepted

See this entry in the UK TeX FAQ.

The "elegant" way is to use the suffix package (which requires eTeX):






share|improve this answer
Does this work with commands with optional arguments too? If so how? – YAK Mar 11 '14 at 10:59
@YAK I don't know. Note that the combination starred/optional is very rare. – lockstep Mar 11 '14 at 11:37
Ups, I meant normal arguments, not optionals. And it works (\WithSuffix\newcommand\foo*[1]{Foo #1}) but warns "No 2nd argument following newcommand"... – YAK Mar 11 '14 at 12:13

LaTeX3 solution:

    {blahblah}% If a star is seen
    {blah}%     If no star is seen
share|improve this answer

If you look at source2e you might see a lot of lines that look like


This makes \foo a one-argument command that has regular and starred versions. The starred version is the expansion of \@foo while the nonstarred version is that of \@@foo. Using the @ sign in the auxiliary macros is a TeX convention which some authors embrace and some avoid.

There are higher-level ways to do it (as lockstep points out) but once you learn this pattern it's not too hard to use. Just make sure it's between \makeatletter...\makeatother or in a .sty file.

Edits removed some inaccuracies and editorializing.

share|improve this answer
What's the controversy with @? FWIW, it's also used in Plain and ConTeXt (although far less in the latter, which do is more common, leading to some funny command names such as \dodohideblock). – Will Robertson Oct 22 '10 at 3:22
Let me be clear that I follow the @-convention and am not advocating against it. But I can also see the point of view that the name \@foo (or \f@o or \f@@) doesn't help the human reader understand the relationship. \@foowithstar and \@foowithoutstar might be better. Sorry if I blew that internal ambivalence into a controversy. :-) Also, I wanted to point out that @'s are not required in auxiliary macros. – Matthew Leingang Oct 22 '10 at 11:12
Yes, using '@' in place of vowels is a pain in the neck, whereas using it as a divider is fine. – Joseph Wright Oct 23 '10 at 17:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.