summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/tabbingbox.tex
blob: e7e25b22cbc5aa21e04ef91789bdd4699bd200ca (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
% -*- Mode: TeX -*-

\ifx\thisfileis\anUndefinedMacro\input maybeload \fi

\thisfileis{<eb.tex.texlocal>tabbingbox} % abort loading if already loaded

\input redefine % from texlocal

% TABBING BOXES (LaTex)
%
% The \begin{tabbingbox}...\end{tabbingbox} environment saves
% a tabbing environment in a box.  This is one way to make a
% box out of a bunch of lines and have the width of the
% box be equal to the width of the longest line.  Naturally,
% tabbing commands are also available in the box, but they aren't
% used much.
%
% An optional position argument [t], [b], or [c] as for \parbox
% may be supplied.  The default is [t].
%
% A second optional argument [boxnumber] causes the box to be
% saved in the indicated box number, instead of being returned.
% Sample use of this form: \begin{tabbingbox}[b][0]...
%
% As a special feature, a [boxnumber] may have the form
% [G boxnumber] to indicate a global assignment.
%

\makeatletter

\newbox\@tabbingboxbox

\def\tabbingbox{\@ifnextchar[{\@argXtabbingbox}%]
{\let\@tabboxnum\@tabbingboxbox\@tabbingbox[t]}}

\def\@argXtabbingbox[#1]{\@ifnextchar
   [{\@argYtabbingbox[#1]}{\let\@tabboxnum\@tabbingboxbox
                           \@tabbingbox[#1]}%]
}

\def\@argYtabbingbox[#1][#2]{\def\@tabboxnum{#2}\@tabbingbox[#1]}

\def\@tabbingbox[#1]{\global\setbox\@tabbingboxbox
  \hbox\bgroup\begingroup\minipage[#1]{\z@}\begingroup\tabbing}

% The weird stuff with \unvbox below patches up a [b]-positioned
% box, which for some reason gets final glue of zero that causes
% the vbox to have zero depth and get positioned funny.

\def\endtabbingbox{\global\@minipagetrue\endtabbing\endgroup
    \endminipage
    \setbox\@tempboxa\lastbox
    \ifdim \dp\@tempboxa=\z@
       \vbox{\unvbox\@tempboxa\unskip}\else\box\@tempboxa\fi
    \global\@minipagefalse\endgroup
    \egroup
    \ifx\@tabboxnum\@tabbingboxbox\box\@tabboxnum
    \else
    \xdef\@snarftabbingbox
       {\if G\expandafter\@car\@tabboxnum\@nil\relax
            \global\setbox\expandafter\@cdr\@tabboxnum\relax\@nil
            \else
            \setbox\@tabboxnum\fi\box\@tabbingboxbox
       }\aftergroup\@snarftabbingbox
    \fi}

%\def\endtabbingbox{\global\@minipagetrue\endtabbing\endgroup
%    \endminipage\unskip\endgroup\egroup\global\@minipagefalse
%    \ifx\@tabboxnum\@tabbingboxbox\box\@tabboxnum
%    \else
%    \xdef\@snarftabbingbox
%       {\if G\expandafter\@car\@tabboxnum\@nil\relax
%           \global\setbox\expandafter\@cdr\@tabboxnum\relax\@nil
%           \else
%           \setbox\@tabboxnum\fi\box\@tabbingboxbox
%       }\aftergroup\@snarftabbingbox
%    \fi}

\makeatother