4

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:

enter image description here

Instead what I got is this:

enter image description here

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

enter image description here

Needless to say I don't like my hack.

Any advice?

\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}

5 Answers 5

2

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}

enter image description here

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

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} 

enter image description here

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

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}

enter image description here

2
  • 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.
    – Pouya
    Commented Jan 25, 2018 at 19:01
  • May be \vdots in the third row in the right hand side?
    – Manuel
    Commented Jan 25, 2018 at 19:53
1

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}

Output of the above code

1

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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .