% -*- coding: utf-8 -*- % This is part of the book TeX for the Impatient. % Copyright (C) 2003 Paul W. Abrahams, Kathryn A. Hargreaves, Karl Berry. % See file fdl.tex for copying conditions. \input macros \chapter{使用 \TeX} \chapterdef{usingtex} % Avoid underfull box complaint about the empty paragraph % that precedes the first section heading. % \def\par{{\parfillskip = 0pt plus 1fil\endgraf}\let\par=\endgraf} \vglue-\abovesectionskip % we've skipped enough already \vskip0pt % Make \combineskips work. %\section Turning input into ink \section 从键盘输入变到油墨 %\subsection Programs and files you need \subsection 所需的程序和文件 %In order to produce a \TeX\ document, you'll need to run the \TeX\ %program and several related programs as well. You'll also need %supporting files for \TeX\ and possibly for these other programs. In %this book we can tell you about \TeX, but we can't tell you about the %other programs and the supporting files except in very general terms %because they depend on your local \TeX\ environment. The people who %provide you with \TeX\ should be able to supply you with what we call %\emph{local information}. %\pix^^{local information} %The local information tells you how to %start up \TeX, how to use the related programs, and how to gain access %to the supporting files. 为了制作一个 \TeX\ 文档, 你必需运行 \TeX\ 及其相关软件. 你同时也需要一些 \TeX\ 及其相关软件所用到的辅助文件. 在这本书中, 我们仅仅谈论 \TeX\ 和一些通用的软件及辅助文件, 不过我们不会介绍其它的, 因为它们仅仅和你自己的 \TeX\ 环境相关. 为你提供 \TeX\ 的人可以为你提供我们所说的\emph{本地信息}. \pix^^{本地信息} 这些本地信息可以告诉你如何去启动 \TeX, 如何去使用相关的程序, 以及如何去访问这些所用到的辅助文件. %Input to \TeX\ consists of a file of ordinary text that you can prepare %with a ^{text editor}. A \TeX\ input file, unlike an input file for a %typical word processor, doesn't ordinarily contain any invisible %^{control characters}. %Everything that \TeX\ sees is visible to you too if you %look at a listing of the file. 你可以使用一个 ^{文本编辑器} 来编写一个可以输入到 \TeX\ 的普通文本文件. 一个 \TeX\ 输入文件和一个文字处理软件的输入文件不同, 它通常并不存在任何不可见的^{控制字符}. 任何 \TeX\ 读到的字符对你来说, 都是你可以看到的. %Your input file may turn out to be little more than a skeleton that %calls for other input files. \TeX\ users often organize large documents %such as books this way. You can use the ^|\input| command (\xref\input) %to embed one input file within another. In particular, you can use %|\input| to incorporate files containing \emph{macro definitions}---% %^^{macros//in auxiliary files} %auxiliary definitions that enhance \TeX's capabilities. %If any macro files are available at your \TeX\ installation, the local %information about \TeX\ should tell you how to get at the macro files %and what they can do for you. The standard form of \TeX, %the one described in this book, incorporates a %collection of macros and other definitions known as ^{\plainTeX} %(\xref{\plainTeX}). 你的输入文件, 可以仅仅是一个引用其它输入文件的框架. \TeX\ 用户往往把大的文档, 比如说这本书, 组织成这种形式. 你可以使用 ^|\input| 命令 (\xref\input) 来把一个输入文件篏入到另一个中. 特别地, 你可以使用 |\input|来调入包含\emph{宏定义}的文件, ^^{宏//在辅助文件中} 宏定义是一些辅助的定义, 它可以来增强 \TeX\ 的功能. 如果你的 \TeX\ 系统中包含任何的宏文件, 和 \TeX\ 相关的本地信息会告诉你如何得到这些宏文件, 以及它们的功能. \TeX\ 的标准安装形式, 也就是在这本书中所描述的, 包括了一个被称为 ^{\plainTeX} (\xref{\plainTeX}) 的宏集. %When \TeX\ processes your document, it produces a file called the %^{\dvifile}. The abbreviation ``|dvi|'' stands for ``device %independent''. The abbreviation was chosen because the information in %the \dvifile\ is independent of the device that you use to print or %display your document. 当 \TeX\ 处理你的文档时, 它会产生一种叫做 ^{\dvifile} 的文件. 其中, ``|dvi|'' 的全称为 ``device independent (设备无关)''. 之所以选用这个缩写, 是因为 \dvifile\ 中所包含的信息和你的打印或显示设备无关. %To print your document or view it with a \emph{previewer}, %^^{previewer} %you need to process the ^{\dvifile} with %a \emph{device driver\/} program. %^^{device drivers} %(A previewer is a program that %enables you to see on a screen some approximation of what the typeset %output will look like.) %Different output devices usually %require different device drivers. %After running the device driver, %you may also need to transfer the output of the device driver to the %printer or other output device. %^^{printers} ^^{output devices} %The local information about \TeX\ should tell %you how to get the correct device driver and use it. 当你需要打印或使用\emph{阅览器}查看你的文档时, ^^{阅览器} 你需要使用相应的\emph{设备驱动}来处理之. ^^{设备驱动} (阅览器是一个程序, 它能把和打印出来的结果差不多的排版内容显示在屏幕上.) 不同的输出设备往往需要不同的设备驱动. 在运行设备驱动以后, 你还需要把设备驱动输出的内容传输到打印机或者其它输出设备上. ^^{打印机} ^^{输出设备} 和 \TeX\ 相关的本地信息会告诉你如何得到正确的设备驱动和如何使用它. %Since \TeX\ has no built-in knowledge of particular fonts, it uses %\emph{font files} %^^{font files} %to obtain information about the fonts used in your %document. The font files should also be part of your local \TeX\ %environment. Each font normally requires two files: one containing the %dimensions of the characters in the font (the \emph{metrics file}) %^^{metrics file} %and one containing the shapes of the characters (the \emph{shape file}). %^^{shape file} %Magnified versions of a font share the metrics file but have %different shape files. ^^{magnification} Metrics files are sometimes %referred to as ^{\tfmfile}s, and the different varieties of shape files %are sometimes referred to as ^{\pkfile}s, ^{\pxlfile}s, and ^{\gffile}s. %These names correspond to the names of the files that \TeX\ and its %companion programs use. For example, |cmr10.tfm| is the metrics file %for the |cmr10| font (10-point Computer Modern Roman). 因为 \TeX\ 内部并没有任何关于一个特定字体的任何信息, 它使用\emph{字体文件} ^^{字体文件} 来得到你文档中所使用的字体的信息. 字体文件也是你本地 \TeX\ 环境的一个组成部分. 一个字体一般对应两个文件: 一个文件 (\emph{字体度量文件}) ^^{度量文件} 包括了字体中每个字符的大小信息, 另一个文件 (\emph{字体轮廓文件}) ^^{轮廓文件} 则描述了字体中字符的形状. 一个字体的缩放版本使用同样的字体度量文件, 不过并不使用相同的字体轮廓文件. ^^{放大率} 字体度量文件往往用来指称 ^{\tfmfile}, 而字体轮廓文件则往往用来指称 ^{\pkfile}, ^{\pxlfile} 和 ^{\gffile} 等不同的种类. 这些名称和 \TeX\ 以及相关软件所使用的文件的文件名所对应. 比如, |cmr10.tfm| 为 |cmr10| 字体的字体度量文件 (10-点的计算机现代字体). %\TeX\ itself uses only the metrics file, since it doesn't care what the %characters look like but only how much space they occupy. The device %driver ordinarily uses the shape file, since it's responsible for %creating the printed image of each typeset character. Some device %drivers need to use the metrics file as well. Some device drivers can %utilize fonts that are resident in a printer and don't need shape files %for those fonts. %\secondprinting{\vfill\eject} \TeX\ 本身仅使用字体度量文件, 因为它只关心这个字体的字符占用了多大的空间, 而并不关心这个字体的外形是什么样子的. 设备驱动则往往需要使用字体轮廓文件, 因为它需要负责把每个排出的字符变成印出的图形. 某些设备驱动也需要使用字体度量文件. 一些设备驱动可以使用打印机中包含的字体, 所以可以不需要这些字体的字体轮廓文件. %\secondprinting{\vfill\eject} %\subsection Running {\TeX} \subsection{运行 \TeX} %\bix^^{running \TeX} %You can run \TeX\ on an input file |screed.tex| by typing %^^{input files} %something like `|run tex|' or just `|tex|' (check your local information). %\TeX\ will respond with something like: %% 4/23/90 is Shakespeare's 426th birthday, and Karl's 26th. %\csdisplay %This is TeX, Version 3.0 (preloaded format=plain 90.4.23) %** %| %The ``preloaded format'' here refers to a predigested form of the %^{\plainTeX} macros that come with \TeX. %You can now type `|screed|' to get \TeX\ to process your file. %When it's done, you'll see something like: %\csdisplay %(screed.tex [1] [2] [3] ) %Output written on screed.dvi (3 pages, 400 bytes). %Transcript written on screed.log. %| %displayed on your terminal, or printed in the record of your %run if you're not working at a terminal. Most of this output is %self-explanatory. %The numbers in brackets are page numbers that \TeX\ displays when it %ships out each page of your document to the \dvifile. %\TeX\ will usually assume an %extension `|.tex|' to an input file name %if the input file name you gave doesn't %have an extension. For some forms of \TeX\ you may be able to %invoke \TeX\ directly for an input file by typing: %\csdisplay %tex screed %| %or something like this. \bix^^{运行 \TeX} 你可以通过输入类似 `|run tex|' 或 `|tex|' (查看你的本地信息) 来运行 \TeX\ 来处理一个输入文件 |screed.tex|. ^^{输入文件} \TeX\ 会作出如下显示 % 4/23/90 is Shakespeare's 426th birthday, and Karl's 26th. \csdisplay This is TeX, Version 3.0 (preloaded format=plain 90.4.23) ** | 在这里, ``preloaded format'' (已预先载入的格式) 指的是 \TeX\ 提供的 ^{\plainTeX} 宏集的一个己预先产生的形式. 现在你可以输入 `|screed|' 来让 \TeX\ 来处理你的文件. 当处理结束时, 你可以在终端或者打印机印出的记录上 (如果你不使用终端) 得到类似下面的输出: \csdisplay (screed.tex [1] [2] [3] ) Output written on screed.dvi (3 pages, 400 bytes). Transcript written on screed.log. | 这个输出大部分是不言自明的. 在括号中的数字是 \TeX\ 在把每页内容输入 \dvifile\ 时所显示的当前页码. 当你提供的名件名不含扩展名时, \TeX\ 往往会把你的文件扩展名当作 `|.tex|'. 在某些 \TeX\ 环境中, 你可能可以直接执行类似下面的语句: \csdisplay tex screed | 来直接处理文档. %Instead of providing your \TeX\ input from a file, you can type it directly at %your terminal. To do so, type `^|\relax|' instead of `|screed|' at the %`|**|' prompt. %\TeX\ will now prompt you with a `|*|' for each line of input and interpret %each line of input as it sees it. %To terminate the input, type a command such as `|\bye|' that tells \TeX\ %you're done. %Direct input is sometimes a handy way of experimenting with \TeX. \TeX\ 不仅可以读取文件输入,也可以直接读取你在终端中的输入: 只需将 `|**|' 提示后的输入从 `|screed|' 改为 `^|\relax|'。 \TeX\ 将在你输入的各行前面给出 `|*|' 提示, 并且逐行解释你的输入。 输入类似 `|\bye|' 这样的命令可以结束输入。 在试验 \TeX\ 时直接输入有时更方便。 %When your input file contains other embedded input files, the displayed %information indicates when \TeX\ begins and ends processing each %embedded file. %^^{input files//embedded} %\xrdef{infiles} %\TeX\ displays a left parenthesis and the file name %when it starts working on a file and displays the corresponding right %parenthesis when it's done with the file. %If you get any ^{error messages} in the displayed output, you can match %them with a file by looking for the most recent unclosed left parenthesis. 当你的输入文件包含其他嵌入的输入文件时, 显示的信息中表明了 \TeX\ 何时开始和结束处理每个嵌入文件。 ^^{输入文件//嵌入输入文件} \xrdef{infiles} 当 \TeX\ 开始处理一个文件时它显示一个左圆括号和该文件名, 而结束时显示一个对应的右圆括号。 如果在所显示的输出中有任何^{错误信息}, 你就能从最接近的未配对左圆括号中确定是哪个文件引起的。 %For a more complete explanation of how to run \TeX, %see \knuth{Chapter~6} and your ^{local information}. %\eix^^{running \TeX} 要得到如何运行\TeX\ 的更完整解释, 可以见\knuth{第~6~章}以及你的^{本地信息}. \eix^^{运行 \TeX} %\section Preparing an input file \section 准备输入文件 %In this section we explain some of the conventions that you must follow in %preparing input for \TeX\null. Some of the information given here also %appears in the examples in \chapterref{examples} of this book. %^^{input, preparing} 在这一节中,我们解释准备 \TeX\ 输入文件时必须遵循的一些约定。 其中的有些信息同样出现在本书\chapterref{examples}的例子中。 ^^{输入文件//准备输入文件} %\subsection Commands and control sequences \subsection 命令和控制序列 %\bix^^{commands} %\bix^^{control sequences} %Input to \TeX\ consists of a sequence of commands that tell \TeX\ how to %typeset your document. Most characters act as commands of a particularly %simple kind: ``typeset me''. The letter `|a|', for instance, is a %command to typeset an `a'. But there's another kind of command---a %\emph{control sequence}---that gives \TeX\ a more elaborate %instruction. A control sequence ordinarily starts with a backslash %(|\|), though you can change that convention if you need to. %\xrdef{@backslash} %For instance, the input: \bix^^{命令} \bix^^{控制序列} \TeX\ 的输入由一系列指引 \TeX\ 如何排版文档的命令组成。 大部分字符如同一种特别简单的命令:``排版我''。 比如,字母 `|a|' 是作为命令将排版出 `a'。 但有另一种命令——\emph{控制序列}(control sequence)——将给 \TeX\ 提供更细致的指令。 控制序列通常以反斜杠(|\|)开头,但必要时你也可以更改此约定。 \xrdef{@backslash} 例如,下列输入: %\csdisplay %She plunged a dagger (\dag) into the villain's heart. %| %contains the control sequence |\dag|; it produces the typeset output: %\display{% %She plunged a dagger (\dag) into the villain's heart. %} %\noindent Everything in this example except for the |\dag| and the spaces %acts like a ``typeset me'' command. We'll explain more about spaces %on \xrefpg{spaces}. \csdisplay She plunged a dagger (\dag) into the villain's heart. | 包含一个控制序列|\dag|;它排版出下列的输出: \display{% She plunged a dagger (\dag) into the villain's heart. } \noindent 在这个例子中, 除 |\dag| 和空格之外的每个字符都如同一个``排版我''命令。 在\xrefpg{spaces}中我们将更详细地解释空格的作用。 %There are two kinds of control sequences: \emph{control words} %^^{control words} %and \emph{control symbols}: %^^{control symbols} %\ulist\compact %\li A control word consists of a %backslash followed by one or more letters, e.g., `|\dag|'. %The first character that isn't a letter marks the end %of the control word. %\li A control symbol consists of a backslash followed by a single character %that isn't a letter, e.g., `|\$|'. %The character can be a space or even the end of a line (which is a perfectly %legitimate character). %\endulist 控制序列可分为\emph{控制词}(control word)^^{控制词}% 和\emph{控制符}(control symbol)^^{控制符}这两种类型: \ulist\compact \li 控制词由反斜杠后跟一个或多个字母组成,例如`|\dag|'。 其后用一个非字母字符结束该控制词。 \li 控制符由反斜杠后跟一个单个的非字母字符组成,例如`|\$|'。 该非字母字符可以是空格符,甚或是行结束符(这也是合乎规则的字符)。 \endulist %\noindent %A control word (but not a control symbol) %absorbs any spaces or ends of line that follow it. %^^{control sequences//absorbing spaces} %If you don't want to lose a space after a control word, %follow the control sequence with a ^{control space} %(|\!visiblespace|) or with `|{}|'. Thus either: %\csdisplay %The wonders of \TeX\!visiblespace!.shall never cease!! %| %or:\hfil\ %\csdisplay %The wonders of \TeX{} shall never cease!! %| %produces: %\display{% %The wonders of \TeX{} shall never cease! %} %\noindent rather than: %\display{% %The wonders of \TeX shall never cease! %} %\noindent %which is what you'd get if you left out the `|\|\visiblespace' %or the `|{}|'. \noindent 控制词后的任何空格或行结束符将被忽略(但控制符后不会这样)。 ^^{控制序列//忽略空格} 如果你真要在控制词后得到一个空格, 可以在该控制词后键入一个^{控制空格}(|\!visiblespace|)或者`|{}|'。 因而这样输入: \csdisplay The wonders of \TeX\!visiblespace!.shall never cease!! | 或者这样输入:\hfil\ \csdisplay The wonders of \TeX{} shall never cease!! | 将得到同样的结果: \display{% The wonders of \TeX{} shall never cease! } \noindent 作为对比,下面的结果: \display{% The wonders of \TeX shall never cease! } \noindent 是你去掉上面输入中的`|\|\visiblespace'或者`|{}|'后得到的。 %Don't run a control word together with the text that follows it---\TeX\ %won't know where the control word ends. For instance, the |\c| control %sequence places a cedilla accent on the character that follows it. The %French word {\it gar\c con\/} must be typed as %`|gar\c!visiblespace!.con|', not `|gar\ccon|'; if you write the latter, %\TeX\ will complain about an undefined control sequence |\ccon|. 不要将控制词和其后的文本连在一起---这样\TeX\ 无法知道控制词在哪里结束。 比如,控制词|\c|给其后的字符加上软音符。 要得到法文单词{\it gar\c con\/},你必须输入`|gar\c!visiblespace!.con|', 而不是`|gar\ccon|';若你输入后者,\TeX\ 将抱怨有未定义的控制序列|\ccon|。 %A control symbol, on the other hand, doesn't absorb anything that %follows it. Thus you must type `\$13.56' as `|\$13.56|', not %`|\$!vs13.56|'; the latter form would produce `\hbox{\$ 13.56}'. %However, those accenting commands that are named by control symbols are %defined in such a way that they produce the effect of absorbing a %following space. Thus, for example, you can type the French word {\it %d\'eshabiller\/} either as `|d\'eshabiller|' or as %`|d\'!visiblespace!.eshabiller|'. 另一方面,控制符后面的任何字符都不会被忽略。 因此,要得到`\$13.56'你必须键入`|\$13.56|', 而不是`|\$!vs13.56|';后者将生成`\hbox{\$ 13.56}'。 然而,那些作为控制符的重音命令,是以忽略其后空格的方式定义的。 例如,要得到法文单词{\it d\'eshabiller\/},键入`|d\'eshabiller|', 或者`|d\'!visiblespace!.eshabiller|'都可以。 %Every control sequence is also a command, %but not the other way around. %^^{commands//versus control sequences} %^^{control sequences//versus commands} %For instance, the letter `|N|' %is a command, but it isn't a control sequence. %In this book we ordinarily use ``command'' rather than %``control sequence'' when either term would do. %We use ``control sequence'' when we want to emphasize aspects of \TeX\ %syntax that don't apply to commands in general. 每个控制序列同时也是一个命令,但反之未必。 ^^{命令//与控制序列对比} ^^{控制序列//与命令对比} 例如字母`|N|'是一个命令,但它不是一个控制序列。 在本书里面,当两者都适用时我们用``命令''而不用``控制序列''。 在强调 \TeX\ 的语法层面时,我们用``控制序列'', 因为此时用``命令''一般并不合适。 %\eix^^{control sequences} %\eix^^{commands} \eix^^{控制序列} \eix^^{命令} %\subsection Arguments \subsection 参量 %\xrdef{arg1} %Some commands need to be followed by one or more %\emph{arguments} ^^{arguments} %that help to determine what the command does. %For instance, the |\vskip| command, which %tells \TeX\ to skip down (or up) the page, %expects an argument specifying how much space to skip. To skip %down two inches, you would type `|\vskip 2in|', where |2in| %is the argument of |\vskip|. \xrdef{arg1} 有些命令的运行依赖于其后的一个或多个\emph{参量}(argument)^^{参量}。 例如,|\vskip|命令告诉 \TeX\ 在页面中往上(或往下)跳过一定间距, 它需要一个参量来指定所跳过间距的大小。 要往下跳过两英寸,你需要键入`|\vskip 2in|', 其中的|2in|就是|\vskip|的参量。 %Different commands expect different kinds of arguments. Many commands %expect dimensions, such as the |2in| in the example above. %Some commands, particularly those defined by macros, %expect arguments that are either a single character or some %text enclosed in braces. %Yet others require that their arguments be enclosed in braces, i.e., %they don't accept single-character arguments. %The description of each command in this book tells you what kinds of arguments, %if any, the command expects. %In some cases, required braces define a group (see \xref{bracegroup}). 不同的命令要求不同类型的参量。 很多命令的参量要求是长度值,比如上面例子中的|2in|。 有些命令,特别是用宏定义的命令, 其参量可以是单个字符或者放在花括号中的文本。 而对其他有些命令,其参量只能放在花括号中,而不能是单个字符。 在本书对各个命令的描述中,若一个命令需要参量, 我们都说明了该命令所需参量的类型。 在有些情形中,命令的参量所需的花括号定义了一个编组(见\xref{bracegroup})。 %\secondprinting{\vfill\eject} %\subsection Parameters \subsection 参数 %\xrdef{introparms} %Some commands are parameters (\xref{parameter}). %^^{parameters//as commands} %You can use a parameter in either of two ways: %\olist %\li You can use the value of a parameter %as an argument to another command. For example, the command %\hbox{|\vskip\parskip|} %causes a vertical skip by the value of the |\parskip| (paragraph skip) %glue parameter. %\li You can change the value of the parameter by assigning %something to it. For example, the assignment \hbox{|\hbadness=200|} %causes the value of the |\hbadness| number parameter to be $200$. %\endolist %\noindent %We also use the term ``parameter'' to refer to entities such as |\pageno| %that are actually registers but behave just like parameters. %^^{registers//parameters as} \xrdef{introparms} 有些命令实际上是参数(parameter,见\xref{参数})。 ^^{参数//作为命令} 你可以按下面两种方式使用这种参数: \olist \li 将该参数的值用作其他命令的参量。 例如 \hbox{|\vskip\parskip|} 这个命令生成大小% 等于粘连参数|\parskip|(段落间距)的竖直间距。 \li 通过赋值修改该参数的值。 例如 \hbox{|\hbadness=200|} 这个赋值使得|\hbadness|参数的值变为$200$. \endolist \noindent 有些命令,例如|\pageno|,虽然是寄存器但和参数的用法一样。 因此我们同样使用``参数''这个术语来指代这些命令。 ^^{寄存器//作为参数} %Some commands are names of tables. These commands are used like %parameters, except that they require an additional argument that %specifies a particular entry in the table. For example, |\catcode| names %a table of category codes (\xref{category code}). Thus %the command %\hbox{|\catcode`~=13|} sets the category code of the `|~|' %character to $13$. 有些命令是表名。这些命令的用法和参数类似, 只是它们需要额外的参量指定表格项。 例如,|\catcode| 是类别码表格的名称(\xref{类别码})。 因此,\hbox{|\catcode`~=13|} 这个命令设置字符`|~|'的类别码为$13$。 %\subsection Spaces \subsection 空格 %\xrdef{spaces} %\bix^^{spaces} %You can freely use extra spaces in your input. Under nearly all circumstances %\TeX\ treats several spaces in a row as being equivalent to a %single space. For instance, it doesn't matter whether you put one space %or two spaces after a ^{period} in your input. Whichever you do, \TeX\ %performs its end-of-sentence maneuvers and leaves the appropriate %(in most cases) amount of space after the period. %\TeX\ also treats the end of an input line as equivalent to a space. %Thus you can end your input lines wherever it's convenient---% %\TeX\ makes input %lines into %paragraphs in the same way no matter where the line breaks are in your %input. \xrdef{spaces} \bix^^{空格} 在输入文件中你可以任意加上额外的空格。 在几乎所有情形中 \TeX\ 都将同一行的连续多个空格看成一个空格。 例如,在^{句号}后加上一个或两个空格是没有差别的。 不论按照哪种写法,\TeX\ 都会执行其句子结束操作, 并在句号后加上适当(在多数情形下)大小的间隔。 \TeX\ 同样将输入中的行结束符视为一个空格。 因此在输入时你可以在方便的地方换行——% \TeX\ 按照此方式将各输入行转换为段落,而不在乎输入中的换行位置。 %A blank line in your input marks the end of a paragraph. %^^{paragraphs//ending} %Several blank lines are equivalent to a single one. 输入中的一个空行结束当前段落。 ^^{段落//结束段落} 多个空行也等同于一个空行。 %\TeX\ ignores input spaces within math formulas (see below). Thus you can %include or omit spaces anywhere within a math formula---\TeX\ doesn't care. %Even within a math formula, however, %you must not run a control word together with a following letter. \TeX\ 忽略数学公式中的空格(见后面)。 因此,你可以加上或者省去公式中的空格——\TeX\ 不在乎这个。 但即使在数学公式中,你也不要将控制词和其后的字母连在一起。 %If you are defining your own macros, you need to be particularly careful about %where you put ends of line in their definitions. %It's all too easy to define a macro that produces an %^{unwanted space} in addition to whatever else it's supposed to produce. %We discuss this problem elsewhere since it's somewhat %technical; see \xrefpg{unwantedspace}. 在定义自己的宏时,你必须小心定义中的行结束符位置。 因为一不小心该宏就在你希望的空格之外生成了^{不需要的空格}。 因为这是个有些技术性的问题,我们在其他地方也讨论到此问题;见\xrefpg{unwantedspace}。 %A space or its equivalent between two words in your input doesn't simply turn %into a space character in your output. %A few of these input spaces turn into ends of lines %in the output, %since input lines generally don't correspond to output lines. %The others turn into spaces of variable width called ``glue'' (\xref{glue}), %which has a natural size (the size it ``wants to be'') %but can stretch or shrink. %When \TeX\ is typesetting a paragraph %that is supposed to have an even right margin (the usual %case), it adjusts the widths of the glue in each line %to get the lines to end at the margin. %(The last line of a paragraph is an exception, since it isn't ordinarily %required to end at the right margin.) 输入文件中两单词间的一个空格或其等价字符, 并不简单地变成输出中的一个空格。 由于输入行和输出行通常不会正好对应, 输入中的这些空格有的变成输出中的行结束符, 另外有些空格则变成宽度可变的间隔即``粘连'' (\xref{粘连}); 粘连有其自然宽度(它希望的宽度),但也可以伸展或者收缩。 \TeX\ 排版要求右页边对齐(通常如此)的段落时, 将调整各行的粘连的宽度以让各行正好在页边结束。% (段落的最后一行是个例外,因为一般不要求它在右页边结束。) %You can prevent an input space from turning into an end of line by using a %^{tie} (^|~|). %For example, you wouldn't want \TeX\ to put a line break between the %`Fig.' and `8' of `Fig.~8'. %By typing `|Fig.~8|' you can prevent such a line break. %\eix^^{spaces} %\needspace{2in} 要阻止输入中的空格在输出中变成行结束符,你可以用^{带子} (^|~|)。 比如,你不会希望 \TeX\ 在`Fig.~8'的 `Fig.' 和 `8' 之间断行。 输入 `|Fig.~8|' 就可以禁止这样断行。 \eix^^{空格} %\needspace{2in} %\subsection Comments \subsection 注释 %\xrdef{comments} %\pix\bix^^{comments} %You can include comments in your \TeX\ input. %When \TeX\ sees a comment it just passes over it, so %what's in a comment doesn't affect your typeset document in any way. %Comments are useful for %providing extra information about what's in your input file. %For example: %\csdisplay %% ========= Start of Section `Hedgehog' ========= %| \xrdef{comments} \pix\bix^^{注释} 在\TeX\ 输入中可以包含注释。\TeX\ 跳过它所碰到的注释, 因此注释中的内容不会以任何方式影响到排版的文档。 注释用于在输入文件中提供更多的信息。 例如: \csdisplay % ========= Start of Section `Hedgehog' ========= | %{\indexchar % }% %A comment starts with a percent sign (|%|) and extends to the end of the %input line. %\TeX\ ignores not just the comment but the end of the line as well, so %comments have another very %important use: connecting two lines so that the end of line %^^{line breaks//deleting} %between them is invisible to \TeX\ and doesn't generate %an output space or an end of line. %For instance, if you type: %\csdisplay %A fool with a spread% %sheet is still a fool. %| %you'll get: %\display{ %A fool with a spread% %sheet is still a fool. %} %\eix^^{comments} {\indexchar % }% 注释以百分号(|%|)开始,一直延续到该输入行结束。 \TeX\ 既忽略注释也忽略该行的结束符, 因此注释有另外的重要用法:将两个输入行连接起来, ^^{断行//删除断行} 使得 \TeX\ 看不到两行间的行结束符, 从而不会在输出中生成空格或换行。 例如,对如下的输入: \csdisplay A fool with a spread% sheet is still a fool. | 你得到的输出为: \display{ A fool with a spread% sheet is still a fool. } \eix^^{注释} %\subsection Punctuation \subsection 标点 %\null %\xrdef{periodspacing} %\TeX\ normally adds some extra space after what it thinks is a %^{punctuation} mark at the end of a sentence, %namely, `^|.|', `^|?|', or `|!!|' \indexchar ! %^^{period} ^^{question mark} ^^{exclamation point} %followed by an input space. %\TeX\ doesn't add %the extra space if the punctuation mark follows %a capital letter, though, because it assumes the capital %letter to be an initial in someone's name. %You can force the extra space where it wouldn't otherwise occur by %typing something like: %\csdisplay %A computer from IBM\null? %| \null \xrdef{periodspacing} 若 `^|.|',`^|?|' 或 `|!!|' 之后有个输入空格,\indexchar ! ^^{句号} ^^{问号} ^^{感叹号} \TeX\ 认为它是句末^{标点}符号,并在其后添加额外间隔。 但若该标点符号之前为大写字母,\TeX\ 就不会添加额外间隔, 因为它认为大写字母是人名的首字母。 如若不然你可以强制生成额外间隔,例如: \csdisplay A computer from IBM\null? | %The |\null| doesn't produce any output, but it does prevent \TeX\ %from associating the capital `M' with the question mark. %On the other hand, you can cancel the %extra space where it doesn't belong by typing a control space %after the punctuation mark, e.g.: %\csdisplay %Proc.\!visiblespace!.Royal Acad.\!visiblespace!.of Twits %| %so that you'll get: %\display{Proc.\ Royal Acad.\ of Twits} %\noindent rather than: %\display{Proc. Royal Acad. of Twits} 命令 |\null| 不生成任何输出, 但它阻止 \TeX\ 将大写字母`M'和问号结合在一起。 反过来,如果某标点符号不为句末标点, 你也能够取消该标点之后的额外间隔; 这可以通过在其后键入控制空格达到,例如: \csdisplay Proc.\!visiblespace!.Royal Acad.\!visiblespace!.of Twits | 得到的正确结果为: \display{Proc.\ Royal Acad.\ of Twits} \noindent 而去掉控制空格后的结果是: \display{Proc. Royal Acad. of Twits} %Some people prefer not to leave more space after punctuation at the %end of a sentence. You can get this effect with the %^|\frenchspacing| command (\xref\frenchspacing). %|\frenchspacing| is often recommended for ^{bibliographies}. 有些人更喜欢不在句末标点后留下更多间隔。 利用 ^|\frenchspacing| 命令(\xref\frenchspacing )你就可达成此效果。 在^{参考文献}中通常建议使用这个 |\frenchspacing| 命令。 %For single ^{quotation marks}, you should use the left and right %single quotes %(|`| and |'|) on your keyboard. For left and right %double quotation marks, use two left single %quotes or two right single quotes (|``| or |''|) rather %than the double quote (|"|) on your keyboard. %The keyboard double quote %will in fact give you a right double quotation mark in %many fonts, but the two right single quotes %are the preferred \TeX\ style. %For example: 对于单^{引号}, 用键盘上的左右单引号(|`| 和 |'|)就可以得到。 对于左双引号或右双引号, 需要用两个左单引号(|``|)或右单引号(|''|)得到, 不能直接用键盘上的双引号(|"|)。 键盘上的双引号在多数字体中将得到一个右双引号, 但两个右单引号是 \TeX\ 中首选的写法。例如: %\vbox{% %\csdisplay %There is no `q' in this sentence. %``Talk, child,'' said the Unicorn. %She said, ``\thinspace`Enough!!', he said.'' %| %}% %These three lines yield: %\display{\par\restoreplainTeX %There is no `q' in this sentence. %\par ``Talk, child,'' said the Unicorn. %\par She said, ``\thinspace`Enough!', he said.'' %} %\noindent %The |\thinspace| in the third input line prevents %the single quotation mark from coming %too close to the double quotation marks. %Without it, you'd just see three %nearly equally spaced quotation marks in a row. \vbox{% \csdisplay There is no `q' in this sentence. ``Talk, child,'' said the Unicorn. She said, ``\thinspace`Enough!!', he said.'' | }% 这三行输入得到的结果为: \display{\par\restoreplainTeX There is no `q' in this sentence. \par ``Talk, child,'' said the Unicorn. \par She said, ``\thinspace`Enough!', he said.'' } \noindent 第三个输入行中的 |\thinspace| 避免单引号和双引号太过靠近。 否则,你将看到三个并排的间隔相近的引号。 %\TeX\ has three kinds of ^{dashes}: %\ulist\compact %\li Short ones (hyphens) like this ( - ). You get them by typing~`^|-|'. %\li Medium ones (en-dashes) like this ( -- ). You get them by typing~`^|--|'. %\li Long ones (em-dashes) like this ( --- ). You get them by typing~`^|---|'. %\endulist %\noindent %Typically you'd use hyphens to indicate compound words like %``will-o'-the-wisp'', %en-dashes to indicate %page ranges such as ``pages~81--87'', and em-dashes to indicate %a break in continuity---like this. 在 \TeX\ 中有三种^{横线号}(dash): \ulist\compact \li 短横线即连字号(hyphen)如这样( - )。键入~`^|-|'~可以得到。 \li 中横线即连接号(en-dash)如这样( -- )。键入~`^|--|'~可以得到。 \li 长横线即破折号(em-dash)如这样( --- )。键入~`^|---|'~可以得到。 \endulist \noindent 一般地,你将用连字号表示像“will-o'-the-wisp”(鬼火)这样的复合词, 用连接号表示像“第~81--87~页”这样的页码起止, 而用破折号表示语气转折\null{---}像这样。 % 用 \null 和 {} 绕开 xecjk 的问题 %\subsection Special characters \subsection 特殊字符 %Certain characters have special meaning to \TeX, so you shouldn't use them %in ordinary text. They are: 在 \TeX\ 中某些字符有特殊的含义, 因而不能在普通文本中使用。这些特殊字符为: %\csdisplay % $ # & % _ ^ ~ { } \ %| %^^|$//in ordinary text| %^^|#//in ordinary text| %^^|&//in ordinary text| %^^|_//in ordinary text| %^^|^//in ordinary text| %^^|~//in ordinary text| %^^|%//in ordinary text| %^^|{//in ordinary text| %^^|}//in ordinary text| %{\recat!ttidxref[\//in ordinary text]] %\noindent %In order to produce them in your typeset document, %you need to use circumlocutions. For the first five, %you should instead type: %^^|\$| %^^|\#| %^^|\&| %^^|\%| %^^|\_| %\csdisplay % \$ \# \& \% \_ %| \csdisplay $ # & % _ ^ ~ { } \ | \ifoldeplain ^^|$//在普通文本中| ^^|#//在普通文本中| ^^|&//在普通文本中| ^^|_//在普通文本中| ^^|^//在普通文本中| ^^|~//在普通文本中| ^^|%//在普通文本中| ^^|{//在普通文本中| ^^|}//在普通文本中| {\recat!ttidxref[\//在普通文本中]] \fi \noindent 要在排版的文档中生成它们,你需要使用间接的方法。 对前面五个字符,你需要键入: \ifoldeplain ^^|\$| ^^|\#| ^^|\&| ^^|\%| ^^|\_| \fi \csdisplay \$ \# \& \% \_ | %\noindent %For the others, you need something more elaborate: \noindent 而对另外五个字符,你需要键入更多: \csdisplay \^{!visiblespace} \~{!visiblespace} $\{$ $\}$ $\backslash$ | %\subsection Groups \subsection 编组 %\bix^^{groups} %A \emph{group} %consists of material enclosed in matching left and right braces (|{| and %|}|). %^^|{//starting a group| %^^|}//ending a group| %By placing a command within a group, you can limit its effects to %the material within the group. %For instance, the |\bf| command tells \TeX\ to set %something in {\bf boldface} type. If you were to put |\bf| into your input %and do nothing else to counteract it, everything in your document following the %|\bf| would be set in boldface. %By enclosing |\bf| in a group, %you limit its effect to the group. For example, if you type: %\csdisplay %We have {\bf a few boldface words} in this sentence. %| %\noindent you'll get: %\display{We have {\bf a few boldface words} in this sentence.} \bix^^{编组} 包含在配对的左右花括号(|{| 和 |}|)中的内容组成一个\emph{编组}。 ^^|{//开始编组| ^^|}//结束编组| 编组内部的命令,其作用范围被限制在该编组内部。 例如,|\bf| 命令让 \TeX\ 将某些内容用粗体显示。 如果你将 |\bf| 放在你的输入中,而没有用任何方式取消它, |\bf| 之后的所有内容都将以粗体显示。 如果将 |\bf| 包含在一个编组中, 就可以将它的作用限制在此编组中。 比如,如果你键入: \csdisplay We have {\bf a few boldface words} in this sentence. | \noindent 你将会得到如下的结果: \display{We have {\bf a few boldface words} in this sentence.} %\noindent You can also use a group to limit the effect of %an assignment to one of \TeX's parameters. %These parameters contain values that affect how \TeX\ typesets your document. %For example, the value of the |\parindent| %parameter specifies the indentation at the beginning of a paragraph. %The assignment |\parindent = 15pt| %sets the indentation to $15$ printer's points. %By placing this assignment at the beginning %of a group containing a few paragraphs, you can change %the indentation of just those paragraphs. If you don't enclose %the assignment in a group, %the changed indentation will apply to the rest of the document (or up to the %next assignment to |\parindent|, if there's a later one). \noindent 利用编组,你可以限制 \TeX\ 某个参数的取值的作用范围。 这些参数的取值影响 \TeX\ 对文档的排版。 例如,|\parindent| 参数的值指定了段首缩进量, 赋值 |\parindent = 15pt| 将设定该缩进量为 $15$ 点。 若将该赋值放在包含几个段落的编组开始处, 你就可以仅仅改变这几个段落的段首缩进。 若不将该赋值包含在编组中, 对缩进量的修改将作用到文档的剩余部分% (或者作用到下个对|\parindent|的赋值为止,若还有下个赋值的话)。 %\xrdef{bracegroup} %Not all pairs of braces indicate a group. %In particular, the braces associated with an argument for which the %braces are \emph{not} required don't indicate a group---they just %serve to delimit the argument. %Of those commands that do require braces for their arguments, %some treat the braces as defining a group %and the others interpret the argument in some special way that depends on %the command.\footnote %{More precisely, for primitive commands either %the braces define a group or they enclose tokens that aren't processed in %\TeX's stomach. %For |\halign| and |\valign| the group has a trivial %effect because everything within the braces either doesn't reach the stomach %(because it's in the template) or is enclosed in a further inner group. %^^|\halign//grouping for| %^^|\valign//grouping for| %} %\eix^^{groups} \xrdef{bracegroup} 并非所有配对花括号都表示一个编组。 特别地,若参量\emph{不要求}有花括号, 则与该参量一起的花括号并不表示一个编组% ——它们仅用于确定该参量的界限。 对于那些参量中确实需要花括号的命令, 有些命令将花括号作为编组的定义, 而其他命令用各自的特殊方式解释该参量。\footnote {更准确地说,对于原始命令, 花括号要么定义了一个编组,要么不会在 \TeX\ 的胃中被处理。 对于 |\halign| 和 |\valign| 命令,编组只有平凡的效果; 这是由于编组中的一切东西要么不会到达胃里(因为它在模板中), 要么包含在更深一层的编组中。 ^^|\halign//阵列中的编组| ^^|\valign//阵列中的编组| } \eix^^{编组} %\subsection Math formulas \subsection 数学公式 %\bix^^{math} %\xrdef{mathform} %A math formula can appear in text (\emph{text math}) %^^{text math} %or set off on a line by itself %with extra vertical space around it (\emph{display math}). %^^{display math} %You enclose a text formula in single dollar signs (|$|) %and a displayed formula in double dollar signs (|$$|). %\ttidxref{$}\ttidxref{$$} %For example: \bix^^{数学} \xrdef{mathform} 数学公式可以出现在正文中(\emph{文内公式}), ^^{文内公式} 或者出现在留出额外上下间距的单独一行中(\emph{陈列公式})。 ^^{陈列公式} 文内公式两边用单个美元符(|$|)括起来, 而陈列公式两边用双个美元符(|$$|)括起来。 \ifoldeplain\ttidxref{$}\ttidxref{$$}\fi 例如: %\csdisplay %If $a