Post by Joseph WrightPost by David KastrupIf you just need to know afterwards, you can put a \vadjust with some
sentinel material (like a box with known height) in each branch. When
the math ends, the right sentinel box will come out and can be collected
with \lastbox.
First: \lastbox is forbidden in math mode
Second: \mathchoice really evaluates (ie boxes) the 4 possibilities
Perhaps David might provide an example: I can't get it to work, but
then I've never used \vadjust before so am probably being thick.
Huh? Rather straightforward. Notice that all boxes get typeset, but
only the box with 0 in it escapes into the surrounding internal vertical
list.
plain TeX
\tracingall
\vbox{
$$\mathchoice{\vadjust{0}}{\vadjust{1}}{\vadjust{2}}{\vadjust{3}}$$
\par
\unskip\unpenalty
\setbox0\lastbox
\showbox0}
This is TeX, Version 3.1415926 (TeX Live 2010) (format=tex 2010.12.3) 20 JAN 2011 16:00
**\tracingall
*\vbox{
{\vbox}
{internal vertical mode: blank space }
*$$\mathchoice{\vadjust{0}}{\vadjust{1}}{\vadjust{2}}{\vadjust{3}}$$
{math shift character $}
{horizontal mode: math shift character $}
@firstpass
[]
@\par via @@0 b=0 p=-10000 d=100
@@1: line 1.2- t=100 -> @@0
{display math mode: \mathchoice}
{math mode: \vadjust}
{internal vertical mode: the character 0}
{horizontal mode: the character 0}
{end-group character }}
@firstpass
[]\tenrm 0
@\par via @@0 b=0 p=-10000 d=100
@@1: line 1.2- t=100 -> @@0
{math mode: end-group character }}
{\vadjust}
{internal vertical mode: the character 1}
{horizontal mode: the character 1}
{end-group character }}
@firstpass
[]\tenrm 1
@\par via @@0 b=0 p=-10000 d=100
@@1: line 1.2- t=100 -> @@0
{math mode: end-group character }}
{\vadjust}
{internal vertical mode: the character 2}
{horizontal mode: the character 2}
{end-group character }}
@firstpass
[]\tenrm 2
@\par via @@0 b=0 p=-10000 d=100
@@1: line 1.2- t=100 -> @@0
{math mode: end-group character }}
{\vadjust}
{internal vertical mode: the character 3}
{horizontal mode: the character 3}
{end-group character }}
@firstpass
[]\tenrm 3
@\par via @@0 b=0 p=-10000 d=100
@@1: line 1.2- t=100 -> @@0
{math mode: end-group character }}
{display math mode: math shift character $}
{restoring \displayindent=0.0pt}
{restoring \displaywidth=0.0pt}
{restoring \predisplaysize=0.0pt}
{restoring \fam=0}
*\par
{horizontal mode: \par}
*\unskip\unpenalty
{internal vertical mode: \unskip}
{\unpenalty}
*\setbox0\lastbox
{\setbox}
*\showbox0}
{\showbox}
\hbox(6.44444+0.0)x469.75499, glue set 444.75497fil
.\hbox(0.0+0.0)x20.0
.\tenrm 0
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0
! OK.
<to be read again>
}
<*> \showbox0}
?
{end-group character }}
{restoring \box0=
\hbox(0.0+6.00006)x8.75002 []}
%% goal height=643.20255, max depth=4.0
{vertical mode: blank space }
*\end
{\end}
% t=12.0 g=643.20255 b=10000 p=0 c=100000#
% t=12.0 plus 1.0fill g=643.20255 b=0 p=-1073741824 c=-1073741824#
\output->{\plainoutput }
\plainoutput ->\shipout \vbox {\makeheadline \pagebody \makefootline }\advancep
ageno \ifnum \outputpenalty >-\@MM \else \dosupereject \fi
{internal vertical mode: \shipout}
\makeheadline ->\vbox to\z@ {\vskip -22.5\p@ \line {\vbox to8.5\p@ {}\the \head
line }\vss }\nointerlineskip
{\vbox}
{\vskip}
\line ->\hbox to\hsize
{\hbox}
{restricted horizontal mode: \vbox}
{internal vertical mode: end-group character }}
{restricted horizontal mode: \the}
{\hfil}
{end-group character }}
{internal vertical mode: \vss}
{end-group character }}
\nointerlineskip ->\prevdepth -1000\p@
{\prevdepth}
\pagebody ->\vbox to\vsize {\boxmaxdepth \maxdepth \pagecontents }
{\vbox}
{\boxmaxdepth}
\pagecontents ->\ifvoid \topins \else \unvbox \topins \fi \dimen@ =\dp \@cclv \
unvbox \@cclv \ifvoid \footins \else \vskip \skip \footins \footnoterule \unvbo
x \footins \fi \***@ggedbottom \kern -\dimen@ \vfil \fi
{\ifvoid}
{true}
{\else}
{\dimen0}
{\unvbox}
{\ifvoid}
{true}
{\else}
{\iffalse}
{false}
{end-group character }}
{restoring \dimen0=0.0pt}
{restoring \boxmaxdepth=16383.99998pt}
\makefootline ->\baselineskip 24\p@ \lineskiplimit \z@ \line {\the \footline }
{\baselineskip}
{\lineskiplimit}
\line ->\hbox to\hsize
{\hbox}
{restricted horizontal mode: \the}
{\hss}
{select font cmr10}
\folio ->\ifnum \pageno <\z@ \romannumeral -\pageno \else \number \pageno \fi
{\ifnum}
{false}
{\number}
{the character 1}
{\fi}
{\hss}
{end-group character }}
{restoring current font=\tenrm}
{internal vertical mode: end-group character }}
{restoring \lineskiplimit=0.0pt}
{restoring \baselineskip=12.0pt}
Completed box being shipped out [1]
\vbox(667.20255+0.0)x469.75499
.\vbox(0.0+0.0)x469.75499, glue set 14.0fil
..\glue -22.5
..\hbox(8.5+0.0)x469.75499, glue set 469.75499fil
...\vbox(8.5+0.0)x0.0
...\glue 0.0 plus 1.0fil
..\glue 0.0 plus 1.0fil minus 1.0fil
.\vbox(643.20255+0.0)x469.75499, glue set 631.20255fill
..\glue(\topskip) 0.0
..\vbox(12.0+0.0)x469.75499
...\hbox(0.0+0.0)x469.75499, glue set 449.75499fil
....\hbox(0.0+0.0)x20.0
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\penalty 10000
...\glue(\abovedisplayshortskip) 0.0 plus 3.0
...\glue(\baselineskip) 12.0
...\hbox(0.0+0.0)x0.0, shifted 234.8775
..\hbox(0.0+0.0)x469.75499
..\glue 0.0 plus 1.0fill
.\glue(\baselineskip) 17.55556
.\hbox(6.44444+0.0)x469.75499, glue set 232.37749fil
..\glue 0.0 plus 1.0fil minus 1.0fil
..\tenrm 1
..\glue 0.0 plus 1.0fil minus 1.0fil
Memory usage before: 233&4880; after: 112&4879; still untouched: 2994092
\advancepageno ->\ifnum \pageno <\z@ \global \advance \pageno \***@ne \else \glob
al \advance \pageno \@ne \fi
{\ifnum}
{false}
{\global}
{\fi}
{\ifnum}
{false}
\dosupereject ->\ifnum \insertpenalties >\z@ \line {}\kern -\topskip \nobreak \
vfill \supereject \fi
{\ifnum}
{false}
{\fi}
{end-group character }}
{vertical mode: \end}
Here is how much of TeX's memory you used:
2 strings out of 497974
20 string characters out of 3220722
5908 words of memory out of 3000000
926 multiletter control sequences out of 15000+200000
14794 words of font info for 50 fonts, out of 3000000 for 9000
14 hyphenation exceptions out of 8191
6i,4n,0p,69b,22s stack positions out of 5000i,500n,10000p,200000b,50000s
Output written on texput.dvi (1 page, 208 bytes).
--
David Kastrup
UKTUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>