math-notdone.tex /size: 5303 b    last modification: 2024-01-16 10:21
1% language=us runpath=texruns:manuals/math
2
3\environment math-layout
4
5% goes to oddities
6
7\startcomponent math-notdone
8
9\startchapter[title=Why we don't do this]
10
11The \TEX\ engine has two math modes: inline and display. What exactly happens
12before we enter math depends on what mode we are in.
13
14\startitemize
15    \startitem
16        When we are in horizontal mode, single dollar signs makes us go into
17        inline math mode. Double dollars on the other hand trigger display math
18        and one of the first things that does is flush the current vertical list
19        contributions. As we are in horizontal mode it is likely that something
20        shows up.
21    \stopitem
22    \startitem
23        When we are in vertical mode the engine will trigger a new paragraph in
24        the hard way: the initial par state node gets added as well as the
25        indentation and everything that \type {\everypar} likes to inject. Inline
26        math then stays inline but display math starts out with flushing the
27        current paragraph and that happens to be the state, indentation and
28        everything else injected at the beginning. Often nothing is seen, just
29        an empty line sits there.
30    \stopitem
31    \startitem
32        In math mode the engine will check if we ended the right way and then
33        render and inject the formula.
34    \stopitem
35\stopitemize
36
37Especially the second case is tricky. The \quote {empty} line is placed with
38proper \typ {\parskip}, \typ {\parindent} and whatever. That can end up with a
39lot of supposedly whitespace of which is not really clear (for the user) what
40comes from where: interline space, whitespace, line height, display spacing, etc.
41To that you can add that empty lines are special themselves: in \MKII\ we relax
42\type {\par}, in \MKIV\ we setup {\LUATEX} to accept \type {\par} equivalents and
43\LUAMETATEX\ has no checks at all. \footnote {The same can be told about \type
44{\outer}.}
45
46Before we show some examples of this we have to make clear that \CONTEXT\ users
47don't have to worry about all this. We don't follow the (Plain and
48\LATEX) \AMS\ policy of \quotation {no empty lines before display math} and
49\quotation {no empty lines in display math}. We don't even use the display skip
50parameters and we do compensate for these empty line issues. The basics haven't
51changed between \MKII, \MKIV\ and \LMTX\ but it has become leaner and meaner deep
52down. We could actually remove display mode (not to be confused with \type
53{\displaystyle}) from the engine but then we could not show the examples below.
54
55\startbuffer[zero]
56\dorecurse{10}{test #1 }
57\startformula
58    x = \the\mathdisplayskipmode + \the\mathdisplaymode
59\stopformula
60\dorecurse{10}{test #1 }
61\stopbuffer
62
63\startbuffer[one]
64\dorecurse{10}{test #1 }       \par
65$$ x = \the\mathdisplayskipmode + \the\mathdisplaymode $$ \par
66\dorecurse{10}{test #1 }       \par
67\stopbuffer
68
69\startbuffer[two]
70\dorecurse{10}{test #1 }
71$$ x = \the\mathdisplayskipmode + \the\mathdisplaymode $$
72\dorecurse{10}{test #1 }
73\stopbuffer
74
75We use this as example:
76
77\typebuffer[one]
78
79as well as this:
80
81\typebuffer[two]
82
83In \CONTEXT\ one does this:
84
85\typebuffer[zero]
86
87and get:
88
89{\showmakeup[line] \getbuffer[zero]}
90
91% \predisplaysize
92
93For the examples with dollars we use this setup:
94
95\startbuffer[setup]
96\everypar              {!}
97\mathdisplaymode       0
98\normalizelinemode     0
99\parindent             30pt
100\parskip               40pt
101\abovedisplayskip      20pt
102\belowdisplayskip      \abovedisplayskip
103\abovedisplayshortskip \abovedisplayskip
104\belowdisplayshortskip \abovedisplayshortskip
105\stopbuffer
106
107\typebuffer[setup]
108
109We make sure that we get something typeset when we start a paragraph, just in
110order that we don't necessarily get empty lines: there can be many. The two modes
111make sure that we operate in regular \TEX\ mode, the way other macro packages do.
112
113First we show what we get with \typ {\mathdisplayskipmode 1}. This makes the
114engine behave like other engines. We don't show what we get with \typ
115{\mathdisplayskipmode 2} where zero skips are ignored but we don't have these.
116Last we show what we get with \typ {\mathdisplayskipmode 3}. Here the math
117specific skips are completely ignored.
118
119In both shown cases you will notice that the \type {\parskip} and \type
120{\baselineskip} interfere which in turn demonstrates why in \CONTEXT\ we always
121did things differently. It is possible to enhance the engine to deal with this
122but because in \CONTEXT\ we don't need it and because it is unlikely that other
123macro packages will use it no time will be wasted on this.
124
125\startbuffer
126\page
127\start
128\showmakeup[line]
129\getbuffer[setup,one,two]
130\stop
131\page
132\stopbuffer
133
134{\mathdisplayskipmode 1 \getbuffer}
135{\mathdisplayskipmode 3 \getbuffer}
136
137
138% \mathdisplaymode 0
139% before \par $$             \vadjust {\bf post 1} \vadjust {\bf post 2} x_2 \vadjust pre {\bf pre} $$ \par after \blank[3*line]
140% before \par $$             \vadjust {\bf post 1} \vadjust {\bf post 2} x_2 \vadjust pre {\bf pre} $$ \par after \blank[3*line]
141% before \par $              \vadjust {\bf post 1} \vadjust {\bf post 2} x_3 \vadjust pre {\bf pre} $  \par after \blank[3*line]
142% before \par $\displaystyle \vadjust {\bf post 1} \vadjust {\bf post 2} x_3 \vadjust pre {\bf pre} $  \par after \blank[3*line]
143
144\stopchapter
145
146\stopcomponent
147