1

I want to write the following matrix in latex,

enter image description here

Adding the group structure is creating some problem. Can anyone provide me with a simple code to generate the groups for the matrices?

Thank you,

Prithish.

2 Answers2

3

Here's a solution that's uses nested array environments.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "\text" macro
\newcommand\curlygroup[1]{%
  \left.\begin{array}{@{}c@{}}
  \vphantom{x_11} \\ \vphantom{vdots} \\ \vphantom{x_11}
  \end{array}\right\} \text{#1}}
\begin{document}
\[
\setlength\arraycolsep{2pt}
\left[\begin{array}{cccc}
x_{11}   & x_{12}  & \cdots & x_{1p} \\
\vdots   & \vdots  & \ddots & \vdots \\
x_{k1}   & x_{k2}  & \cdots & x_{kp} \\
\hline
x_{k+1,1}&x_{k+1,2}& \cdots & x_{k+1,p}\\
\vdots   & \vdots  & \ddots & \vdots   \\
x_{n1}   & x_{n2}  & \cdots & x_{np}   \\
\end{array}\right]
\begin{array}{@{}l@{}}
\curlygroup{Group 1}\\[4.5ex]
\curlygroup{Group 2}
\end{array}
\]
\end{document}
Mico
  • 506,678
1

With {bNiceMatrix} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

[ \setlength{\arraycolsep}{2pt} \begin{bNiceMatrix}[margin,last-col=5] x_{11} & x_{12} & \cdots & x_{1p} & \Block{3-1}{\quad \text{Group } 1} \ \vdots & \vdots & \ddots & \vdots \ x_{k1} & x_{k2} & \cdots & x_{kp} \ \hline x_{k+1,1}&x_{k+1,2}& \cdots & x_{k+1,p}& \Block{3-1}{\quad \text{Group } 2}\ \vdots & \vdots & \ddots & \vdots \ x_{n1} & x_{n2} & \cdots & x_{np} \ \CodeAfter [sub-matrix/xshift=2mm] \SubMatrix{.}{1-1}{3-4}{}} \SubMatrix{.}{4-1}{6-4}{}} \end{bNiceMatrix} ]

\end{document}

Output of the above code

F. Pantigny
  • 40,250