summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/mh/breqn-technotes.tex
blob: e8c6174cbbff250cb414ff5961493074094b880d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
\documentclass{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{breqn}
\def\eqnumside{L}
\providecommand*\cs[1]{\texttt{\textbackslash#1}}

\usepackage{hyperref}

\title{Technical notes on equation breaking}
\author{Michael J.\ Downes \and Morten H\o gholm}
\begin{document}

\maketitle


\section{Tag placement}

The method used by the breqn package to place the equation number is
rather more complicated than you might think, and the whole reason is
to allow the number to stay properly centered on the total height even
when the height fluctuates due to stretching or shrinking of the page.


Consider the following equation: 
\begin{dmath}[number={3.15}]
  N_{0} \simeq \left( \frac{\nu}{\lVert u\rVert_{H^{i}}} \right) 
  \lvert I\rvert^{-1/2}
\end{dmath}
It will have only one line, if the column width is not too narrow. 

Scrutinizing the vertical list will shed light on some of the basic properties 
shared by all breqn equations. After that we will look at what would happen if 
two or more lines were needed. The numbers added on the left in the following 
\cs{showlists} output mark the points of interest. 
\begin{verbatim}
[1] \penalty 10000 
    \glue(\abovedisplayskip) 0.0 
    \penalty 10000 
    \glue(\belowdisplayskip) 0.0 
[2] \glue 4.0 plus 4.0 
    \glue(\lineskip) 1.0 
[3] \vbox(16.53902+0.0)x0.0, glue set 16.53902fil 
    .\glue 0.0 plus 1.0fil minus 1.0fil 
    \penalty 10000 
[4] \glue -8.51945 
[5] \hbox(7.5+2.5)x25.55563 
    .\OT1/cmr/m/n/10 ( 
    .\OT1/cmr/m/n/10 3 
    .\OT1/cmr/m/n/10 . 
    .\OT1/cmr/m/n/10 1 
    .\OT1/cmr/m/n/10 5 
    .\kern 0.0 
    .\OT1/cmr/m/n/10 ) 
    \penalty 10000 
[6] \glue(\parskip) -18.01956 
[7] \hbox(16.53902+9.50012)x360.0, glue set 1.78647 
\end{verbatim}
\begin{enumerate}
\item These four lines are a hidden display structure from \TeX's
  primitive \texttt{\$\$} mechanism. It is used only to get the value
  of \cs{predisplaysize} so that we can later calculate by hand
  whether to use the short display skips or the regular ones. (The
  reason that we have to do it by hand traces back to the fact that
  \TeX\ 3.x does not allow unhboxing in math mode.) The penalties come
  from \cs{predisplaypenalty} and \cs{postdisplaypenalty}, which were
  locally set to 10000 to ensure there would be no unintended page
  breaks at these glue nodes.

\item These two glue nodes are the ones that would normally have been
  produced at the top of a display; the first one is the above-display
  skip node (though we had to put it in by hand with \cs{vskip}) and
  the second one is the usual baselineskip/lineskip node.

\item This is a dummy copy of the equation's first line, which is
  thrown in here to get the proper value of baselineskip (or lineskip
  in this case). Why do we need this? Because this ensures that we get
  the top spacing right before we fiddle with the glue nodes
  surrounding the equation number. And if the equation has a frame,
  this box is a good place to add it from.

\item This is a special glue node that brings us to the right vertical
  position for adding the equation number. Its value is calculated
  from the variables that you would expect, given the presence of the
  dummy first line above the num- ber: starting position of the
  equation, height of first line, total height of equation body. If
  the equation body had more than one line, with stretchable glue
  between the lines, half of the stretch would be added in this glue
  node.

\item The hbox containing the equation number.

\item Backspace to bring the equation body to the right starting point. We use 
  \cs{parskip} to put this glue in place because we're going to get a
  parskip node here in any case when we add the equation body with (in
  essence). If we didn't do this we'd get two glue nodes instead of
  one, to no purpose.

\cs{\noindent} \cs{unhbox}\cs{EQ@box}.


\item And lastly we see here the first line of the equation body,
  which appears to have height 16.5pt and depth 9.5pt.
\end{enumerate}

For comparison, the vertical list produced from the above equation in
standard \LaTeX\ would look like this, if the same values of
columnwidth and abovedisplayskip are used:
\begin{verbatim}
[1] \penalty 10000 
[2] \glue(\abovedisplayskip) 4.0 plus 4.0 
    \glue(\lineskip) 1.0 
    \hbox(16.53902+9.50012)x232.94844 
[3] .\hbox(7.5+2.5)x25.55563 
    ..\hbox(7.5+2.5)x25.55563 
    ...\OT1/cmr/m/n/10 ( 
    ...\OT1/cmr/m/n/10 3 
    ...\OT1/cmr/m/n/10 . 
    ...\OT1/cmr/m/n/10 1 
    ...\OT1/cmr/m/n/10 5 
    ...\kern 0.0 
    ...\OT1/cmr/m/n/10 ) 
    .\kern101.49591 
[4] .\hbox(16.53902+9.50012)x105.8969 
    ... 
[5] \penalty 0 
[6] \glue(\belowdisplayskip) 4.0 plus 4.0 
    \glue(\lineskip) 1.0 
    \hbox(6.94444+1.94444)x345.0, glue set 62.1106fil
\end{verbatim}

\begin{enumerate}
  \item \cs{predisplaypenalty}
  \item \cs{abovedisplayskip} 
  \item  equation number box
  \item equation body 
  \item \cs{postdisplaypenaltly}  
  \item \cs{belowdisplayskip}
\end{enumerate}





\end{document}