能否有人通过手绘草图解释一下这四个值与 LuaTeX 命令\pagedir
、\bodydir
、\pardir
、\textdir
和相关的意义\mathdir
?\boxdir
答案1
正如问题下的评论中提到的,我去年在 luatex 列表中发布了一些内容,并附上了一些注释。为了避免人们从邮件存档中解压附件,我将在这里将其添加为纯 TeX。自从我起草此手册以来,手册已经进行了多次更新,因此可能需要在某些地方进行扩展/更正。
% Some attempt at describing luatex's direction commands
% David Carlisle
% You may copy, modify and use without restriction.
\catcode`\|\active
\def|#1|{{\tt\detokenize\expandafter{\string#1}}}
\suppressoutererror1
\beginsection Direction identifiers.
The luatex system distinguishes four different directions,
TLT, TRT, RTT, LTL.
The three letters in the name denote three aspects of the typesetting direction behavior.
\item 1
The direction towards the ``top'' of the paragraph
(that is, the start of the vertical mode direction)
is one of
T(top), L(left), R(right).
For English and Arabic, the beginning of the paragraph is T;
for Japanese it is R;
for Mongolian it is L.
\item 2
The direction towards the beginning of the line
(that is, the start of the horizontal mode direction)
is one of
T(top), L(left), R(right).
Defines where each line begins.
For English, it is L;
for Arabic, it is R;
for Japanese and Mongolian, it is T.
\item 3
The top of the glyphs within the line
is one of
T(top), L(left).
\bigskip
These result in the following typical settings:
TLT for English,
TRT for Arabic,
RTT for Japanese,
LTL for Mongolian.
\beginsection Direction registers.
The direction state is stored in five registers as listed below
\halign{&# \hfil\cr
page &|tex.pagedir|& |\pagedir|\cr
text &|tex.textdir|& |\textdir|, |\linedir|\cr
mathematics &|tex.mathdir|& |\mathdir|\cr
body &|tex.bodydir|& |\bodydir|\cr
paragraph &|tex.pardir|& |\pardir|\cr}
Each of these primitives takes as primitive one of the above four writing directions.
\item{|\pagedir|}
{\it
Can |\bodydir| be different to |\pagedir|? If it is different get warning
warning (backend):
pagedir differs from bodydir, the output may be placed wrongly on the page
\par}
\item{|\pardir|}
This defines the direction of the paragraph building.\par
In the default |\pagedir| TLT |\bodydir| TLT |\textdir| TLT then
TLT:
paragraph indentation left of first line, at top.
|\rightskip| fills from the right and |\parfillskip| fills the bottom line, from the right
TRT:
paragraph indentation left of first line, at top.
|\rightskip| fills from the left and |\parfillskip| fills the bottom line from the left,
LTL
paragraph indentation left of first line, at top.
|\rightskip| is a vertical skip after each line
RTT
paragraph indentation vertical above first line, at top.
|\rightskip| is a vertical skip after each line
\item{|\textdir|}
This primitive can appear anywhere in a text.
Grouping is respected, so it is possible to have inserts within a
paragraph.
The |\linedir| primitive sets the same text direction parameter but
with a modified positioning of the direction nodes with respect to white
space, which is convenient in some cases. Compare the two examples below.
|abc {\textdir TRT xyz \textdir TLT 123} abc|
abc {\textdir TRT xyz \textdir TLT 123} abc
|abc {\linedir TRT xyz \linedir TLT 123} abc|
abc {\linedir TRT xyz \linedir TLT 123} abc
Note how in the first case the space after |xyz| in the source
is affected by the direction and so ends up visually adjacent to the
space after |abc|, with no space visible between xyz and 123.
|\linedir| adjusts the position of inserted direction nodes relative
to adjacent space characters so that text runs remain separated by the
spaces.
\item{|\mathdir|}
Normally mathematics is done in the same direction as English, namely
TLT There have been situations where it has been written TRT.
TLT: left to right\par
TRT: Right to left\par
LTL: down with superscripts to the left\par
RTT: down with superscripts to the right\par
\beginsection Box directions
\item {|\boxdir|}
The |\boxdir| primitive allows the direction of a previously
constructed box register to be altered.
For example:
|\newbox\bxA|\par
|\setbox\bxA\hbox{abc}|\par
|1 \box\bxA\ 2 \boxdir\bxA TRT\ box\bxA|
Produces
% 1 abc 2 cba
\newbox\bxA
\setbox\bxA\hbox{abc}
1 \copy\bxA\ 2 \boxdir\bxA TRT\ \copy\bxA
Note that this only specifies the initial direction, any direction
nodes that were saved in the box are retained with their original values.
|\newbox\bxB|\par
|\setbox\bxB\hbox{\textdir TLT abc}|\par
|1 \copy\bxB\ 2 \boxdir\bxB TRT\ \copy\bxB|
Produces
% 1 abc 2 abc
\newbox\bxB
\setbox\bxB\hbox{\textdir TLT abc}
1 \copy\bxB\ 2 \boxdir\bxB TRT\ \copy\bxB
\beginsection Direction nodes
to be added\dots
\beginsection balancing the direction stack.
Something about how dirction nodes are constructed to add |+| or |-|
prefixed direction nodes to generate a balanced stack for the back end
processing\dots
\beginsection |local_par| nodes
Perhaps, add something, as far as they relate to directionality\dots
\beginsection Paragraph Shape.
Something about |\parshape| and |\shapemode| to be added\dots
\bye