TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

Over/Underbrackets
TUG logo

Main page

Index
UK FAQ
Documentation
Software
CTAN
Search CTAN:

Statistics

Google c.t.t.

Google d.c.t.t.

 


 


Copy the following LaTeX-code and put it in your preamble or load the example:

\def\underbracket{%
  \@ifnextchar [ %
    {\@underbracket}%
    {\@underbracket [\@bracketheight]}}
\def\@underbracket[#1]{%
  \@ifnextchar [ %
    {\@under@bracket[#1]}%
    {\@under@bracket[#1][0.4em]}}
\def\@under@bracket[#1][#2]#3{%\message {Underbracket: #1,#2,#3}
  \mathop {%
    \vtop {%
      \m@th \ialign {%
	##\crcr $\hfil \displaystyle {#3}\hfil $%
       \crcr \noalign %
       {\kern 3\p@ \nointerlineskip }%
	\upbracketfill {#1}{#2}
       \crcr \noalign %
       {\kern 3\p@ }%
     }%
   }%
  }%
  \limits%
}
\def\upbracketfill#1#2{%
  $\m@th \setbox \z@ \hbox {$\braceld$}
  \edef\@bracketheight{\the\ht\z@}\bracketend{#1}{#2}
  \leaders \vrule \@height #1 \@depth \z@ \hfill 
  \leaders \vrule \@height #1 \@depth \z@ \hfill%
  \bracketend{#1}{#2}$%
}
\def\bracketend#1#2{\vrule height #2 width #1\relax}

the code for the overbracket is different and was send by Dorothea Bahns:

\def\overbracket{\@ifnextchar [ {\@overbracket} {\@overbracket
[\@bracketheight]}}
\def\@overbracket[#1]{\@ifnextchar [ {\@over@bracket[#1]}
{\@over@bracket[#1][0.3em]}}
\def\@over@bracket[#1][#2]#3{%\message {Overbracket: #1,#2,#3}
\mathop {\vbox {\m@th \ialign {##\crcr \noalign {\kern 3\p@
\nointerlineskip }\downbracketfill {#1}{#2}
                              \crcr \noalign {\kern 3\p@ }
                              \crcr  $\hfil \displaystyle {#3}\hfil $%
                              \crcr} }}\limits}
\def\downbracketfill#1#2{$\m@th \setbox \z@ \hbox {$\braceld$}
                  \edef\@bracketheight{\the\ht\z@}\downbracketend{#1}{#2}
                  \leaders \vrule \@height #1 \@depth \z@ \hfill
                  \leaders \vrule \@height #1 \@depth \z@ \hfill
\downbracketend{#1}{#2}$}
\def\downbracketend#1#2{\vrule depth #2 width #1\relax}
There is no difference in the examples. Replace "under" with "over" and you'll get nearly the same.

underbrace versus underbracket

  1. \underbrace{...} is an often used command:
    (1)
         

  2. Sometimes an underbracket is needed, which can be used in more ways than \underbrace{...} an example for \underbracket{...}:


use of \underbracket{...}

The \underbracket{...} command has two optional parameters:

  • the linethickness in any valid latex unit, e.g. 1pt
  • the height of the edgebrackets, e.g. 1em
using without any parameters gives the same values for thickness and height as predefined for the \underbrace-command.

textmath-mode

1. $\underbracket {foo\ bar}$
2. $\underbracket[2pt] {foo\ bar}$
3. $\underbracket[2pt] [1em] {foo\ bar}$

local time: Fri Apr 19 15:26:00 CEST 2024 ; file is: 1756.9965625 days old
contact webmaster _at_ TeXnik.de