\documentclass{article}
\usepackage{graphicx}
%\newcommand\myLineThickness{0.3pt}
%
\makeatletter
\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}


\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}
\makeatother
\begin{document}
\section{overbracket-demo}
\begin{enumerate}
\item \verb/\underbrace{...}/ is an often used command:
\begin{eqnarray}
\underbrace{{x^{2}+2x+1}} & = & f(x)\\
\left(x+1\right)^{2}\,\,\,\nonumber 
\end{eqnarray}

\item Sometimes an under\textbf{bracket} is needed, which can be used in
more ways than \verb/\underbrace{...}/
an example for \verb/\underbracket{...}/:


\begin{eqnarray*}
\textrm{Hate Science  }& \underbracket[0.5pt]{1\rightarrow2\rightarrow3\rightarrow4}
    \underbracket[0.75pt][0.75em]{\rightarrow5\rightarrow6\rightarrow7}
    \underbracket[1pt][1em]{\rightarrow8\rightarrow9\rightarrow10} & \textrm{Love Science}\\
 & \textrm{low}\hspace{1.5cm}\textrm{medium}\hspace{1.5cm}\textrm{high}
 \end{eqnarray*}


\end{enumerate}

\subsection*{use of \texttt{\textbackslash{}underbracket\{...\}}}

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

\begin{itemize}
\item the linethickness in any valid latex unit, e.g. \verb/1pt/
\item the height of the edgebrackets, e.g. \verb/1em/
\end{itemize}
using without any parameters gives the same values for thickness and
height as predefined for the \verb/\underbrace/-command.


\subsubsection*{textmath-mode}

\vspace{0.3cm}
\begin{center}
\begin{tabular}{|c|c|c|}
\hline 
1.&
\verb/$\underbracket {foo\ bar}$/ &
$\underbracket {foo\ bar}$ \tabularnewline
\hline 
2.&
\verb/$\underbracket[2pt] {foo\ bar}$/ &
$\underbracket[2pt] {foo\ bar}$ \tabularnewline
\hline 
3.&
\verb/$\underbracket[2pt] [1em] {foo\ bar}$/&
$\underbracket[2pt] [1em] {foo\ bar}$\tabularnewline
\hline
\end{tabular}\end{center}
\vspace{0.3cm}


\section{overbracket-demo}

\verb/\overbrace{...}/ is an often used command:
\begin{eqnarray}
\left(x+1\right)^{2}\nonumber\\
\overbrace{x^{2}+2x+1} & = & f(x)
\end{eqnarray}


\begin{enumerate}
\item Sometimes an over\textbf{bracket} is needed, which can be used in
more ways than \verb/\overbrace{...}/
an example for \verb/\overbracket{...}/:


\begin{eqnarray*}
\textrm{Hate Science  }& \overbracket[0.5pt]{1\rightarrow2\rightarrow3\rightarrow4}
    \overbracket[0.75pt][0.75em]{\rightarrow5\rightarrow6\rightarrow7}
    \overbracket[1pt][1em]{\rightarrow8\rightarrow9\rightarrow10} & \textrm{Love Science}\\
 & \textrm{low}\hspace{1.5cm}\textrm{medium}\hspace{1.5cm}\textrm{high}\nonumber 
 \end{eqnarray*}


\end{enumerate}

\subsection*{use of \texttt{\textbackslash{}overbracket\{...\}}}

The \verb/\overbracket{...}/ command has two optional parameters:

\begin{itemize}
\item the linethickness in any valid latex unit, e.g. \verb/1pt/
\item the height of the edgebrackets, e.g. \verb/1em/
\end{itemize}
using without any parameters gives the same values for thickness and
height as predefined for the \verb/\overbrace/-command.


\subsubsection*{textmath-mode}

\vspace{0.3cm}
\begin{center}\begin{tabular}{|c|c|c|}
\hline 
1.&
\verb/$\overbracket {foo\ bar}$/ &
$\overbracket {foo\ bar}$ \tabularnewline
\hline 
2.&
\verb/$\overbracket[2pt] {foo\ bar}$/ &
$\overbracket[2pt] {foo\ bar}$ \tabularnewline
\hline 
3.&
\verb/$\overbracket[2pt] [1em] {foo\ bar}$/&
$\overbracket[2pt] [1em] {foo\ bar}$\tabularnewline
\hline
\end{tabular}\end{center}
\vspace{0.3cm}


\end{document}
