Math & ScienceOverbrace over an array

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
super_baros
Posts: 8
Joined: Fri Jan 08, 2010 12:26 am

Overbrace over an array

Post by super_baros »

Hi guys, I was just wondering if there is a way to put an overbrace over certain entries in an array.
I can do it for all entries in an array, simply

Code: Select all

\begin{displaymath}
\overbrace{
\begin{array}{cc}
		2 & 3
\end{array}}
\end{displaymath}
But I want to do something like this
example.JPG
example.JPG (3.72 KiB) Viewed 9119 times
with the numbers 1,2,3,4 in different columns of the array...

Many thanks guys!...

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Overbrace over an array

Post by gmedina »

Hi,

a basic approach could be something like the following:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{tabular}{cccc}
  & \multicolumn{2}{c}{$\overbrace{\rule{.8cm}{0pt}}$} &\\[-3pt]
  \multicolumn{2}{c}{$\overbrace{\rule{.8cm}{0pt}}$} &
    \multicolumn{2}{c}{$\overbrace{\rule{.8cm}{0pt}}$}\\[-3pt]
1 & 2 & 3 & 4\\
\end{tabular}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
claudia.degroote
Posts: 1
Joined: Thu Sep 16, 2010 3:30 pm

Overbrace over an array

Post by claudia.degroote »

Hi,

I had the same question, only with matrices. After applying your suggestion, I have still one problem. The overbrace is defined in the matrix itself, but I think it would be nicer if it would come above the columns of the matrix. For example:

Code: Select all

\begin{equation}
G =
\begin{pmatrix}
\multicolumn{3}{c}{\overbrace{\rule{1.5cm}{0pt}}^{N(k,d)-d}} & \multicolumn{3}{c}{\overbrace{\rule{1.5cm}{0pt}}^{d}}\\[-4pt]
0 & \ldots & 0 & 1 & \ldots & 1\\[9pt]
  & G_1    &   &   & G_2    &
\end{pmatrix}
\end{equation}
Is it possible in this example to set the braces and the $N(k,d)-d$ and $d$ out of the matrix?

Thanks!
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Overbrace over an array

Post by gmedina »

Hi,

you could use something like this:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
  \begin{array}{r@{\,}l}
    & 
    \begin{matrix}
      \mspace{15mu}\overbrace{\rule{1.5cm}{0pt}}^{N(k,d)-d} &     
      \overbrace{\rule{1.5cm}{0pt}}^{d}
    \end{matrix}
    \\
    G = & 
    \begin{pmatrix}
      0 & \ldots & 0 & 1 & \ldots & 1\\[9pt]
      & G_1    &   &   & G_2    &
    \end{pmatrix}
  \end{array}
\end{equation}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

Overbrace over an array

Post by CrazyHorse »

claudia.degroote wrote:Is it possible in this example to set the braces and the $N(k,d)-d$ and $d$ out of the matrix?

Thanks!

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\def\Width{0\kern2\tabcolsep\ldots\kern1\tabcolsep0}

\begin{document}

\begin{equation}
\begin{array}{rl}
    &  ~\array{cc}\overbrace{\phantom{\Width}}^{N(k,d)-d} &
       \overbrace{\phantom{\Width}}^{d} \endarray\\[-10pt]
G = & \begin{pmatrix}
      0 & \ldots & 0 & 1 & \ldots & 1\\[9pt]
      & G_1    &   &   & G_2    &
    \end{pmatrix}
  \end{array}
\end{equation}
\end{document}
Herbert
Post Reply