Annotation of ttbar/p20_taujets_note/ltabptch.sty, revision 1.1.1.1
1.1 uid12904 1: %% LTabPtch.sty---Uwe L"uck---patch for Longtable.
2: \def\filedate{2005/01/10} \def\fileversion{1.74d}
3: %% For David Carlisle's Longtable.sty, version 4.11
4: %% Fixes tools/3180 (Sebastian Rahtz) and tools/3485:
5: %% missing/wrong interline glues above/below table.
6: %%
7: %% Copyright (C) 2002--2004 Uwe L"uck,
8: %% http://www.contact-ednotes.sty.de.vu
9: %% --author-maintained.
10: %%
11: %% Usage, no warranty, distribution as in lppl.txt on CTAN
12: %% (macros/latex/base/lppl.txt).
13: %%
14: %% Loading Longtable.sty with options must be done earlier!
15: %%
16: \NeedsTeXFormat{LaTeX2e}[1994/05/20] % \CheckCommand
17: \ProvidesPackage{ltabptch}[\filedate\space v\fileversion\space
18: Longtable patch for tools/3180, 3485 (ul)]
19: %
20: % The problem(s):
21: % Sebastian Rahtz (tools/3180) observed 2000/03/05 that there be
22: % a "spurios blank line" below the longtable. This impression
23: % may have been due to two spacing problems:
24: % (1) There is \parskip and some interline glue below longtable,
25: % while there is no \parskip and no interline glue above
26: % (without head as specified by \endhead or \firstendhead)
27: % or just \lineskip 0.0pt (with head---\endhead, \endfirsthead).
28: % (2) After longtable, \prevdepth is the depth of the last line
29: % before the longtable (if there is no head) or the depth of the
30: % head (otherwise). So \prevdepth may be 0pt. By contrast, the
31: % last table row has depth of at least \dp\@arstrutbox--which
32: % should rather matter, and this is 3.6pt or more.
33: % --I have reported something like this as tools/3485, not
34: % entirely correctly. Details are presented below \endinput.
35: %
36: % Solution presented:
37: % (1) I think there should be \parskip and usual interline glue
38: % above, since the same would happen with a table in a center
39: % environment (e.g.).
40: % \noindent seems to work fatally; moreover, \LT@start's decision
41: % whether to enter a new page would ignore \parskip and interline
42: % glue still needed.
43: % So emulate interline glue calculation according to TeXbook p. 80
44: % and add it by \vskip, along with \parskip.
45: % (This is rather a hack---a proper correction should perhaps not
46: % "emulate" but place the interlineglue changes of \LT@array inside
47: % the \vbox \LT@bchunk starts and treat glue between chunks in a
48: % new way.)
49: % (2) Set \prevdepth to depth of box 0 before the latter is
50: % \unvbox'ed (which leaves \prevdepth untouched, TeXbook p. 282)
51: % in \endlongtable.
52: %
53: % I thought David Carlisle would change Longtable according to my
54: % suggestions. By e-mail from 2003/04/07 however, he finds it
55: % better not to change Longtable, in order not to change layouts
56: % of works that have been made using Longtable so far
57: % (e-Mail 2003/04/08).
58: %
59: %% <- TODO: change this when David has changed his mind!
60: % By the way:
61: % 1.) There are two successive lines in the Longtable code (v4.11)
62: % together saying:
63: % \prevdepth\z@\global
64: % \global\let\LT@setprevdepth\relax
65: % Isn't the first \global just a typo?
66: % --Yes--this is David Carlisle's answer in his e-mail
67: % dating from 2004/05/14.
68: % 2.) Couldn't the one-column restriction easily be removed
69: % by using \columnwidth instead of \hsize?
70: %
71: % Patching is to override Longtable.sty:
72: \RequirePackage{longtable}[2004/02/01]
73: %% TODO: Cf. \CheckCommand below.
74: % Load earlier on your own for choosing Longtable options!
75: %
76: % For (1), we are patching \LT@start, assumed to have been defined
77: % as follows (Longtable v4.11; sorry we can no longer handle v3.16
78: % through 4.10):
79:
80: \CheckCommand*{\LT@start}{%
81: \let\LT@start\endgraf
82: \endgraf\penalty\z@\vskip\LTpre
83: \dimen@\pagetotal
84: \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
85: \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
86: \advance\dimen@ \ht\LT@foot
87: \dimen@ii\vfuzz
88: \vfuzz\maxdimen
89: \setbox\tw@\copy\z@
90: \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
91: \setbox\tw@\vbox{\unvbox\tw@}%
92: \vfuzz\dimen@ii
93: \advance\dimen@ \ht
94: \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
95: \advance\dimen@\dp
96: \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
97: \advance\dimen@ -\pagegoal
98: \ifdim \dimen@>\z@\vfil\break\fi
99: \global\@colroom\@colht
100: \ifvoid\LT@foot\else
101: \advance\vsize-\ht\LT@foot
102: \global\advance\@colroom-\ht\LT@foot
103: \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
104: \maxdepth\z@
105: \fi
106: \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
107: %% \nobreak new with Longtable v4.11.
108: \output{\LT@output}}
109: %
110: % Change it:
111: \def\LT@start{%
112: \let\LT@start\endgraf
113: \endgraf\penalty\z@\vskip\LTpre
114: \vskip\parskip %% U.L.
115: % I want to add the interline glue before \pagetotal goes to \dimen@.
116: % So I move \LT@start's \vsplit here.
117: %% U.L. start:
118: \dimen@ii\vfuzz
119: \vfuzz\maxdimen
120: \setbox\tw@\copy\z@
121: \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
122: \setbox\tw@\vbox{\unvbox\tw@}%
123: \vfuzz\dimen@ii
124: \ifdim\prevdepth>-\@m\p@
125: % First we need the maximum of the heights of \tw@ and head row.
126: % A little flaw might be here: I am ignoring \Lt@start's
127: % \@arstrutbox concern below, cf. remark there.
128: \@tempskipa % \normalbaselineskip going to enter.
129: \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
130: % \typeout{\@tempskipa=\the\@tempskipa}% TEST
131: \@tempskipa-\ifdim\@tempskipa<\ht\tw@\ht\tw@\else\@tempskipa\fi
132: % \typeout{\@tempskipa=\the\@tempskipa}% TEST
133: \advance\@tempskipa-\prevdepth
134: % \typeout{\string\prevdepth=\prevdepth}% TEST
135: % \typeout{\@tempskipa=\the\@tempskipa}% TEST
136: \advance\@tempskipa\normalbaselineskip
137: % \typeout{\normallineskiplimit=\the\normallineskiplimit}% TEST
138: % \typeout{\@tempskipa=\the\@tempskipa}% TEST
139: \vskip \ifdim\@tempskipa<\normallineskiplimit
140: \normallineskip
141: \else
142: \@tempskipa
143: \fi
144: \fi
145: \nointerlineskip % v1.4 prevent head from adding more
146: % % (if only negative) glue.
147: % \prevdepth -1000\p@ % Prevent head from adding more glue (v1.3).
148: %% U.L. end.
149: \dimen@\pagetotal
150: \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
151: \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
152: \advance\dimen@ \ht\LT@foot
153: % \dimen@ii\vfuzz
154: % \vfuzz\maxdimen
155: % \setbox\tw@\copy\z@
156: % \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
157: % \setbox\tw@\vbox{\unvbox\tw@}%
158: % \vfuzz\dimen@ii
159: %
160: % Remark U.L.: The following four code lines seem strange to me:
161: % after all, \tw@ contains \@arstrutbox, doesn't it?
162: % And even if not: why should we need room for another \@arstrutbox?
163: \advance\dimen@ \ht
164: \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
165: \advance\dimen@\dp
166: \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
167: \advance\dimen@ -\pagegoal
168: \ifdim \dimen@>\z@\vfil\break\fi
169: \global\@colroom\@colht
170: \ifvoid\LT@foot\else
171: \advance\vsize-\ht\LT@foot
172: \global\advance\@colroom-\ht\LT@foot
173: \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
174: \maxdepth\z@
175: \fi
176: \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
177: %% \nobreak new with Longtable 4.11.
178: \output{\LT@output}}
179: %
180: %
181: % For (2), we are patching \endlongtable:
182: % The patch should not change essentials of \endlongtable
183: % which may have changed when this patch meets longtable.
184: % We just assume that the final contribution to the main vertical
185: % list is done by \unvbox0 which is preceded by \LT@start.
186: % \prevdepth\dp0 can be put in between, it will then
187: % last till the end (TeXbook pp. 282, 277f.).
188: \def\@tempa#1\LT@start{#1\LT@start \prevdepth\dp\z@}
189: \expandafter\expandafter\expandafter \def
190: \expandafter\expandafter\expandafter \endlongtable
191: \expandafter\expandafter\expandafter
192: {\expandafter\@tempa\endlongtable}
193: %
194: \endinput
195:
196: DETAILED DIAGNOSIS:
197:
198: Concerning the question of "bugs" vs. "features", you might
199: reason what features should be aimed at.
200:
201: %% TODO: This can be shortened when David agrees.
202:
203: (A) If there is \parskip below a longtable, there should
204: be \parskip above as well--shouldn't it?
205: (B) Interline glue above should (in general) depend on the
206: same values of \baselineskip and \lineskip as below---OK?
207: (C) Interline glue below a longtable should depend on the
208: depth of the last row, not on the depth of the head or of the
209: last line above the longtable--OK?
210:
211: The recent versions of longtable.sty have not satisfied any
212: of these three demands.
213: Concerning (A), \parskip appears below the longtable, but not
214: above.
215: Concerning (B), (i) no interline glue appears above if there
216: is no head, (ii) otherwise, only zero interline glue appears.
217: Concerning (C), the interline glue below the longtable is
218: calculated using the depth of (i) the last line above the
219: longtable as \prevdepth when there is no head or of (ii) the
220: head otherwise. (Thus I was wrong earlier when I claimed that
221: \prevdepth were 0pt after longtable. This only holds in the
222: previous case (i) when the last line above the longtable has
223: zero depth.)
224:
225: You can observe this by playing with the demonstration file
226: ltabptch.tex in CTAN folder macros/latex/contrib/ltabptch.
227:
228: Reasons: For contributing a head to the main vertical list,
229: longtable uses \copy or \box, which yields a <box> according
230: to TeXbook p. 278. Rows are contributed by \unvbox. Now,
231: violation of (A) is due to the fact that neither \copy or
232: \box of the head nor the \unvbox for table rows leads to
233: execution of an \indent or \noindent (TeXbook pp. 282f., see
234: also <horizontal command>).
235: Violation of (B) is due either to (i) the fact that \unvbox
236: is no <box> (TeXbook p. 282/278) or to (ii) the fact that at
237: \copy or \box \baselineskip and \lineskip are 0pt.
238: Violation of (C) is due to the fact that \unvbox does not
239: change \prevdepth (TeXbook p. 282).
240:
241: As to recognizable effects:
242: Violation of (A), of course, has very little effect in
243: general since \parskip is 0pt plus 1pt usually. This is hardly
244: recognizable in the presence of the \bigskipamount above and
245: below a longtable.
246: Violation of (B) results in missing appropriate interline
247: glue above, which often should be 3.6pt or more. This may
248: rather be recognizable and may contribute to the impression
249: that there even is a spurious blank line below the longtable
250: (this is what Sebastion Rahtz reported in tools/3180).
251: For the previous as well as for the details and the
252: effects of violation of (C), consider the algorithm for
253: calculating interline glue on p. 80 of the TeXbook. If there
254: is no head, and the depth of the last line before the
255: longtable is 0pt, the interline glue below the longtable is
256: \baselineskip minus the height of the first line after the
257: longtable. The interline glue *should be* \baselineskip minus
258: height of following line *minus* depth of last table row--if
259: this depth is not too large (depending on \lineskiplimit).
260: This depth is at least 3.6pt. So the interline glue is often
261: by 3.6pt or more greater than is appropriate. Considering the
262: missing interline glue above the longtable and the \parskip
263: below, the glue after the longtable is by 6.2pt (or more) plus
264: 1pt larger than the glue before. Due to the shrink component
265: of the surrounding \bigskipamount, the glue following the
266: longtable may be nearly twice as large as the glue before.
267: ---Usually, violation of (C) has no effect at all. Namely,
268: there is a head usually, and its depth is usually the same as
269: the depth of the last row, namely \dp\@arstrutbox.
270:
271:
272: %% VERSION HISTORY:
273: v1.7 2003/01/07 Sent around 2003/01/13 with first release of
274: ednotes.sty. Sent to David Carlisle. Earlier versions
275: were sent to Frank Mittelbach and the team.
276: v1.71 2003/01/22 Added version history.
277: v1.72 2003/01/27 Changed copyright notice.
278: v1.73 2004/05/13 Adapted to Longtable v4.11; new copyright;
279: longtable -> Longtable (selectively).
280: Added `I have ... 3485'.
281: v1.74 2004/08/05 Added `---Yes---...'.
282: 2004/08/21 Typo fix for `problem'; added report on 2003/04/08.
283: 2004/08/23 Corrected and extended diagnosis, sent to CTAN.
284: v1.74b .../08/23 `---' -> `--'; added that (C) usually doesn't
285: matter.
286: v1.74c .../08/31 `author-maintained'.
287: v1.74d 2005/01/10 Contact via http.
288:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>