4

This is my code for creating the matrix in Latex

How to add the underbrace

\begin{equation}
G = 
\begin{bmatrix}
g_0 \\ g_1 \\ . \\ . \\ . \\ g_k-1\\
\end{bmatrix}
=
\setcounter{MaxMatrixCols}{15}
\begin{bmatrix} 
p_{0,0}     & p_{1,0}     & . & . & . & p_{0,n-k-1}   & & & & 1 & 0 & . & . & . & 0 \\
p_{0,1}     & p_{1,1}     & . & . & . & p_{1,n-k-1}   & & & & 0 & 1 & . & . & . & 0 \\
.           & .           & . &   &   & .             & & & & . & . & . &   &   & . \\
.           & .           &   & . &   & .             & & & & . & . &   & . &   & . \\
.           & .           &   &   & . & .             & & & & . & . &   &   & . & . \\
p_{0,n-k-1} & p_{1,n-k-1} & . & . & . & p_{k-1,n-k-1} & & & & 0 & 0 & . & . & . & 1 \\
\end{bmatrix}
\end{equation}

How to add the underbrace for the highlighted part of the submatrix P ?

Thank you.

2

1 Answer 1

4

Here is one method using tikz overlays and markers

\documentclass[a4paper]{memoir}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{equation}
G = 
\begin{bmatrix}
g_0 \\ g_1 \\ . \\ . \\ . \\ g_k-1\\
\end{bmatrix}
=
\setcounter{MaxMatrixCols}{15}
\begin{bmatrix} 
p_{0,0}     & p_{1,0}     & . & . & . & p_{0,n-k-1}   & & & & 1 & 0 & . & . & . & 0 \\
p_{0,1}     & p_{1,1}     & . & . & . & p_{1,n-k-1}   & & & & 0 & 1 & . & . & . & 0 \\
.           & .           & . &   &   & .             & & & & . & . & . &   &   & . \\
.           & .           &   & . &   & .             & & & & . & . &   & . &   & . \\
.           & .           &   &   & . & .             & & & & . & . &   &   & . & . \\
\tikzmark{A} p_{0,n-k-1} & p_{1,n-k-1} & . & . & . & p_{k-1,n-k-1}\tikzmark{B} & & & & 0 & 0 & . & . & . & 1 \\
\end{bmatrix}
\end{equation}
\begin{tikzpicture}[remember picture,overlay,decoration={brace,amplitude=5pt,mirror,raise=5pt}]
  \draw[red,decorate] (pic cs:A) -- (pic cs:B)
  node [midway,below=9pt] {$p$};
\end{tikzpicture}

\end{document}
5
  • Can you also tell me or give me the link to download the package tikz.
    – Mitun_C
    Feb 10, 2017 at 15:28
  • @Mitun_C Which LaTeX installation do you use? Most installations has a package manager that can be used to install packages. Instead of using very small LaTeX installations, I recommend to install everything, for example installing the latest TeXLive (TeXLive from Linux is often fragmented and odd)
    – daleif
    Feb 10, 2017 at 15:58
  • Using Texmaker in Linux. I dont have administrative access in this computer. There are also Kile and KBibtex available. Is there any way to check where the packages are downloaded, so that I can update them.
    – Mitun_C
    Feb 10, 2017 at 16:23
  • @Mitun_C Ask your administrator to provide a full latex installation. If usepackage tikz does not work, you have very basic installation which is not very useful.
    – daleif
    Feb 10, 2017 at 17:11
  • I tried your recommendations for installing tikz packages, but it is not so easy to get it done with my admin. Can you give me a solution without the tikz method ? Thank you.
    – Mitun_C
    Feb 14, 2017 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .