4

How to add square bracket in this matrix?

(a1,...,an) and (x1,...,xm) does not in the brackets.

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
    \begin{align*}
        D=
        \begin{array}{ccccc}
            &a_1&a_2&\ldots&a_n\\
            x_1&(\mu_{11},\nu_{11})&(\mu_{12},\nu_{12})&\ldots&(\mu_{1n},\nu_{1n})\\
            x_2&(\mu_{21},\nu_{21})&(\mu_{22},\nu_{22})&\ldots&(\mu_{2n},\nu_{2n})\\
            \vdots&\vdots&\ddots&\vdots\\
            x_m&(\mu_{m1},\nu_{m1})&(\mu_{m2},\nu_{m2})&\ldots&(\mu_{mn},\nu_{mn})
        \end{array}
    \end{align*}
\end{document}

enter image description here

2
  • 6
    Look up blkarray, nicematrix might also have support for it. Has been answered several times on the site
    – daleif
    Commented Apr 8, 2021 at 5:08
  • 1
    Related/duplicate: Label rows of a matrix by characters
    – Werner
    Commented Apr 8, 2021 at 15:35

2 Answers 2

6

With nicematrix.

\documentclass{article}
\usepackage{nicematrix,amssymb}
\begin{document}
    \begin{align*}
        D=
        \begin{bNiceMatrix}[first-col,first-row]
            &a_1&a_2&\ldots&a_n\\
            x_1&(\mu_{11},\nu_{11})&(\mu_{12},\nu_{12})&\ldots&(\mu_{1n},\nu_{1n})\\
            x_2&(\mu_{21},\nu_{21})&(\mu_{22},\nu_{22})&\ldots&(\mu_{2n},\nu_{2n})\\
            \vdots&\vdots&\ddots&\vdots\\
            x_m&(\mu_{m1},\nu_{m1})&(\mu_{m2},\nu_{m2})&\ldots&(\mu_{mn},\nu_{mn})
        \end{bNiceMatrix}
    \end{align*}
\end{document}

Output of the above code

Edit: we might also improve your matrix using \Ldots, \Vdots and \Ddots

\documentclass{article}

\usepackage{amssymb}

\usepackage{nicematrix}

\begin{document}
    
\begin{align*}
    D=
    \begin{bNiceMatrix}[first-col, first-row]
               & a_1                 & a_2                 & \Ldots & a_n                 \\
        x_1    & (\mu_{11},\nu_{11}) & (\mu_{12},\nu_{12}) & \Ldots & (\mu_{1n},\nu_{1n}) \\
        x_2    & (\mu_{21},\nu_{21}) & (\mu_{22},\nu_{22}) & \Ldots & (\mu_{2n},\nu_{2n}) \\
        \Vdots & \Vdots              & \Vdots              & \Ddots & \Vdots              \\
        x_m    & (\mu_{m1},\nu_{m1}) & (\mu_{m2},\nu_{m2}) & \Ldots & (\mu_{mn},\nu_{mn})
    \end{bNiceMatrix}
\end{align*}

\end{document}

enter image description here

7
\documentclass{article}
\usepackage{blkarray,amsmath}
\begin{document}
\begin{align*}
    D=
    \begin{blockarray}{c c c c c}
        &a_1&a_2&\ldots&a_n\\
        \begin{block}{c [c c c c]}
            x_1&(\mu_{11},\nu_{11})&(\mu_{12},\nu_{12})&\ldots&(\mu_{1n},\nu_{1n})\\
            x_2&(\mu_{21},\nu_{21})&(\mu_{22},\nu_{22})&\ldots&(\mu_{2n},\nu_{2n})\\
            \vdots&\vdots&\vdots&\ddots&\vdots\\
            x_m&(\mu_{m1},\nu_{m1})&(\mu_{m2},\nu_{m2})&\ldots&(\mu_{mn},\nu_{mn})\\
        \end{block}
    \end{blockarray}
\end{align*}    
\end{document}

enter image description here

You must log in to answer this question.

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