Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
6  
Commands such as \em and \scriptsize have 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
    
A recent question How to write math symbols contains relevant information and pointers about this –  JLDiaz Jul 24 '12 at 7:26
3  
Related: tex.stackexchange.com/questions/57062/… –  lockstep Jul 24 '12 at 8:14
add comment

3 Answers 3

up vote 31 down vote accepted

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.

  1. Font aspect changing commands have two forms: action and declaration

  2. The same holds for abstract instruction such as "emphasize"

  3. Size changing commands have only the declarative form.

Let me review the three points.

Font aspect changing commands

The 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:

\sffamily
\itshape
\bfseries

The "action form" is a command that takes an argument; all kernel defined commands of this type have a prefix text and a suffix corresponding to the similar declaration:

\textsf{words}
\textit{words}
\textbf{words}

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 \textnormal (action) and \normalfont (declaration) that instruct LaTeX to use the font which was current at document start.

Abstract instruction

By "abstract instruction" I mean \emph and \em, which usually act by italicizing, but one should not rely on this, as the effect can be redefined by the document class.

The form \emph is the action: \emph{words}, while \em is a declaration. The latter can be useful in defining environments.

Size changing commands

The 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

\footnotesize
\small
\normalsize
\large

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 \par or a blank line. Commonly it's the environment where they are issued that takes care of it.

share|improve this answer
add comment

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 \large at the beginning of a document and the whole document goes large (it is an assignment as if the syntax were

\setlength\currentsize{1in}

On the other hand if the syntax were \large{.....} then the whole document would have to be parsed as an argument this would have implications on TeX's memory requirements (and would probably not have been possible for that reason alone in the early days) as well as meaning that \verb and other catcode changing features could not be used in the scope of such a command.

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:

\begin{large}
....
\end{large}
share|improve this answer
    
Thanks. This is a great addendum to egreg's answer. If I could accept both, I would. –  naught101 Jul 25 '12 at 1:30
add comment

In addition to the very good answers already given: The action form (e.g. \emph{...}) may do more than the declarative form ({\em ...}). In the case of \emph it's automatic italic correction, for example.

share|improve this answer
1  
Well, \def\em{\it\aftergroup\/} {\em Testing} 1,2,3\par {\it Testing\/} 1,2,3\par {\it Testing} 1,2,3 \bye at least does the same thing. –  morbusg Jul 24 '12 at 17:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.