Брекеты внутри или снаружи?

Брекеты внутри или снаружи?

Некоторые теги работают внутри своих фигурных скобок: {\scriptsize lorem}.

Другие, снаружи: \flushright{lorem}(и они остаются в силе некоторое время).

Редактировать: Другие снаружи, длящиеся только внутри скобок: {\textbf lorem}.

Другие, внутри или снаружи: \em{lorem}, то же самое \tt.

Разница может зависеть от повествовательной формы и формы действия, хотя это вызывает плохие воспоминания о школьной латыни. Почему команды форматирования текста используются внутри фигурных скобок?

Как запомнить, какой тег имеет какую область действия?

решение1

% !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}

шрифты и прочее

решение2

В дополнение к ответу cfr я думаю, важно подчеркнуть, что объявления не имеют фигурных скобок, они не находятся «внутри своих фигурных скобок», они просто изменяют состояние (обычно шрифт) в текущей точке.

Итак, беря ваши примеры,

{\scriptsize lorem}

внешние скобки не являются частью синтаксиса команды, вы могли бы просто написать

\scriptsize lorem \normalsize

или

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

\flushright{lorem}

Фигурные скобки здесь не связаны с командой и просто образуют группу, которая будет охватывать любое объявление, например, \scriptsizeвнутри «lorem». \flushrightпредназначено только для использования в качестве среды

\begin{flushright} lorem\end{flushright}

Форма декларации: \raggedright.

\raggedright lipsum

{\textbf lorem}

фигурные скобки здесь снова не связаны с \textbfкомандой и образуют группу, \textbfэто макрос с одним аргументом, поэтому здесь, поскольку его аргумент не заключен в фигурные скобки, аргументом является следующий токен, то есть lон такой же, как

{\textbf{l}orem}

причем lявляется аргументом, \textbfа внешние фигурные скобки не играют никакой роли в этой команде.


\emи \ttявляются объявлениями типа \raggedright( \ttне определено по умолчанию в latex, а определено только в некоторых классах с совместимостью с ранними версиями LaTeX)

Связанный контент