summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/oubraces/oubraces.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/oubraces/oubraces.sty
Initial commit
Diffstat (limited to 'macros/latex/contrib/oubraces/oubraces.sty')
-rw-r--r--macros/latex/contrib/oubraces/oubraces.sty92
1 files changed, 92 insertions, 0 deletions
diff --git a/macros/latex/contrib/oubraces/oubraces.sty b/macros/latex/contrib/oubraces/oubraces.sty
new file mode 100644
index 0000000000..e5adc2282a
--- /dev/null
+++ b/macros/latex/contrib/oubraces/oubraces.sty
@@ -0,0 +1,92 @@
+% oubraces.sty: Interleave \overbrace with \underbrace
+%
+% \overunderbraces{upper_braces}{main_formula}{lower_braces}
+%
+% Instructions are given below, after \endinput, and in oubraces.tex (.pdf)
+%
+% Copyright 1993,2011 Donald Arseneau, Vancouver, Canada
+%
+% Redistribution and use, with or without modification, are permitted provided
+% that the above copyright notice and this condition for use are retained.
+
+\begingroup
+\catcode`\@=\catcode`A
+\gdef\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
+% \noalign{\kern2\p@}% % because
+ \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
+\gdef\br@up#1#2{\multispan{#1}\upbracefill}
+\gdef\br@down#1#2{\multispan{#1}\downbracefill}
+\gdef\br@label#1#2{\multispan{#1}\hidewidth $\scriptstyle {#2}$\hidewidth}
+
+\endgroup
+\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