Most commands in Latex are written with the arguments inside braces following the command: \command{arguments}. But text formatting options, like \em, or \scriptsize are usually written inside the braces, like {\em some italicised text}. Why is this? What makes these commands different? I'm particularly asking because it seems to make standardisation - of which LaTeX really appears badly in need - more difficult.
|
|
||||
|
There is a standard. It's a matter of opinion whether it's sensible or not, but it's been there since the release of LaTeX2e.
Let me review the three points. Font aspect changing commandsThe declarative form for changing the font's aspect is formed from a prefix denoting briefly the purpose and by a suffix denoting the attribute that's changed:
The "action form" is a command that takes an argument; all kernel defined commands of this type have a prefix
The fundamental difference is that a declaration's scope is up to the end of the group in which it's issued (or a countermanding declaration). Two important commands are Abstract instructionBy "abstract instruction" I mean The form Size changing commandsThe size changing commands have only the declarative form, as very rarely one needs to set a couple of words in a smaller or larger size. Examples
Their scope ends with the group where they have been issued (usually an environment). If a paragraph must be typeset in a different size it's important to remember marking explicitly the end with |
|||
|
|
|
As @egreg has explained, partly it is the way it is because that's just how it is (and was in latex2.09 and plain tex). Apart from just being a syntax choice, there are also efficiency considerations. As a switch you can go
On the other hand if the syntax were If you do not like the assignment/switch model and prefer to use a different syntax then LaTeX does offer an alternative that looks more "LaTeX-like" and does not have the problems with parsing massive macro arguments:
|
||||
|
|
In addition to the very good answers already given: The action form (e.g. |
|||||
|
\emand\scriptsizehave no argument; they function as ‘switches’. The surrounding braces form a group so that changes are only local. – mhp Jul 24 '12 at 6:56