# How to remove vertical space between two tikz matrix rows?

I have the following matrix in TikZ: Here's the code:

\documentclass{article}
\usepackage{tikz,amssymb}
\usetikzlibrary{matrix,calc,fit}
\begin{document}

\tikzset{
circled/.style={draw,circle,inner sep=0pt},
highrow/.style={minimum height=.9cm},
}
\begin{tikzpicture}
\node[matrix of nodes] (tcm) {
{}  &
$a_{00}$  &  $\leqslant$  &
$a_{10}$  &  $\leqslant$  &
$a_{20}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n0}$  \\
{}  &
$a_{01}$  &  $\leqslant$  &
$a_{11}$  &  $\leqslant$  &
$a_{21}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n1}$ \\
{}  &
$a_{02}$  &  $\leqslant$  &
$a_{12}$  &  $\leqslant$  &
$a_{22}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n2}$  \vspace{-5cm}\\
|[circled]| $+$  &
|[highrow]| $\vdots$  &  {}  &
$\vdots$  &  {}  &
$\vdots$  &  {}  &
$\ddots$  &  {}  &
$\vdots$  \\
{}  &
$\sum\limits_{m=0}^\infty a_{0m}$  &  {}  &
$\sum\limits_{m=0}^\infty a_{1m}$  &  {}  &
$\sum\limits_{m=0}^\infty a_{2m}$  &  {}  &
$\cdots$                           &  {}  &
$\sum\limits_{m=0}^\infty \lim\limits_{n\to\infty} a_{nm}$  \\
};
\node[fit=(tcm-5-1) (tcm-5-2) (tcm-5-3) (tcm-5-4) (tcm-5-5) (tcm-5-6) (tcm-5-7) (tcm-5-8) (tcm-5-9) (tcm-5-10),inner sep=0pt] (R5) {};
\draw (R5.north -| tcm.west) -- (R5.north -| tcm.east);
\end{tikzpicture}

\end{document}


The amount of vertical space between the third and fourth rows is bothering me. The fourth row (the row that follows the circled plus sign) has a lot of vertical space above, and I can't remove it. As far as I know, row sep only works for all the rows at once -- I can't use it in only the fourth row.

OBS: The source of the problem is not the minimum height of the circled plus sign. When this minimum height is set to zero, the fourth row has an abnormal amount of vertical space above it.

The "standard" tabular adjustments work so that you can use \\[-4mm], for example, to decrease the space between two consecutive rows. Similarly, \\[3em] will add 3em of space. If you do this then your diagram becomes: Here is the full code (which is the OP's with this single adjustment):

\documentclass{article}
\usepackage{tikz,amssymb}
\usetikzlibrary{matrix,calc,fit}
\begin{document}

\tikzset{
circled/.style={draw,circle,inner sep=0pt},
highrow/.style={minimum height=.9cm},
}
\begin{tikzpicture}
\node[matrix of nodes] (tcm) {
{}  &
$a_{00}$  &  $\leqslant$  &
$a_{10}$  &  $\leqslant$  &
$a_{20}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n0}$  \\
{}  &
$a_{01}$  &  $\leqslant$  &
$a_{11}$  &  $\leqslant$  &
$a_{21}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n1}$ \\
{}  &
$a_{02}$  &  $\leqslant$  &
$a_{12}$  &  $\leqslant$  &
$a_{22}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n2}$  \\[-4mm]
|[circled]| $+$  &
|[highrow]| $\vdots$  &  {}  &
$\vdots$  &  {}  &
$\vdots$  &  {}  &
$\ddots$  &  {}  &
$\vdots$  \\
{}  &
$\sum\limits_{m=0}^\infty a_{0m}$  &  {}  &
$\sum\limits_{m=0}^\infty a_{1m}$  &  {}  &
$\sum\limits_{m=0}^\infty a_{2m}$  &  {}  &
$\cdots$                           &  {}  &
$\sum\limits_{m=0}^\infty \lim\limits_{n\to\infty} a_{nm}$  \\
};
\node[fit=(tcm-5-1) (tcm-5-2) (tcm-5-3) (tcm-5-4) (tcm-5-5) (tcm-5-6) (tcm-5-7) (tcm-5-8) (tcm-5-9) (tcm-5-10),inner sep=0pt] (R5) {};
\draw (R5.north -| tcm.west) -- (R5.north -| tcm.east);
\end{tikzpicture}

\end{document}

• Didn't know about the "standard" tabular ajustments, hehe. Thanks! Feb 16, 2016 at 20:22
• Nice. By adding [matrix of nodes,nodes in empty cells] you can omit the empty braces {} Apr 2 at 4:16

The additional vertical space comes from the height of \vdots and \ddots as you can see with

\documentclass[tikz]{standalone}
\begin{document}
\tikz\node[inner sep=0pt,draw]{$\vdots$};
\end{document} So I would use $\smash{\vdots}$ to hide the height of the dots and a style like strutsize/.style={text height=\ht\strutbox,text depth=\dp\strutbox} to reserve the needed vertical space. \documentclass{article}
\usepackage{tikz,amssymb}
\usetikzlibrary{matrix,calc,fit}
\begin{document}

\tikzset{
circled/.style={draw,circle,inner sep=0pt},
highrow/.style={minimum height=.9cm},
strutsize/.style={text height=\ht\strutbox,text depth=\dp\strutbox}
}
\begin{tikzpicture}
\node[matrix of nodes] (tcm) {
{}  &
$a_{00}$  &  $\leqslant$  &
$a_{10}$  &  $\leqslant$  &
$a_{20}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n0}$  \\
{}  &
$a_{01}$  &  $\leqslant$  &
$a_{11}$  &  $\leqslant$  &
$a_{21}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n1}$ \\
{}  &
$a_{02}$  &  $\leqslant$  &
$a_{12}$  &  $\leqslant$  &
$a_{22}$  &  $\leqslant$  &
$\cdots$  &  $\leqslant$  &
$\lim\limits_{n\to\infty} a_{n2}$ \\
|[circled]| $+$  &
|[strutsize]| $\smash{\vdots}$  &  {}  &
$\smash{\vdots}$  &  {}  &
$\smash{\vdots}$  &  {}  &
$\smash{\ddots}$  &  {}  &
$\smash{\vdots}$  \\
{}  &
$\sum\limits_{m=0}^\infty a_{0m}$  &  {}  &
$\sum\limits_{m=0}^\infty a_{1m}$  &  {}  &
$\sum\limits_{m=0}^\infty a_{2m}$  &  {}  &
$\cdots$                           &  {}  &
$\sum\limits_{m=0}^\infty \lim\limits_{n\to\infty} a_{nm}$  \\
};
\node[fit=(tcm-5-1) (tcm-5-2) (tcm-5-3) (tcm-5-4) (tcm-5-5) (tcm-5-6) (tcm-5-7) (tcm-5-8) (tcm-5-9) (tcm-5-10),inner sep=0pt] (R5) {};
\draw (R5.north -| tcm.west) -- (R5.north -| tcm.east);
\end{tikzpicture}

\end{document}

• Well, good to know that vdots has this strange behaviour. Thanks! Feb 16, 2016 at 20:24