Skip to content

Commit 99abb9b

Browse files
committed
[chapter03][translated] embellished.
1 parent 3dd707c commit 99abb9b

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

chapter03.tex

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ \chapter{字符}\label{char}
1818
%Internally, \TeX\ represents characters by their (integer)
1919
%character code. This chapter treats those codes, and the
2020
%commands that have access to them.
21-
\TeX\ 在其内部使用字符编码来表示字符。这一章讨论字符编码及相关命令
21+
\TeX 在其内部使用字符编码来表示字符;本章讨论字符编码及相关命令
2222

2323
\label{cschap:char}\label{cschap:chardef}\label{cschap:accent}\label{cschap:uccode}\label{cschap:lccode}
2424
\label{cschap:uppercase}\label{cschap:lowercase}\label{cschap:string}\label{cschap:escapechar}
2525
\begin{inventory}
2626
%\item [\cs{char}]
2727
% Explicit denotation of a character to be typeset.
28-
\item [\cs{char}] 显式指定所要排印的字符
28+
\item [\cs{char}] 显式指定所要排版的字符
2929
%\item [\cs{chardef}]
3030
% Define a control sequence to be a synonym for
3131
% a~character code.
@@ -45,19 +45,19 @@ \chapter{字符}\label{char}
4545
%\item [\cs{uccode}]
4646
% Query or set
4747
% the character code that is the uppercase variant of a given code.
48-
\item [\cs{uccode}] 对于给定的字符编码,查询或设置其对应的大写变体编码
48+
\item [\cs{uccode}] 对于给定的字符编码,查询或设置其对应的大写变体的编码
4949
%\item [\cs{lccode}]
5050
% Query or set
5151
% the character code that is the lowercase variant of a given code.
52-
\item [\cs{lccode}] 对于给定的字符编码,查询或设置其对应的小写变体编码
52+
\item [\cs{lccode}] 对于给定的字符编码,查询或设置其对应的小写变体的编码
5353
%\item [\cs{uppercase}]
5454
% Convert the \gr{general text} argument to its uppercase form.
5555
\item [\cs{uppercase}]
56-
\gr{general text} 转换为大写形式。
56+
将普通文本(\gr{general text}转换为大写形式。
5757
%\item [\cs{lowercase}]
5858
% Convert the \gr{general text} argument to its lowercase form.
5959
\item [\cs{lowercase}]
60-
\gr{general text} 转换为小写形式。
60+
将普通文本(\gr{general text}转换为小写形式。
6161
%\item [\cs{string}]
6262
% Convert a token to a string of one or more characters.
6363
\item [\cs{string}]
@@ -81,7 +81,7 @@ \section{字符编码}
8181
%Conceptually it is easiest to think that \TeX\ works with
8282
%characters internally, but in fact
8383
%\TeX\ works with integers: the \indextermsub{character}{codes}.
84-
在概念上说,认为 \TeX 内部处理着字符最简单,但是实际上 \TeX 内部处理的是整数\cindextermsub{字符}{编码}。
84+
在概念上说,认为 \TeX 内部直接对字符进行处理是最简单的;但是实际上 \TeX 内部处理的是整数,即\cindextermsub{字符}{编码}。
8585

8686
%The way characters are encoded in a computer may differ
8787
%from system to system.
@@ -104,7 +104,7 @@ \section{字符编码}
104104
%a single-character control sequence.
105105
%Thus both \verb.\count`a. and \verb.\count`\a. are synonyms
106106
%for \verb.\count97.. See also Chapter~\ref{number}.
107-
利用反引号\n{`{}},或称左引号)可将字符(准确说是字符记号)转换为其字符编码。在所有 \TeX 希望得到 \gram{number} 的地方,都可以通过这种方式将一个字符记号的编码传给 \TeX:反引号加字符或是反引号加单字符控制序列。例如 \verb.\count`a. 和 \verb.\count`\a. 都表示 \verb.\count97.。详见第~\ref{number}~章。
107+
反引号\n{`{}},或称左引号)可将字符(准确说是字符记号)转换为其字符编码。 \TeX 中,所有需要 \gram{number} 的地方,都可以通过这种方式将一个字符记号的编码传给 \TeX:反引号加字符或是反引号加单字符控制序列。例如 \verb.\count`a. 和 \verb.\count`\a. 都表示 \verb.\count97.。详见第~\ref{number}~章。
108108

109109
%The possibility of a single-character control
110110
%sequence is necessary in certain cases such as
@@ -132,7 +132,7 @@ \section{字符编码}
132132
%roman fonts there are no `less than' and `greater than'
133133
%\message{Check <>! Dammit!}%
134134
%signs, so the input `\verb.<>.' will give `<>' in the output.
135-
当字符记号被转换为字符编码后,字符编码就与其外部形状没有关联了。当然,对于大多数字符来说,在视觉上,其排版输出与输入是一致的。例如输入 \n{a} 会排版输出字符「a」。不过,即使在常见的符号中,也有例外情况。在计算机现代罗马字体中,就没有小于号和大于号。
135+
当字符记号被转换为字符编码后,字符编码就与字符的形状没有关联了。当然,对于大多数字符来说,在视觉上,其排版输出与输入是一致的。例如输入 \n{a} 会排版输出字符「a」。不过,即使在常见的符号中,也有例外情况。在计算机现代罗马字体中,就没有小于号和大于号。
136136
\message{Check <>! Dammit!}%
137137
输入 `\verb.<>.' 得到的输出是 `{\font\cmr=cmr10 \cmr<>}'。
138138
%{\MathRMx<>}
@@ -147,25 +147,25 @@ \section{字符编码}
147147
%%\point Control sequences for characters
148148
%\section{Control sequences for characters}
149149
%\point Control sequences for characters
150-
\section{表示字符的控制序列}
150+
\section{字符相关的控制序列}
151151

152152
%There are a number of ways in which a control sequence can denote
153153
%a character. The \cs{char} command specifies a character to be
154154
%typeset; the \cs{let} command introduces
155155
%a synonym for a character token, that is,
156156
%the combination of character code and category code.
157-
有许多种方式可以用控制序列来表示字符。例如说,\cs{char} 命令可以指定一个用于打印的字符;\cs{let} 命令可引入一个与置顶字符记号同义的控制序列——包括其字符编码和其分类码。
157+
有许多种方式可以用控制序列来表示字符。例如说,\cs{char} 命令可以指定一个用于打印的字符;\cs{let} 命令可引入一个与指定字符记号同义的控制序列——包括其字符编码和其分类码。
158158

159159
%%\point Denoting characters to be typeset: \cs\char
160160
%\subsection{Denoting characters to be typeset: \protect\cs{char}}
161161
%\point Denoting characters to be typeset: \cs\char
162-
\subsection{表示要排印的字符\protect\cs{char}}
162+
\subsection{表示要排版的字符\protect\cs{char}}
163163

164164
%Characters can be denoted numerically by, for example,
165165
%\verb.\char98.\cstoidx char\par.
166166
%This command tells \TeX\ to add character number~98 of the
167167
%current font to the horizontal list currently under construction.
168-
字符可以通过数值来表示,比如 \cstoidx char\par\verb-\char98-。该命令使得 \TeX\ 将当前字体中编码为 98 的字符添加到正在构建的水平列表中。
168+
字符可以通过数值来表示,比如 \cstoidx char\par\verb-\char98-。该命令会将当前字体中编码为 98 的字符添加到正在构建的水平列表中。
169169

170170
%Instead of decimal notation, it is often more convenient to
171171
%use octal or hexadecimal notation. For octal the single quote is used:
@@ -191,12 +191,12 @@ \subsection{表示要排印的字符:\protect\cs{char}}
191191
%comes in the final stages of processing.
192192
%In effect it says `typeset character number
193193
%so-and-so'.
194-
表面上看,\cs{char} 命令与 \verb.^^. 替换机制(第~\ref{mouth}~章)类似两种机制都是通过间接的方式来访问字符。但是,\verb.^^. 替换机制发生的非常早——在 \TeX 的输入处理器为字符分配分类码之前;而 \cs{char} 命令则在可视化处理器中起作用。从效果上看,\cs{char} 是告诉 \TeX:「排版字体中第 $n$ 个字符。」
194+
表面上看,\cs{char} 命令与 \verb.^^. 替换机制(第~\ref{mouth}~章)类似两种机制都是通过间接的方式来访问字符。但是,\verb.^^. 替换机制发生的非常早——在 \TeX 的输入处理器为字符分配分类码之前;而 \cs{char} 命令则在可视化处理器中起作用。从效果上看,\cs{char} 是告诉 \TeX:「排版字体中第 $n$ 个字符。」
195195

196196
%There is a construction to let a control sequence stand
197197
%for some character code: the \csterm chardef\par\ command.
198198
%The syntax of this is \label{chardef}
199-
\csterm chardef\par 命令可定义一个控制序列定义作为一个字符编码的代替品\label{chardef}它的用法是
199+
\csterm chardef\par 命令可定义一个控制序列定义作为一个\emph{字符编码}的代替品\label{chardef}它的用法是
200200
\begin{disp}
201201
\cs{chardef}\gram{control sequence}\gr{equals}\gram{number},
202202
\end{disp}
@@ -228,26 +228,25 @@ \subsection{表示要排印的字符:\protect\cs{char}}
228228
%\cs{newbox} (see Chapters~\ref{number} and~\ref{alloc}).
229229
%Tokens defined with \cs{mathchardef} can also be used this
230230
%way.
231-
\cs{chardef} 命令定义的控制序列可作为是 \gr{number} 使用。在诸如 \cs{newbox} 的分配类命令中,就用到了这一特性。(见第 \ref{number} 章和第 \ref{alloc} 章)用 \cs{mathchardef} 命令定义的记号同样可以这样使用。
231+
\cs{chardef} 命令定义的控制序列可作为 \gr{number} 使用。在诸如 \cs{newbox} 的分配类命令中,就用到了这一特性。(见第 \ref{number} 章和第 \ref{alloc} 章)用 \cs{mathchardef} 命令定义的记号同样可以这样使用。
232232

233233
%\subsection{Implicit character tokens: \protect\cs{let}}
234234
\subsection{隐式字符记号:\protect\cs{let}}
235235

236236
%Another construction defining a control sequence
237237
%to stand for (among other things)
238238
%a character is~\cs{let}\cstoidx let\par:
239-
另一种定义表示字符的控制序列的方式是使用 \cstoidx let\par 命令,并且将字符记号置于可选等号的右边:
239+
另一种定义表示字符的控制序列的方式是使用 \cs{let} \cstoidx let\par 命令,并且将字符记号置于可选等号的右边:
240240
\begin{disp}\cs{let}\gr{control sequence}\gr{equals}\gr{token}\end{disp}
241241
%with a character token on the right hand side of the (optional)
242242
%equals sign. The result is called an \indextermbus{implicit}{character} token.
243243
%(See page~\pageref{let} for a further discussion of~\cs{let}.)
244-
如此,得到的控制序列称为\cindextermbus{隐式}{字符}记号。
245-
(见第~\pageref{let}~页对~\cs{let}~的进一步讨论。)
244+
如此,得到的控制序列称为\cindextermbus{隐式}{字符}记号。(见第~\pageref{let}~页对~\cs{let}~的进一步讨论。)
246245

247246
%In the
248247
%plain format there are for instance synonyms for
249248
%the open and close brace:
250-
在 plain \TeX 中有对左右花括号做的同义控制序列
249+
在 plain \TeX 中有对左右花括号定义同义控制序列
251250
\begin{verbatim}
252251
\let\bgroup={ \let\egroup=}
253252
\end{verbatim}
@@ -260,10 +259,10 @@ \subsection{隐式字符记号:\protect\cs{let}}
260259
%in the sense that \cs{let}
261260
%makes the control sequence stand for the combination
262261
%of a character code and category code.
263-
通过 \cs{let} 和 \cs{chardef} 将字符赋值给控制序列是有区别的。被 \cs{let} 定义的控制序列表示字符编码与分类码的组合
262+
通过 \cs{let} 和 \cs{chardef} 将字符赋值给控制序列是有区别的。被 \cs{let} 定义的控制序列是字符编码与分类码这一组合的替代品
264263

265264
%As an example
266-
例如在下例中,由于 \cs{b} 关闭了 \cs{m} 定义所在的分组,因此 \TeX 会提示错误:「未定义的控制序列」。
265+
例如在下例中,\cs{b} 关闭了 \cs{m} 定义所在的分组,因此 \TeX 会提示错误:「未定义的控制序列」。
267266
\begin{verbatim}
268267
\catcode`|=2 % make the bar an end of group
269268
\let\b=| % make \b a bar character
@@ -272,7 +271,7 @@ \subsection{隐式字符记号:\protect\cs{let}}
272271
%gives an `undefined control sequence \cs{m}'
273272
%because the \cs{b} closed the group inside which \cs{m}
274273
%was defined. On the other hand,
275-
另一方面,由于 \cs{b} 的定义在分类码修改之前,因此它无法承担分组结束符的作用,只能表示一条竖线(或是其他任何在当前字体中编号为 124 的字符)。因此,这里构造的是一个不闭合的分组。
274+
又例如在下例中,\cs{b} 的定义在分类码修改之前,因此它无法承担分组结束符的作用,只能表示一条竖线(或是其他任何在当前字体中编号为 124 的字符)。因此,这里构造的是一个不闭合的分组。
276275
\begin{verbatim}
277276
\let\b=| % make \b a bar character
278277
\catcode`|=2 % make the bar character end of group
@@ -325,15 +324,15 @@ \subsection{隐式字符记号:\protect\cs{let}}
325324
{\lccode`,=94 \lccode`.=95 \catcode`,=7 \catcode`.=8
326325
\lowercase{\global\let\sp=, \global\let\sb=.}}
327326
\end{verbatim}
328-
至于它为什么能起作用,可详见后文关于 \cs{lowercode} 的介绍。
327+
至于它为什么能起作用,可详见后文关于 \cs{lowercase} 的介绍。
329328
%will do the job; see below for an explanation of lowercase codes.
330329
%The \verb>^^> method as it was in \TeX\ version~2
331330
%(see page~\pageref{hathat}) cannot be used here,
332331
%as it would require typing two characters that can ordinarily
333332
%not be input.
334333
%With the extension in \TeX\ version~3 it would also be possible
335334
%to write
336-
由于我们无法键入 \verb.^.,因此 \TeX2 中的 \verb.^^. 表示法无法在此解决问题。(见第~\pageref{hathat}~页)考虑到上标和小标以十六进制表示的字符编码分别是 \verb.5e. 和 \verb.5f.,利用 \TeX3 中扩展的表示法可以依照如下方式解决问题:
335+
由于我们无法键入 \verb.^.,因此 \TeX2 中的 \verb.^^. 表示法无法在此解决问题。(见第~\pageref{hathat}~页)考虑到上标和下标的字符编码以十六进制表示分别是 \verb.5e. 和 \verb.5f.,利用 \TeX3 中扩展的表示法可以依照如下方式解决问题:
337336
\begin{verbatim}
338337
{\catcode`\,=7
339338
\global\let\sp=,,5e \global\let\sb=,,5f}
@@ -380,7 +379,7 @@ \section{重音}
380379
%such double accents do occur.
381380
%Positioning accents on top of each other is possible,
382381
%however, in math mode.
383-
\cs{accent} 命令后必须紧跟 \gr{character} 避免了将重音符号置于连字之上或是置于另一个重音符号之上。在诸如印度语及越南语的少数语言中,确实存在双重音符号的情况因此这种规定有时可能会令人不爽。不过,将重音符号置于另一个之上在数学模式中是可以实现的
382+
\cs{accent} 命令后必须紧跟 \gr{character}。这一规定避免了将重音符号置于连字之上或是置于另一个重音符号之上。在诸如印度语及越南语的少数语言中,确实存在双重音符号的情况因此这种规定有时可能会令人不爽。不过,将重音符号置于另一个之上可以在数学模式中实现
384383

385384
%The width of a character with an accent is the same as that of
386385
%the unaccented character. \TeX\ assumes that the
@@ -406,7 +405,7 @@ \section{重音}
406405
%are inserted automatically, these kerns are classified
407406
%as {\italic explicit\/} kerns. Therefore they inhibit hyphenation
408407
%in the parts of the word before and after the kern.
409-
重音符号的水平位置由 \cs{fontdimen1}(\cindextermbus{每点}{倾斜},\emph{slant per point})控制。为此,\TeX 引入铅空以校正重音符号的水平位置\liamfnote{铅空是活字印刷排版时代,排版工人用于调整字符水平位置而使用的空白铅块。}注意,尽管这些铅空是自动插入的,但这些铅空隶属\emph{显式}铅空。因此,它们会抑制铅空前后的连字符。
408+
重音符号的水平位置由 \cs{fontdimen1}(\cindextermbus{每点}{倾斜},\emph{slant per point})控制。为此,\TeX 会引入铅空以校正重音符号的水平位置\liamfnote{铅空是活字印刷排版时代,排版工人用于调整字符水平位置而使用的空白铅块。}注意,尽管这些铅空是自动插入的,但这些铅空隶属\emph{显式}铅空。因此,它们会抑制铅空前后的连字符。
410409

411410
%As an example of kerning for accents,
412411
%here follows the dump of a horizontal list.
@@ -433,13 +432,13 @@ \section{重音}
433432
\section{字符真值测试}
434433

435434
%Equality of character codes is tested by \cs{if}:
436-
使用 \cs{if} 可检测两个字符编码是否相等
435+
使用 \cs{if} 可检测两个字符记号的字符编码是否相等
437436
\begin{disp}\cs{if}\gr{token$_1$}\gr{token$_2$}\end{disp}
438437
%Tokens following this conditional are expanded until two
439438
%unexpandable tokens are left. The condition is then true
440439
%if those tokens are character tokens with the same character
441440
%code, regardless of category code.
442-
\TeX 遇到 \cs{if} 后,会对其后的记号持续展开,直至遇见两个不可展开的记号。而后,若这两个记号的字符编码相等,而不管分类码,则真值测试为真。
441+
\TeX 遇到 \cs{if} 后,会对其后的记号持续展开,直至遇见两个不可展开的记号。而后,不管分类码如何,若这两个记号的字符编码相等,则真值测试为真。
443442

444443
%An unexpandable control
445444
%sequence is considered to have character code 256 and
@@ -582,10 +581,10 @@ \subsection{关键字的大写与小写形式}
582581
%characters \rdash to their character code. This has some implications
583582
%for implementations of \TeX\ for non-roman alphabets;
584583
%see page 370 of \TeXbook, \cite{Knuth:TeXbook}.
585-
\TeX 关键字可以是大写形式也可以是小写形式。比如 \n{pt} 还可以写作 \n{pT}、\n{Pt} 以及 \n{PT}。此处,\TeX 不使用 \cs{uccode} 及 \cs{lccode} 表来确定小写形式;而是直接在大写字母的字符编码上加 32 来得到其小写形式——\ascii 编码中,同一字母大小写形式之差为 32。这种做法与 \TeX 在处理非罗马字符时的具体实现方式有所牵扯;详见 \TeXbook\ \cite{Knuth:TeXbook} 第 370 页。
584+
\TeX 关键字可以是大写形式也可以是小写形式。比如 \n{pt} 还可以写作 \n{pT}、\n{Pt} 以及 \n{PT}。此处,\TeX 不使用 \cs{uccode} 及 \cs{lccode} 表来确定小写形式;而是直接在大写字母的字符编码上加 32 来得到其小写形式——\ascii 编码中,同一字母大小写形式之差为 32。这种做法与 \TeX 在处理非罗马字符时的具体实现方式有些关联;详见 \TeXbook\ \cite{Knuth:TeXbook} 第 370 页。
586585

587586
%\subsection{Creative use of \cs{uppercase} and \cs{lowercase}}
588-
\subsection{妙用 \cs{uppercase} 和 \cs{lowercase}}
587+
\subsection{巧用 \cs{uppercase} 和 \cs{lowercase}}
589588

590589
%The fact that \cs{uppercase} and \cs{lowercase} do not change
591590
%category codes can sometimes be used to create certain
@@ -736,7 +735,7 @@ \subsection{\cs{string} 输出输出字符串的分类码}
736735
%into character tokens with character code~32,
737736
%so the chances are pretty slim that
738737
%`funny spaces' wind up in control sequences.
739-
\cs{string} 命令输出字符串中,各个字符的分类码均为 12\index{category!12},唯独被字符串化的控制序列中的空格,其分类码是 10\index{category!10}。由于控制序列内部不存在分类码的说法,\cs{strign} 输出的所有空格必定只是\emph{空格字符},也就是说,它的字符编码是 32。由于 \TeX 的输入处理器会将所有空格记号的字符编码设置为 32,「滑稽空格」出现在控制序列中的机会相当渺茫。
738+
\cs{string} 命令输出的字符串中,各个字符的分类码均为 12\index{category!12},唯独被字符串化的控制序列中的空格,其分类码是 10\index{category!10}。由于控制序列内部不存在分类码的说法,\cs{string} 输出的所有空格必定只是\emph{空格字符},也就是说,它的字符编码是 32。由于 \TeX 的输入处理器会将所有空格记号的字符编码设置为 32,「滑稽空格」出现在控制序列中的机会相当渺茫。
740739

741740
%Other commands with the same behaviour with respect to
742741
%category codes as \cs{string}, are

0 commit comments

Comments
 (0)