5

I want to draw a matrix, in this example, a 7x7 one, with numbers on the outside, but a 3x3 matrix in the core, as shown in the hand drawn picture below. I don't want to write out the inside 3x3 matrix, I just want write the name of it (A_c - B_c * K_c).

I know there are many other questions asking how to draw a matrix inside a matrix, but I couldn't find one where I didn't have to write the actual contents of the inside matrix.

Thanks!

enter image description here

2
  • Try package nicematrix: ctan.org/pkg/nicematrix?lang=en . Have a look inside its manual. What you want to do can be done e.g. using the \Block statement of this package. // For the outer and inner braces, they come as rectangular, rounded, none etc. with nicematrix. Commented Jul 21, 2021 at 20:01
  • Hmm, I actually want a 17x17 matrix (for the example I drew a 7x7 one for simplicity). I'm using overleaf and it is telling me that I'm trying to use more columns than the emergency stop :( Commented Jul 21, 2021 at 20:11

3 Answers 3

5

I propose a solution with blkarray:

\documentclass{article} \usepackage{blkarray, bigstrut} \begin{document} \[ \left[\begin{blockarray}{ccccccc} 0 & 0 & 0 & 0 & 0 & 1 & 0 \bigstrut[t]\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \begin{block}{cc[ccc]cc} 0 & 0 & & & & 0 & 0 \\ 0 & 0 & \BAmulticolumn{3}{c}{A_c-B_cK_c} & 0 & 0 \\ 0 & 0 & & & & 0 & 0 \\ \end{block} 0 & 0 & 1 & 2 & 3 & 0 & 0 \\ 0 & 0 & 4 & 5 & 6 & 0 & 0 \\[-2ex] \end{blockarray}\right] \]% \end{document} 

enter image description here

1
  • 1
    Ahhh, I found this solution to be the easiest and work the best for me, thanks! Commented Jul 21, 2021 at 20:55
6

With {bNiceMatrix} of nicematrix.

\documentclass{article} \usepackage{nicematrix} \begin{document} $\begin{bNiceMatrix}[columns-width=4mm] 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & \Block{3-3}{A_c-B_cK_c} & & & 0 & 0 \\ 0 & 0 & & & & 0 & 0 \\ 0 & 0 & & & & 0 & 0 \\ 0 & 0 & 1 & 2 & 3 & 0 & 0 \\ 0 & 0 & 4 & 5 & 6 & 0 & 0 \\ \CodeAfter \SubMatrix[{3-3}{5-5}] \end{bNiceMatrix}$ \end{document} 

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

4

An idea is to “guess” a suitable amount of additional intercolumn space to accommodate the rather big A_c-B_cK_c. I tried a bit and found out that 3pt fits the bill for the standard font and 10pt size.

\documentclass{article} \usepackage{amsmath,mathtools} \begin{document} \[ \addtolength{\arraycolsep}{3pt} \begin{bmatrix} 0 & 0 & \begin{matrix} 0 & 0 & 0 \end{matrix} & 1 & 0 \\ 0 & 0 & \begin{matrix} 0 & 0 & 0 \end{matrix} & 0 & 1 \\ \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} & \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} & \hidewidth\begin{bmatrix} \\ A_c-B_cK_c \\ \\ \end{bmatrix}\hidewidth & \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} & \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} \\ 0 & 0 & \begin{matrix} 1 & 2 & 3 \end{matrix} & 0 & 0 \\ 0 & 0 & \begin{matrix} 4 & 5 & 6 \end{matrix} & 0 & 0 \\ \end{bmatrix} \] \end{document} 

With \hidewidth on either side, the central block turns out to be “invisible” as far as spacing is concerned, but still printed.

enter image description here

1
  • Ahhhh, I didn't think of putting together matricies like that to mimic 1 big matrix, thanks! Commented Jul 21, 2021 at 20:14

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.