4

Normally, I'm kind of a Latex guru and I find solutions to problems easily with sites like this, but now I encountered something I cannot find an appropriate solution for: I have matrices within a matrix and the bows seem to be glued to each other, look: bows are glued to each other

My code looks like this:

\begin{pmatrix}
\begin{pmatrix}
 0 & 1\\
 0 & 0\\
\end{pmatrix} & 
\begin{pmatrix}
 1\\
 1\\
\end{pmatrix}
& \begin{pmatrix}
0\\
2\\
\end{pmatrix}\\
 \begin{pmatrix}
0 & 2\\
\end{pmatrix} & \begin{pmatrix}
 0\\
\end{pmatrix} & \begin{pmatrix}
 0\\
\end{pmatrix}\\
\begin{pmatrix}
 0 & 0\\
\end{pmatrix} & \begin{pmatrix}
 0\\
\end{pmatrix} & \begin{pmatrix}
 1\\
\end{pmatrix}\\
\end{pmatrix} 

How can I add just a little vertical space between the submatrices?

  • immediately after a line \end{pmatrix}\` add [2pt]` or some other amount of space that you want to skip. no space between \\[2pt] -- amsmath checks for space there, and if found, the brackets and their contents are printed. – barbara beeton Apr 24 '15 at 20:12
  • 1
    Welcome to TeX.SX! In this case it's not so important, but it's better to make self contained examples starting from \documentclass, loading the necessary packages and ending with \end{document}. – egreg Apr 24 '15 at 20:24
  • 1
    What a beautiful bubbles! ;-) [And \\[length] sugested by barbara beeton is of course the solution]. – Przemysław Scherwentke Apr 24 '15 at 20:49
2

Here I added a stacking gap (default 3pt, settable with optional argument) to one of the matrices on row 2. It adds the gap above and below the item. Note, though, that if there are other matrix or vector terms in the same equation (not shown), you may need to add gap to those as well, in order to keep rows on the same vertical level.

\documentclass{article}
\usepackage{stackengine,amsmath}
\stackMath
\begin{document}
\[
\begin{pmatrix}
\begin{pmatrix}
 0 & 1\\
 0 & 0\\
\end{pmatrix} & 
\begin{pmatrix}
 1\\
 1\\
\end{pmatrix}
& \begin{pmatrix}
0\\
2\\
\end{pmatrix}\\
\addstackgap{
\begin{pmatrix}
0 & 2\\
\end{pmatrix}} & \begin{pmatrix}
 0\\
\end{pmatrix} & \begin{pmatrix}
 0\\
\end{pmatrix}\\
\begin{pmatrix}
 0 & 0\\
\end{pmatrix} & \begin{pmatrix}
 0\\
\end{pmatrix} & \begin{pmatrix}
 1\\
\end{pmatrix}\\
\end{pmatrix} 
\]
\end{document}

enter image description here

1

Vertical spacing is inconsistent in mathmode and behaves differently from that of textmode, that is why simply adding \\[length] wouldn't work. I suggest adding a zero-length \rule of a chosen height can solve the problem. Of course, adding a zero-length \rule inevitably adds a space of {}, so I also put an equal negative space length \! to compensate for this.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
\begin{pmatrix}
\begin{pmatrix}
 0 & 1\\
 0 & 0\\
\end{pmatrix} & 
\begin{pmatrix}
 1\\
 1\\
\end{pmatrix}
& \begin{pmatrix}
0\\
2\\
\end{pmatrix}\\\!\rule{0in}{.16in}
\begin{pmatrix}
0 & 2\\
\end{pmatrix} & \begin{pmatrix}
 0\\
\end{pmatrix} & \begin{pmatrix}
 0\\
\end{pmatrix}\\\!\rule{0in}{.16in}
\begin{pmatrix}
 0 & 0\\
\end{pmatrix} & \begin{pmatrix}
 0\\
\end{pmatrix} & \begin{pmatrix}
 1\\
\end{pmatrix}\\
\end{pmatrix} 
\end{equation}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.