summaryrefslogtreecommitdiff
path: root/info/tex-nutshell/tex-nutshell.tex
diff options
context:
space:
mode:
Diffstat (limited to 'info/tex-nutshell/tex-nutshell.tex')
-rw-r--r--info/tex-nutshell/tex-nutshell.tex103
1 files changed, 66 insertions, 37 deletions
diff --git a/info/tex-nutshell/tex-nutshell.tex b/info/tex-nutshell/tex-nutshell.tex
index 412313ca2d..18077c7bf7 100644
--- a/info/tex-nutshell/tex-nutshell.tex
+++ b/info/tex-nutshell/tex-nutshell.tex
@@ -1,12 +1,25 @@
\useoptex % We are using OpTeX, no LaTeX
-\report
\fontfam[pagella]
+\report
\emergencystretch=2em
\hbadness=2100
\def\thed#1{\ifnum#1<10 0\fi\the#1}
+\let\isAleBsaved=\_isAleB
+\def\preprocessindex{% sort \_iilist with the rule: .word is before :word is before word
+ \def\_isAleB ##1##2{%
+ \edef\tmpb{\csstring ##1&\relax\csstring ##2&\relax}%
+ \_ea\testAleB \tmpb
+ }
+ \ifx\_iilist\empty \else \_dosorting\_iilist \fi
+ \let\_isAleB=\isAleBsaved
+}
+\def\testAleB #1#2#3\relax #4#5#6\relax{%
+ \ifnum `#2<`#5 \_AleBtrue \else \_AleBfalse \fi
+}
+
\catcode`<=13
\def<#1>{{\def\_dsp { }\iindex{:#1}\iis {:#1} {$\langle\hbox{\it#1}\rangle$}}%
$\def\,{\hskip1.5pt plus.3pt minus1.2pt}\,\langle\hbox{\it#1}\rangle\,$}
@@ -21,7 +34,11 @@
\adef|#1;{{\Red#1}}
\toksapp\everyintt{\catcode`\/=13 \catcode`\|=13}
\catcode`\/=12 \catcode`\|=12
-\def\comment#1\par{{\adef\%{\%}\Green\%#1}\par}
+\ifx\_partokenset\undefined
+ \def\comment#1\par{{\adef\%{\%}\Green\%#1}\par}
+\else
+ \def\comment#1\_par{{\adef\%{\%}\Green\%#1}\_par}
+\fi
\catcode`\%=14
\toksapp\everytt{\adef\%{\comment}}
@@ -134,8 +151,9 @@ There are four types of meanings of control sequences:
* the control sequence can be a \ii macro {\em macro}. When it is read, it is
replaced by its \ii replacement/text {\em replacement text} in the input queue. If there are more
macros in the replacement text, all macros are replaced. This is called the
- \ii expansion/process {\em expansion process} which ends on the level of text to be printed or
- primitive commands or registers or character constants or font selectors.
+ \ii expansion/process {\em expansion process} which ends when only printable text,
+ primitive commands (listed in section~\ref[main]),
+ registers (section~\ref[reg]), character constants, or font selectors remain.
\enditems
Example. When \TeX/ reads:
@@ -170,9 +188,10 @@ only \"private" control sequences (prefixed by `_`). So, a user can re-define
\sec Formats, engines
\TeX/ is able to start without any macros preloaded in the so-called \ii ini-TeX/state {\em ini-\TeX/
-state} (the `-ini` option on the command line must be used). It knows only Cca 300
-primitive registers and primitive commands at this state.\fnote
-{Roughly speaking, if you know all these 300 primitive objects and the syntax of all
+state} (the `-ini` option on the command line must be used). It already knows
+only primitive registers and primitive commands at this state.\fnote
+{Roughly speaking, if you know all these primitive objects (about 300 in
+classical \TeX/, 700 in Lua\TeX/) and the syntax of all these
primitive commands and all the built-in algorithms, then you know all about \TeX.
But starting to produce ordinary documents from this primitive level without
macro support is nearly impossible.}
@@ -200,7 +219,7 @@ format file with the same name which is used for running \TeX. For example
and reads the `document.tex`.
The `tex.fmt` is the format file dumped when \ii plain~TeX/macros {\em plain \TeX/ macros}\fnote
-{Plain \TeX/ macros were made by \iindex {Knuth,/Donald} Donald Knuth, the author of \TeX. It is a
+{Plain \TeX/ macros were made by \iindex {Knuth,/Donald}Donald Knuth, the author of \TeX. It is a
set of basic macros and settings which is used (more or less) as a subset of
all other macro packages.}
were read, and `latex.fmt` is the format file dumped when \ii LaTeX/macros {\em \LaTeX/ macros} were read.
@@ -318,20 +337,19 @@ If you need to print these special characters you can use
\ii -percent,-at,-dollar,-hash
`\%`, `\&`, `\$`, `\#` or `\_`. These five control sequences are declared as
\"print this character" in all typical \TeX/ formats.
-Another possibility is to use a verbatim environment (it depends on the used format)
+Another possibility is to use a verbatim environment (it depends on the used format).
Last alternative: you can use \i csstring {\let\,=\relax`\csstring\<character>`}
-in Lua\TeX/, because Lua\TeX/ disposes
-with the primitive command `\csstring` which converts `\<character>`
+in Lua\TeX/, because it has
+the primitive command `\csstring` which converts `\<character>`
to `<character>`\c{12}.
The \ii active/character \"active character\c{13}"
can be declared by \i catcode `\catcode`\code{`}`\<character>=13`.
-Such a `<character>` behaves like a `<control sequence>`. For example, you can
+Such a `<character>` behaves like a control sequence. For example, you can
define it by
-\i def `\def<character>{...}`.
-If a `<control sequence>` is
-listed in this document, the active character is meant too.
-{\emergencystretch=2em\par}
+\i def `\def<character>{...}` and use this `<character>` as a macro.
+If the term `<control sequence>` is used in syntactical rules in this document
+then it means a real control sequence or an active character.
Each control sequence is built by the tokenizer starting from `\`\c0. Its name is
a continuous sequence of letters\c{11} finalized by the first non-letter.
@@ -341,7 +359,7 @@ Note that \OpTeX/ sets
You can look to such files and you will see many such characters inside
private control sequence names declared by \LaTeX/ macros.
-If the first character after `\`\c0 is not letter\c{\ne11}, then the control sequence is
+If the first character after `\`\c0 is non-letter (i.e.\ `<something>`\c{\ne11}), then the control sequence is
finalized with only this character in its name. So called
\ii one~character/control~sequence {\em one-character control sequence} is created. Other control sequences
are \ii multiletter/control~sequence {\em multiletter control sequences}.
@@ -458,8 +476,9 @@ The following primitive commands used in vertical mode start
horizontal mode: the first character of a paragraph (most common
situation) or \i indent `\indent`, \i noindent `\noindent`, \i hskip `\hskip`
(and its alternatives),
-\i vrule `\vrule`\fnote {The list is not fully completed, but most important commands
-are mentioned here.} and the plain \TeX/ macro \i leavevmode `\leavevmode`.
+\i vrule `\vrule` and the plain \TeX/ macro
+\i leavevmode `\leavevmode`\fnote {The list is not exhaustive, but most important commands
+are mentioned.}.
When horizontal mode is opened, an indentation of \i parindent `\parindent` width
is included. The exception is only if horizontal mode is started by
\i noindent `\noindent`; then the paragraph has no indentation.
@@ -748,7 +767,7 @@ example:
Note that there are two possibilities of how to write real macro
parameters when a macro is in use. The parameter is one token by default but
if there is `{<something>}` then the parameter is `<something>`. The braces
-here are delimiters for the real parameter (the \TeX/ group is not open/close
+here are delimiters for the real parameter (no \TeX/ group is opened/closed
here).
The example above shows a declaration of \ii unseparated/parameter,@ {\em unseparated parameters}. The
@@ -806,8 +825,8 @@ then the number of `#` must be doubled for inner declaration. Example:
\def\defmacro#1#2{%
\def#1##1 ##2 {##1 says: #1 ##2.}%
}
-\defmacro \hello {hello} % expands to \def\hello#1 #2 {#1 says: hello #2.}
-\defmacro \goobye {good bye}
+\defmacro \hello {hello} % expands to \def\hello#1 #2 {#1 says: hello #2.}
+\defmacro \goodbye {good bye}
\hello Jane Eric % expands to: Jane says: hello Eric.
\goodbye Eric John % expands to: Eric says: good bye John.
\endtt
@@ -962,7 +981,7 @@ type of the register (i.e.\ `<number>`, `<dimen>`, `<skip>` and `<toks>`) follow
`01234567`\,;
* {\let\,=\relax \code{`}`<character>`} (the prefix is the reverse single quote \code{`}).
It returns the code of the `<character>`. Examples:
- \code{`}`A` or one-character control sequence \code{`\\A}).
+ \code{`}{`|A;`} or one-character control sequence \code{`}{`|\A;`}).
Both examples represent the number 65. The Unicode of the character
is taken here if Lua\TeX/ or \XeTeX/ is used;
* \i numexpr `\numexpr<num. expression>`.\fnote
@@ -1077,7 +1096,7 @@ value given by plain \TeX/ follows.
by \x`\baselineskip` by default. The appropriate real glue is inserted
between the lines.
But if this real glue (between boxes) is less than \x`\lineskiplimit`
- then only \x`\lineskip` is inserted between the boxes.
+ then \x`\lineskip` is inserted between the boxes instead.
* \y`\topskip=10pt` is the distance between the top of the page box and the baseline of
the first line.
@@ -1101,7 +1120,8 @@ value given by plain \TeX/ follows.
and \x`\widowpenalty` (inserted before the last line of a paragraph). Typographical rules
often demand us to set these registers to 10000 (no page break is allowed here).
-* \y`\looseness=0` allows us to create of a \"suboptimal" paragraph. The page-building
+* \y`\looseness=0` allows us to create of a \"suboptimal" paragraph. The
+ paragraph building
algorithm tries to build the paragraph with \x`\looseness` lines more than
the optimal solution. If the {\noda\x`\tolerance`} does not have a sufficiently large value
then this setting is simply ignored. It is reset to zero after each
@@ -1225,6 +1245,9 @@ detail).
\sec[expand] Expandable primitive commands
+These commands are processed like macros, i.e.\ they expand to
+another sequence of tokens.
+
Notes about notation are in this and the following sections.
If the documented command is from the $\varepsilon$\TeX{} extension
(i.e.\ implemented in pdf\TeX, \XeTeX/
@@ -1277,7 +1300,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
Another example: a macro programmer should implement a key/value dictionary
using this primitive:
\begtt
-\def\keyval #1 #2 {\expandafter\def\csname dict:#1\endcsnme{#2}}
+\def\keyval #1 #2 {\expandafter\def\csname dict:#1\endcsname{#2}}
\def\value #1 {\csname dict:#1\endcsname}
\keyval Peter 21 % key=Peter, value=21, saved to the dictionary
% it does \def\dict:Peter{21}
@@ -1299,10 +1322,10 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
We need not define `\csname` by `\def`; we want to define
a `\dict:key`. The \x`\expandafter` helps here.
- The \z`<token 2>` should be another \x`\expandafter`. We can see
+ The \z`<token 2>` can be another \x`\expandafter`. We can see
\x`\expandafter` chains in many macro files. For example
- `\expandafter A\expandafter B\expandafter CD` is processed as
- \z`ABC<expanded D>`.
+ `\expandafter\A\expandafter\B\expandafter\C\D` is processed as
+ \z`\A \B \C <expanded>\D`.
The `/<expandafters>.`\z`{|<text>};` syntax rule enables us to prepare \z`|<text>;` by
`\expandafter`(s). For example \i detokenize `\detokenize{\macro}` expands to
@@ -1377,6 +1400,10 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
(or nothing if no `<else text>` is declared) when a branch with a given
`<number>` does not exist.
+* \*\i pdfstrcmp `\pdfstrcmp{<stringA>}{<stringB>}` returns $-1$ if
+ <stringA>$\string<$<stringB>, 0 if they are equal or 1 in other cases.
+ It is not implemented in \LuaTeX.
+
* \i noexpand `\noexpand|<token>;`.
The expand processor does not expand the `<token>` if it is expanding the
text in {\noda\x`\edef`, \x`\write`, \x`\message`} or similar lists.
@@ -1429,7 +1456,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
{\bf Commands used for declaration of control sequences}
\par\nobreak\medskip\nobreak
\begitems
-* \x`\def` \x`\edef` \x`\gdef` \x`\xdef` were documented in section~\ref[def].
+* \x`\def`, \x`\edef`, \x`\gdef`, \x`\xdef` were documented in section~\ref[def].
* \x`\long` is a prefix; it can be used before `\def`, `\edef`, `\gdef`, `\xdef`.
The declared macro accepts the control sequence `\par` in its parameters.
@@ -1497,6 +1524,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
processor. Typically \z`<token 1>` is a macro that needs to know the next token.
\enditems
+\goodbreak
\noindent {\bf Commands for box manipulation}
\begitems
@@ -1547,7 +1575,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
\ii box/register {\em box registers} addressed by `<box number>` and
accessed via \i box `\box<box number>` or alternatives described below.
The `\setbox` command saves the given `<box>` to the register addressed by
- `<box-number>`.
+ `<box number>`.
Macro programmers use only 0 to 9 \z`<box numbers>` directly. Other
addresses to box registers should be allocated by
@@ -2238,13 +2266,13 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
\nonum\sec[index] Index
-\iis LaTeX/macros {\LaTeX/ macros}
-\iis plain~TeX/macros {plain \TeX/ macros}
+\iis LaTeX/macros {\LaTeX{} macros}
+\iis plain~TeX/macros {plain \TeX{} macros}
\iis OpTeX {\OpTeX}
\iis pdfTeX {pdf\TeX}
\iis luaTeX {Lua\TeX}
\iis XeTeX {\XeTeX}
-\iis TeX/engines {\TeX/ engines}
+\iis TeX/engines {\TeX{} engines}
\iis -percent {{\code{\\\%}}}
\iis -at {{\code{\\\&}}}
\iis -dollar {{\code{\\\$}}}
@@ -2252,14 +2280,15 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
\iis -space {{\code{\\}{\tt\char9251}}}
\iis -italiccorr {{\code{\\/}}}
\iis -hyphen {{\code{\\-}}}
-\iis TeXlive {\TeX/live}
+\iis TeXlive {\TeX{}live}
\iis baselineskiprule {\code{\\baselineskip} rule}
\iis -comma {{\code{\\,}}}
\iis -greater {{\code{\\>}}}
\iis -column {{\code{\\;}}}
\iis -exclam {{\code{\\!}}}
+\iis plain~TeX {plain \TeX}
-{\let\Blue=\relax \typosize[9/11] \begmulti 3 \makeindex \endmulti}
+{\let\Blue=\relax \typosize[9/11] \preprocessindex \begmulti 3 \makeindex \endmulti }
\normalbottom
@@ -2268,7 +2297,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed.
\noindent
Petr Olšák {\tt petr@olsak.net}\nl
Czech Technical University in Prague\nl
-Version of the text: 0.7 (\the\year-\thed\month-\thed\day)
+Version of the text: 0.8 (\the\year-\thed\month-\thed\day)
\break