# Braces inside or outside?

Some tags work inside their braces: {\scriptsize lorem}.

Others, outside: \flushright{lorem} (and they stay in force for a while).

Edit: Others outside, lasting only within the braces: {\textbf lorem}.

Others, either inside or outside: \em{lorem}, ditto \tt.

The difference may depend on declarative form vs. action form, although that triggers bad memories of high school Latin. Why are text format commands used inside braces?

How can one remember which tag has which scope?

• Lots and lots of practice :) – Will Robertson May 3 '17 at 1:31
• \textbf is not 'either'. \tt ought not be used in LaTeX documents at all. \em ought generally to be avoided, I think. \flushright does not take an argument, but \begin{flushright} would probably be better. The only really correct examples there are \textbf{lorem} and {\scriptsize lorem} and even the latter isn't right, often. – cfr May 3 '17 at 1:34
• Whoops. {\textbf lorem} indeed boldfaces only the l. Edited. My closing, general, question remains. – Camille Goudeseune May 3 '17 at 1:56
• Partial answer: vim's syntax coloring. – Camille Goudeseune May 3 '17 at 2:04
• The way to know the scope is usually by looking at the documentation. If that fails, look at the definition. – Werner May 3 '17 at 3:19

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
% arara: pdflatex
\pdfminorversion=7
% ateb: https://tex.stackexchange.com/a/367883/
\documentclass{article}
\usepackage[a4paper,scale=.9]{geometry}
\usepackage{booktabs}
\usepackage{cfr-lm}
\begin{document}
\verb|\flushright| is really starting an environment and would be better marked as such in \LaTeX.

\verb|\begin{flushright}lorem\end{flushright}| \begin{flushright}lorem\end{flushright}

\verb|{\textbf lorem}| is not the same as \verb|\textbf{lorem}|.
The former will make only the \verb|l| bold, while the latter will make \verb|lorem| bold.
\verb|\bfseries| is a \emph{switch} and does not take an argument.
Everything following will be bold until the switch is changed or the local \TeX{} group ends.
Hence, limiting its scope requires a local group, \verb|{\bfseries lorem}|.

\begin{tabular}{ccc}
\verb|\textbf{lorem}| & \verb|{\textbf lorem}| & \verb|{\bfseries lorem}| \\
\textbf{lorem} & {\textbf lorem} & {\bfseries lorem} \\
\end{tabular}

\verb|\scriptsize| is another switch: everything following will be in this size, until another size is activated or the local \TeX{} group ends.
{\scriptsize Hence, brackets are needed to limit the scope, \verb|{\scriptsize lorem}|.
However, to be fully effective, the scope of size-changing macros must include a paragraph break at the end.}
In some contexts, this doesn't matter (and can even be exploited), but generally, ending a size mid-paragraph is not what you want.

\scriptsize \verb|\scriptsize| is another switch: everything following will be in this size, until another size is activated or the local \TeX{} group ends.
{\normalsize Hence, brackets are needed to limit the scope, \verb|{\scriptsize lorem}|.
However, to be fully effective, the scope of size-changing macros must include a paragraph break at the end.}
In some contexts, this doesn't matter (and can even be exploited), but generally, ending a size mid-paragraph is not what you want.

\normalsize
\verb|\tt| is obsolete and ought not be used in \LaTeXe{} at all.
Use \verb|\ttfamily| as a switch, \verb|{\ttfamily lorem}|, or \verb|\texttt| with an argument, \verb|\texttt{lorem}|.

If you stick to \LaTeX{} font selection commands, then all those which take arguments have names beginning with \verb|\text| (with the exception of \verb|\emph|, as explained below), while switches do not.
Switches instead have standard endings which indicate the kind of thing they switch: \verb|size| for size, \verb|family| for family, \verb|shape| for shape and \verb|series| for width and weight.

\newcommand*\cs[1]{\texttt{\textbackslash#1}}
\begin{center}
\begin{tabular}{*{7}{l}}
\toprule
Switch & Switch & Text & Switch & Text & Switch & Text \\
\midrule
\cs{tiny} & \cs{upshape} & \cs{textup} & \cs{rmfamily} & \cs{textrm} & \cs{mdseries} & \cs{textmd} \\
\cs{scriptsize} & \cs{itshape} & \cs{textit} & \cs{sffamily} & \cs{textsf} & \cs{bfseries} & \cs{textbf} \\
\cs{footnotesize} & \cs{slshape} & \cs{textsl} & \cs{ttfamily} & \cs{texttt} \\
\cs{small} & \cs{scshape} & \cs{textsc}  \\
\cs{large} \\
\cs{Large} \\
\cs{LARGE} \\
\cs{Huge} \\
\cs{normalsize} & \cs{normalfont} & \cs{textnormal} & \cs{normalfont} & \cs{textnormal} & \cs{normalfont} & \cs{textnormal} \\
\bottomrule
\end{tabular}
\end{center}

This system is the New Font Selection Scheme, introduced with \LaTeXe more than twenty years ago (so no longer so new').

\verb|\emph{lorem}| is not part of this scheme because, strictly speaking, it does not specify a particular font change but is, rather, \emph{semantic} mark-up.
\verb|\emph| and the \TeX{} switch \verb|\em| specify that text should be \emph{emphasised} using whatever format is currently active for marking such text.
By default, this means that text is italicised, if currently non-italic, or made upright, if currently italic.
However, it would be perfectly legitimate to design a class in which important text was made bold rather than rendered italic/non-italic.

With the default settings, the difference between the semantic \verb|\emph| and the non-semantic \verb|\textit| can be observed by seeing what happens when such changes are nested.

\begin{verbatim}
This is not especially important.
\emph{This is very important, especially \emph{this phrase}, which deserves particular attention.}

This is not especially important.
\textit{This is very important, especially \textit{this phrase}, which deserves particular attention.}

This is not especially important.
\emph{This is very important, especially \textit{this phrase}, which deserves particular attention.}

This is not especially important.
\textit{This is very important, especially \emph{this phrase}, which deserves particular attention.}
\end{verbatim}
This is not especially important.
\emph{This is very important, especially \emph{this phrase}, which deserves particular attention.}

This is not especially important.
\textit{This is very important, especially \textit{this phrase}, which deserves particular attention.}

This is not especially important.
\emph{This is very important, especially \textit{this phrase}, which deserves particular attention.}

This is not especially important.
\textit{This is very important, especially \emph{this phrase}, which deserves particular attention.}
\end{document}


• So the terms to learn are: environment, switch, argument, local group, paragraph break. Still, in that last paragraph, what does it mean to "start \text"? Is that related to the table's two headings, switch and text? – Camille Goudeseune May 3 '17 at 2:41
• @CamilleGoudeseune I just mean that all their names start with \text: \textit, \textup, \textsc, \textrm etc. They are also all declared using \DeclareTextFontCommand, but you don't need to know that to use them. (As opposed to e.g. \DeclareRobustCommand or the like.) You asked how to keep track of which were which. The names give it away if you use the LaTeX syntax consistently. – cfr May 3 '17 at 3:44
• Have you read a basic introduction to LaTeX? If not, you should as it will save you a lot of headaches. Doing so will certainly introduce you to at least some of those terms. (Maybe not 'switch', but certainly 'environment', 'argument' and so on.) – cfr May 3 '17 at 3:46
• +1. Nice use of the cfr-lm package, by the way! :-) – Mico May 3 '17 at 4:54
• Two (very minor) suggestions, just for completeness: you may want to list \em and \emph in the "shape" column pair, and you may want to mention that the text-equivalent of the \normalfont switch is \textnormal. – Mico May 3 '17 at 5:14

In addition to cfr's answer I think it's important to stress that declarations do not have braces, they are not "inside their braces", they just change the state (typically the font) at the current point

{\scriptsize lorem}


the outer braces are not part of the command syntax, you could just as well go

\scriptsize lorem \normalsize


or

\begin{center}\scriptsize lorem\end{center}


\flushright{lorem}


The braces here are unconnected with the command and just form a group that would scope any declaration such as \scriptsize inside "lorem". \flushright is only intended to be used as an environment

\begin{flushright} lorem\end{flushright}


The declaration form is \raggedright.

\raggedright lipsum


{\textbf lorem}


the braces here are again unconnected to the \textbf command and form a group, \textbf is a macro with one argument so here, as its argument isn't braced, the argument is the next token, which is l so it is the same as

{\textbf{l}orem}


with the l being the argument to \textbf and the outer braces playing no role in this command.

\em and \tt are declarations like \raggedright (\tt` is not defined by default in latex and is just defined in some classes with compatibility with early versions of LaTeX)