2

enter image description here

I want to make a matrix-vector product in latex that is similar in style to what is shown. Suppose that the entire matrix and vector is 3x3 and 3x1, but i want to group the entries as shown and separate with dotted lines, while keeping the original "size" of the matrix, to show how the entries are grouped. How would one go about doing that?

cTroels
  • 23
  • 2

1 Answers1

3

The nicematrix package has tools for this. The \Block command spans both columns and rows as specified. columns-width=auto forces all columns to be the same width.

enter image description here

\documentclass{article}

\usepackage{nicematrix}

\begin{document} [ \NiceMatrixOptions{cell-space-limits=2mm} \begin{bNiceArray}{c:cc}[columns-width=auto, margin] A_{11} & \Block{1-2}{A_{12}} & \ \hdottedline \Block{2-1}{A_{21}} & \Block{2-2}{A_{22}} \[4ex] && \end{bNiceArray}; \begin{vNiceArray}{c}[margin] \Block{1-1}{x_1}\ \hdottedline \Block{2-1}{x_2} \[4ex] \ \end{vNiceArray} ] \end{document}

Or if you want dashed lines, you can define a custom-line. Note that tikz must be loaded for this option.

enter image description here

\documentclass{article}

\usepackage{nicematrix, tikz}

\begin{document} [ \NiceMatrixOptions{cell-space-limits=2mm, custom-line={letter=I, tikz=dashed, total-width=\pgflinewidth, command = hdashedline}} \begin{bNiceArray}{cIcc}[columns-width=auto, margin] A_{11} & \Block{1-2}{A_{12}} & \ \hdashedline \Block{2-1}{A_{21}} & \Block{2-2}{A_{22}} \[4ex] && \end{bNiceArray}; \begin{vNiceArray}{c}[margin] \Block{1-1}{x_1}\ \hdashedline \Block{2-1}{x_2} \[4ex] \ \end{vNiceArray} ] \end{document}

Sandy G
  • 42,558