Leaving out the curly braces

I'm trying to understand how LaTeX works, but I don't understand the following:

\dot X


and

\dot{\mathcal X}


work, but

\dot \mathcal X


does not work. Can anybody explain why?

• TeX cant set a dot on a macro , i.e. \mathcal. \dot must see a letter/glyph first to operate on, so \mathcal{X} has to be expanded first – user31729 Jan 7 '16 at 13:07
• @ChristianHupfer but that hides the point that it's all about how macros find their arguments for example _ rather than \dot things are different $A_ \mathcal X B$ works without error and works as $A_ {\mathcal{X}} B$ – David Carlisle Jan 7 '16 at 13:13
• @DavidCarlisle: I formulated it a bit clumsy, perhaps. – user31729 Jan 7 '16 at 13:15
• $\dot\mathcal X$ seems to work with standard classes, but not with amsmath, which redefines things. – Alex Jan 7 '16 at 13:16
• This is a good reason why you should always type \dot{X}, \mathcal{X} and so \dot{\mathcal{X}}. – egreg Jan 7 '16 at 14:40

Macros defined with normal non delimited arguments take a single token or brace group as the argument so

\dot X


is

\dot{X}


and

\dot{\mathcal X}


is

\dot{\mathcal{X}}


but

\dot \mathcal X


is

\dot{\mathcal} X


which is an error as \mathcal is expecting an argument but does not see one.

• Thank you, I think I understand now, but since you say "defined with normal non delimited arguments", is there also a way to define dot to take both mathcal and X? – Carucel Jan 7 '16 at 13:16
• @pascal - Are you asking how to redefine \dot to make it take two arguments? – Mico Jan 7 '16 at 13:18
• @Mico No sorry I am not very clear perhaps, I meant is it possible to redefine \dot to interpret \dot \mathcal X as \dot{\mathcal{X}}. – Carucel Jan 7 '16 at 13:19
• @pascal possibly but it would be a bad idea, the syntax rules described above apply to every command defined in tex. The only things that do not follow it exactly are a few tex primitives such as _ or \hbox which have their own argument scanning rules. So unless you plan to redefine the entire TeX language it is best just to leave as is any attempt to change the scanning would be very fragile and bound to be incompatible with several packages – David Carlisle Jan 7 '16 at 13:25
• @pascal my reference to normal non-delimited arguments I just meant to exclude so called delimited arguments where arguments are delimited by other tokens such as [..] or (..,..) where the rules are similar but different and not really relevant to your question so I excluded them from the discussion. – David Carlisle Jan 7 '16 at 13:27