Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1 #7

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 28 additions & 44 deletions chapter12.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ \chapter{Expansion}\label{expand}
%procedure calls in most programming languages. This chapter treats the
%commands connected with expansion, and gives a number of (non-trivial)
%examples.
\emph{Expansion}\index{expansion} in \TeX\ is rather different from
procedure calls in most programming languages. This chapter treats the
commands connected with expansion, and gives a number of (non-trivial)
examples.
在\TeX\ 中,\emph{展开}与众多编程语言的函数调用不同。本章主要讲命令的展开,并给出一些非平凡的例子。

%\label{cschap:relax}\label{cschap:expandafter}\label{cschap:noexpand}\label{cschap:afterassignment}\label{cschap:the}
%\begin{inventory}
Expand All @@ -25,28 +22,27 @@ \chapter{Expansion}\label{expand}
\label{cschap:relax}\label{cschap:expandafter}\label{cschap:noexpand}\label{cschap:afterassignment}\label{cschap:the}
\begin{inventory}
\item [\cs{relax}]
Do nothing.
什么也不做。


%\item [\cs{expandafter}]
% Take the next two tokens and place the expansion of the
% second after the first.
\item [\cs{expandafter}]
Take the next two tokens and place the expansion of the
second after the first.
将后一个记号放到前一个记号之前。

%\item [\cs{noexpand}]
% Do not expand the next token.
\item [\cs{noexpand}]
Do not expand the next token.
不展开下一个记号。


%\item [\cs{edef}]
% Start a macro definition;
% the replacement text is expanded at definition time.
\item [\cs{edef}]
Start a macro definition;
the replacement text is expanded at definition time.
开始一个宏定义;
替换的文字在定义时即展开。

%
%\item [\cs{aftergroup}]
Expand All @@ -67,8 +63,7 @@ \chapter{Expansion}\label{expand}
% Expand the value of various quantities in \TeX\ into a string
% of character tokens.
\item [\cs{the}]
Expand the value of various quantities in \TeX\ into a string
of character tokens.
将 \TeX\ 定义中的各种 quantities 展开成字符记号。

%\end{inventory}
\end{inventory}
Expand All @@ -88,15 +83,8 @@ \section{Introduction}
%largely assignments and typesettable material;
%the former category
%is expanded, and the result of that expansion is examined anew.
\TeX's expansion processor accepts a stream of tokens
coming out of the input processor, and its result is
again a stream of tokens, which it feeds to the execution
processor. For the input processor there are two
kinds of tokens: expandable and unexpandable ones.
The latter category is passed untouched, and it contains
largely assignments and typesettable material;
the former category
is expanded, and the result of that expansion is examined anew.
\TeX 的 展开处理器接受输入处理器的记号流,并产生记号流的输出结果输入到执行处理器中。
对于输入处理器来说,有两种类型的记号:可展开的与不可展开的。后一种在处理过程中保持不变,它主要包括 assignments 和可打印的内容;前一种被展开,下面就展开的结果详细讨论。

%%\point Ordinary expansion
%\section{Ordinary expansion}
Expand All @@ -119,9 +107,7 @@ \section{Ordinary expansion}
% \cs{splitfirstmark}, \cs{splitbotmark}
%\item \cs{input}, \cs{endinput}
%\end{itemize}
The following list gives those constructs
that are expanded, unless
expansion is inhibited:
下面的列表给出了会被展开的 constructs,除非展开被禁止。
\index{expansion!expandable constructs}
\begin{itemize}
\item macros\label{expand:lijst}
Expand Down Expand Up @@ -177,21 +163,20 @@ \section{Ordinary expansion}
% preceded by \cs{span} and the tokens in a \cs{tabskip}
% assignment are still expanded.
%\end{itemize}
This is the list of all instances where
expansion is inhibited:
下表是不会展开的所有情形:
\begin{itemize}\label{noexp:list}
\item when \TeX\ is reading a token to be defined by
\item \TeX\ 读到被下述环境作用的记号时

\begin{itemize} \item a \gr{let assignment}, that is,
by \cs{let} or \cs{futurelet},
\item a \gr{shorthand definition}, that is,
by \cs{chardef} or \cs{mathchardef}, or a
\gr{register def}, that is, \cs{countdef},
\begin{itemize} \item \gr{let assignment}, ,
\cs{let} \cs{futurelet},
\item \gr{shorthand definition}, ,
\cs{chardef} \cs{mathchardef}, 或是
\gr{register def}, 包括, \cs{countdef},
\cs{dimendef}, \cs{skipdef}, \cs{muskipdef},
or~\cs{toksdef},
\item a \gr{definition}, that is a macro definition
with \cs{def}, \cs{gdef}, \cs{edef}, or~\cs{xdef},
\item the \gr{simple assignment}s \cs{read} and \cs{font};
以及~\cs{toksdef},
\item \gr{definition},遇到宏定义时。
\cs{def}, \cs{gdef}, \cs{edef}, ~\cs{xdef},
\item \gr{simple assignment}s \cs{read} \cs{font};
\end{itemize}
\item when a \gr{parameter text} or macro arguments
are being read; also when the replacement text of a
Expand Down Expand Up @@ -222,21 +207,20 @@ \section{Ordinary expansion}
%%\point Reversing expansion order
%\section{Reversing expansion order}
%\point Reversing expansion order
\section{Reversing expansion order}
\section{颠倒展开的顺序}

%Every once in a while you need to change the normal order of
%expansion of tokens. \TeX\ provides several mechanisms for
%this. Some of the control sequences in this section are
%not strictly concerned with expansion.
Every once in a while you need to change the normal order of
expansion of tokens. \TeX\ provides several mechanisms for
this. Some of the control sequences in this section are
人们时常会有改变记号正常的展开顺序的需求。 \TeX\ 提供了若干种机制来达到这一目的。
Some of the control sequences in this section are
not strictly concerned with expansion.

%%\spoint One step expansion: \cs{expandafter}
%\subsection{One step expansion: \protect\cs{expandafter}}
%\spoint One step expansion: \cs{expandafter}
\subsection{One step expansion: \protect\cs{expandafter}}
\subsection{一步展开: \protect\cs{expandafter}}

%The most obvious tool for reversed expansion order is
%\csidx{expandafter}. The sequence
Expand Down Expand Up @@ -265,10 +249,10 @@ \subsection{One step expansion: \protect\cs{expandafter}}
%\item If the \cs{tokentwo} is a macro with one or more
%parameters, sufficiently many subsequent tokens will be absorbed
%to form the replacement text.\end{itemize}
The most obvious tool for reversed expansion order is
\csidx{expandafter}. The sequence
最常用的reversed 展开是用
\csidx{expandafter}. 序列
\begin{disp}\cs{expandafter}\gr{token$_1$}\gr{token$_2$}\end{disp}
expands to
展开为
\begin{disp}\gr{token$_1$}\gr{\italic the expansion of token$_2$}
\end{disp}
Note the following.
Expand Down