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?
\parwhich 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{ }...) – cgnieder Feb 19 '13 at 09:36}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. – Lover of Structure Feb 19 '13 at 09:40\newcommandbut it can with\def: in\def\test a#1b{(#1)}the argument has the delimitersaandb. In\test a bthe space betweenaandbwill not be ignored, similar to\newcommand\test[1]{(#1)}\test{ }. – cgnieder Feb 19 '13 at 09:53\par? And, what about a non-empty line, i.e. two linebreak characters separated only by space characters? – Lover of Structure Feb 19 '13 at 10:14\par, see Joseph's answer and the comments below – cgnieder Feb 19 '13 at 10:18\noParis not long, so it doesn't allow\partokens in its argument; it's obvious that the code raises an error. It has already said many times: a blank line is converted into\par, so there's no distinction to be made. – egreg Feb 19 '13 at 11:30\threeArgsis long. This is interesting and imo worth pointing out, as it teaches (a non-expert) something about the order in which things are processed. Not knowing about TeX-internals, it's entirely plausible to assume that\threeArgsprocesses its arguments first. It's about greedy vs lazy evaluation order, though TeX's very special parsing algorithm doesn't quite fit into those categories and makes it tricky to figure out and understand such details. – Lover of Structure Feb 19 '13 at 11:36\noParand so it absorbs its argument, which happens to contain\par. Error. – egreg Feb 19 '13 at 11:39\noPardoes this error checking before\threeArgshas a chance to eat\par,B, and\par. Why would this be obvious to a non-expert? – Lover of Structure Feb 19 '13 at 12:26\par, which is part of macro execution of\noPar, happens before\threeArgsis executed. I don't see how this order is obvious to a casual user of LaTeX. – Lover of Structure Feb 20 '13 at 11:08\parin the argument of\noPar. It doesn't matter what possible macros in the same argument will do with it. I've never encountered such a problem from users. – egreg Feb 20 '13 at 11:12\noPar, like what is described here, the comment can be multiple paragraphs. The question is not whether this is a likely thing to occur; my point is that it's something about execution order and parsing that is not obvious (to a non-expert) and needs to be documented, such as here. – Lover of Structure Feb 20 '13 at 11:16