How are spaces and empty lines processed by long commands (i.e., those that do not accept paragraph breaks inside)? Are there different space tokens aside from " " and an empty line? It appears that an empty line counts as exactly one empty argument:
\documentclass{article}
\newcommand{\oneArg}[1]{}
\newcommand{\twoArgs}[2]{}
\newcommand{\threeArgs}[3]{}
\begin{document}
\indent
A \oneArg
B
% output:
% A B
A \twoArgs
B
C
% output:
% A
% C
A \threeArgs
B
C
% output:
% A C
\end{document}
And is there anything special one needs to know about math mode in this regard?
One pointer: Some relevant information is in this question, especially this discussion thread about \somecommand *
being legal LaTeX.
Addendum: An interesting detail about short macros (those defined for example with \newcommand*
): If I add \newcommand*{\noPar}[1]{#1}
to my source code and try to compile an additional codechunk
\noPar{
A \threeArgs
B
C
}
the compiler will throw an error. As this is semantically not a paragraph break, the long-short distinction between commands should probably be described in terms of empty lines, not paragraph breaks. Or not?
\par
which is read in as an argument to your commands. Spaces alone are ignored when scanning for arguments except when they're used as delimiters for the arguments. (... or between delimiters of a delimited argument, or in braces{ }
...)}
and{
of successive arguments' delimiters", correct? And the "in braces" addendum is a bit confusing (surely not all spaces occurring somewhere inside{ }
are ignored, perhaps only those at the beginning or end, but I though those are not ignored.\newcommand
but it can with\def
: in\def\test a#1b{(#1)}
the argument has the delimitersa
andb
. In\test a b
the space betweena
andb
will not be ignored, similar to\newcommand\test[1]{(#1)}\test{ }
.\noPar
and so it absorbs its argument, which happens to contain\par
. Error.