# Vertically align padded matrix with different rows

Allow me to elaborate: I have a square matrix that by padding zeros to the right columns, became non-square. I want to use one zero to represent the zero submatrix to ideally achieve this:

Instead what I got is this:

For the moment I faked it by replacing a \ddot with two dots in consecutive rows hence achieving odd number of rows:

Needless to say I don't like my hack.

\documentclass{article}
\usepackage{bm,delarray}
\begin{document}
$\bm{\Sigma} = \left[ \begin{array}{cccc|c} \bm{\sigma}_1 & & & & 0 \\ & \bm{\sigma}_2 & & & 0\\ & & \ddots & & 0 \\ & & & \bm{\sigma}_m & 0 \end{array} \right]$
$\bm{\Sigma} = \left[ \begin{array}{ccccc|c} \bm{\sigma}_1 & & & & & \\ & \bm{\sigma}_2 & & & & \\ & & . & & & 0 \\ & & & . & & \\ & & & & \bm{\sigma}_m & \end{array} \right]$
\end{document}

Nest a matrix in the array

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\begin{document}

$\bm{\Sigma} = \left[\begin{array}{@{}c|c} \begin{matrix} \bm{\sigma}_1 \\ & \bm{\sigma}_2 \\ & & \ddots \\ & & & \bm{\sigma}_m \end{matrix} & 0 \end{array}\right]$

\end{document}

• Thank you. I prefer this answer, mainly because I doesn't include a hard coded value. Commented Jan 26, 2018 at 14:15

This way?

\documentclass{article}
\usepackage{bm, delarray, multirow}

\begin{document}

$\bm{\Sigma} = \left[ \begin{array}{cccc|c} \bm{\sigma}_1 & & & & \multirow{4}{*}[-0.5ex]{\Large 0 } \\ & \bm{\sigma}_2 & & & \\[-0.5ex] & & \ddots & & \\[-0.5ex] & & & \bm{\sigma}_m & \end{array} \right]$

\end{document}

• From 0 to +1 :-). Hi and good work. Commented Jan 25, 2018 at 21:34

A quick work-around: use \smash for \ddots because it has more height than other math symbols. There are other options, of course, if you don't like this hack; one can increase inter-row space via \renewcommand{\arraystretch}{1.5} for example, or adding \vphantom{\ddots} to all other rows without \ddots.

\documentclass{article}
\usepackage{bm,delarray}
\begin{document}
$\bm{\Sigma} = \left[ \begin{array}{cccc|c} \bm{\sigma}_1 & & & & 0 \\ & \bm{\sigma}_2 & & & 0\\ & & \smash{\vcenter{\hbox{\ddots}}} & & 0 \\ & & & \bm{\sigma}_m & 0 \end{array} \right]$
\end{document}

• Thank you very much. It is definitely better than my hack and I also learned about \smash. With that said, I would like to have a single 0 on the right hand side instead of four. Just like first image in my question. Commented Jan 25, 2018 at 19:01
• May be \vdots in the third row in the right hand side? Commented Jan 25, 2018 at 19:53

With {pNiceArray} of nicematrix.

\documentclass{article}
\usepackage{bm}
\usepackage{nicematrix}

\NiceMatrixOptions{xdots/shorten=6pt}

\begin{document}
$\setlength{\arraycolsep}{6pt} \bm{\Sigma} = \begin{bNiceArray}{cccc|c}[nullify-dots,margin=1pt] \bm{\sigma}_1 & & & & 0 \\ & \bm{\sigma}_2 & & & 0\\ & & \Ddots & & 0 \\ & & & \bm{\sigma}_m & 0 \end{bNiceArray}$
\end{document}

One more solution with use of the nicematrix package which mimic @egreg and @Bernard answers:

\documentclass[margin=3mm,varwidth]{standalone}
\usepackage{bm}
\usepackage{nicematrix}

\begin{document}
$\setlength{\arraycolsep}{1pt} \bm{\Sigma} = \begin{bNiceArray}{cccc|c}[margin=1pt] \bm{\sigma}_1 & & & & \Block{4-1}<\Huge>{0} \\ & \bm{\sigma}_2 & & & \\ & & \ddots & & \\ & & & \bm{\sigma}_m & \end{bNiceArray}$
\end{document}