summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ltxmisc/oubraces.sty
blob: ebe2a41036996c6b72e476c7284a27ed43a3ab43 (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
% oubraces.sty: Interleave \overbrace with \underbrace
%                Donald Arseneau, 1993
%
% \overunderbraces{upper_braces}{main_formula}{lower_braces}
%
% Instructions are given below, after \endinput.
%
%  First, set catcode of @ in case it isn't a "letter" already
\expandafter\edef\csname REST@catcode\endcsname
  {\catcode`\noexpand\@=\the\catcode`\@
  \let \csname SREST@catcode\endcsname \noexpand\UnDefinedButNoAt}
\catcode`\@=11

\def\overunderbraces #1#2#3{{%
 \baselineskip\z@skip \lineskip4\p@ \lineskiplimit4\p@
 \displaystyle % deliberately generate error if not in math mode!
% first, do the top half of the alignment in a save-box ...
 \setbox\z@\vbox{\ialign{&\hfil${}##{}$\hfil\cr
   \global\let\br\br@label #1\cr % upper labels
   \global\let\br\br@down #1\cr  % upper braces
   #2\cr % main line of the formula
 }}% finished partial alignment and \vbox.
 \dimen@-\ht\z@ %   Measure height of partial alignment --
% ... it is the height we want for the whole.
% Now do the whole alignment (notice the repetition from above)
 \setbox\z@\vbox{\ialign{&\hfil${}##{}$\hfil\cr
   \global\let\br\br@label #1\cr % upper labels
   \global\let\br\br@down #1\cr  % upper braces
   #2\cr % main line of the formula
   \global\let\br\br@up #3\cr    % lower braces
   \global\let\br\br@label #3\cr % lower labels
 }}% finished whole alignment and \vbox.
 \advance\dimen@\ht\z@ % calc. the necessary lowering
 \lower\dimen@\hbox{\box\z@}% shift to get the desired height
}}

% Three aliases for \br.
% #1=number of spanned columns,  #2=label
\def\br@up#1#2{\multispan{#1}\upbracefill}
\def\br@down#1#2{\multispan{#1}\downbracefill}
\def\br@label#1#2{\multispan{#1}\hidewidth $#2$\hidewidth}

\REST@catcode

\endinput
%
%-----------------------------------------------------------------
%
% oubraces.sty: Interleave \overbrace with \underbrace
%                Donald Arseneau, 1993
%
% The syntax is:
%
%   \overunderbraces{upper_braces}{main_formula}{lower_braces}
%
% Suppose we want the equation:
%                x               y
%          ,-----^-----.   ,-----^-----.
%  a + b + c + d + e + f + g + h + i + j + k + l + m = \pi r^2
%                  `-----v-----'
%                        z
% There are seven segments:
%                x               y
%          ,-----^-----.   ,-----^-----.
%  a + b + c + d + e + f + g + h + i + j + k + l + m = \pi r^2
%  11111111222222223333344455555666666667777777777...
%                  `-----v-----'
%                        z
% Insert & between each segment (where the tips of the braces point)
% to type the main_formula:
%                x               y
%          ,-----^-----.   ,-----^-----.
%  a + b +&c + d +&e + f&+&g + h&+ i + j&+ k + l + m
%                  `-----v-----'
%                        z
% Each brace should be specified by typing
%
%    \br{number_of_segments}{label},
%
% separated by  &  to indicate which segment to start at; and
% where  & &  skips a segment that has no brace.  For our
% example formula, the upper and lower brace specifiers are:
%
% top row:  &\br{2}{x}& &\br{2}{y}
% bot row:  & &\br{3}{z}
%
% Now put them all together:
%
% \overunderbraces{&\br{2}{x}& &\br{2}{y}}%
%    {a + b +&c + d +&e + f&+&g + h&+ i + j&+ k + l + m}%
%    {& &\br{3}{z}}
%  = \pi r^2