牙套在里面还是外面?

牙套在里面还是外面?

一些标签在括号内起作用:{\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 兼容的类中定义)

相关内容