A rather puny question:
What is "good practice" to end a backslashed command?
At the moment, I simply insert a {} if the following char
(can you tell me which ones qualify?) does not automatically end the
backslashed command, e.g. $\rho+\Delta{}A$. In this case, the
closing bracket could go after the A but I quickly found
that when expressions get complicated (e.g. A has an index 1
too) things go unmatched very fast :-)
- 757,742
- 393
2 Answers
Never use braces just to terminate a command in math mode, they form an empty node, rather like \mbox{} and so affect the space. In your example just use
$\rho+\Delta A$
An example with a clear spacing difference would be
\documentclass{article}
\begin{document}
$\rho \leq{} + 2 A$
$\rho \leq + 2 A$
\end{document}
- 757,742
-
This same example also shows we can't use
{}around the macro either, as in{\leq}(stating just in case anyone was considering that option for delimiting macros). – ShreevatsaR Nov 08 '17 at 23:30
In general all letters qualify to follow a backslash and make up a command name. These letters are a-z and A-Z by default. Some commands like \makeatletter or \ExplSyntaxOn add other characters as letters (e.g. @ or _ and :). If one of those characters follows the command name you have to put some boundary there. The easiest way to do this is to follow your command by a space (as mentioned by @DavidCarlisle).
Examples (if you want more details consider reading this post):
\DeltaA % this would be one command, use
\Delta A % instead as this has the "boundary", but
\Delta1 % would not be a problem as 1 is no "letter" by default
\Delta@ % see above, but
\makeatletter\Delta@\makeatother % would call for a macro \Delta@
If math mode is concerned you are done using the space. In text mode you may want to consider that the space after a command is absorbed. So in text mode you may want to use \textDelta{} (or if you want to ensure the space \textDelta\).
- 33,589

{}this way (it will ruin the spacing in general) just use a space. – David Carlisle Nov 08 '17 at 14:01