5

I want to format this matrix in the \scriptsize font size:

enter image description here

\documentclass[12pt]{article}
\usepackage{amsmath}

\begin{document}

\scriptsize

$S=\begin{pmatrix}\sigma_1 & 0     & 0\\ 
                0        &\sigma_2 & \vdots\\
                0        &\dots    &
\end{pmatrix}$

\end{document}

It does however look unbalanced - there is unwanted whitespace between the first and second row and the \vdots are taller than the $0$ in the second row. What is the best way to correctly typeset this expression?

Edit 1:

A workaround would be to simply write

$$S=\text{diag}(\sigma_1,\sigma_2,\ldots,0,\ldots),$$

where the term $0,\ldots$ signifies that the matrix has to be filled up with zeros, as $S\in\mathbb{R}^{m\times n}$. I would still like to know how to correctly typeset the matrix though.

Edit 2:

I want to copy this matrix from a reference source. There it looks like this:

enter image description here

It appears that the whitespace between the dots has been adjusted, and that they were also shifted manually in the vertical direction. I feel like the ideal option would be to align the top most dot with the top of the 0 and the bottom most dot with the bottom of the $2$. Is there a way to format the matrix like this?

0
5

I propose a \svdots macro for “scaling” vertical dots. I've never really liked the standard definition, to be honest.

\documentclass{article}
\usepackage{amsmath}

\DeclareRobustCommand{\svdots}{% s for `scaling'
  \vbox{%
    \baselineskip=0.33333\normalbaselineskip
    \lineskiplimit=0pt
    \hbox{.}\hbox{.}\hbox{.}%
    \kern-0.2\baselineskip
  }%
}

\begin{document}

$S=
\begin{pmatrix}
  \sigma_1 & 0        & 0\\ 
  0        & \sigma_2 & \svdots\\
  0        & \dots    &
\end{pmatrix}
\begin{pmatrix}
  \sigma_1 & 0        & 0\\ 
  0        & \sigma_2 & 0\\
  0        & \dots    &
\end{pmatrix}$

\scriptsize

$S=\begin{pmatrix}
  \sigma_1 & 0        & 0\\ 
  0        & \sigma_2 & \svdots\\
  0        & \dots    &
\end{pmatrix}$

\end{document}

enter image description here

If you want the vertical dots centered with respect to the formula axis, you can do

\documentclass{article}
\usepackage{amsmath}

\DeclareRobustCommand{\svdots}{% s for `scaling'
  \vcenter{%
    \offinterlineskip
    \hbox{.}
    \vskip0.25\normalbaselineskip
    \hbox{.}
    \vskip0.25\normalbaselineskip
    \hbox{.}%
  }%
}

\begin{document}

$S=
\begin{pmatrix}
  \sigma_1 & 0        & 0\\ 
  0        & \sigma_2 & \svdots\\
  0        & \dots    &
\end{pmatrix}
\begin{pmatrix}
  \sigma_1 & 0        & 0\\ 
  0        & \sigma_2 & 0\\
  0        & \dots    &
\end{pmatrix}$

\scriptsize

$S=\begin{pmatrix}
  \sigma_1 & 0        & 0\\ 
  0        & \sigma_2 & \svdots\\
  0        & \dots    &
\end{pmatrix}$

\end{document}

enter image description here

3
  • Thanks for these suggestions, they already look really good! The formatting is however still slightly off compared to the reference that I am trying to copy this matrix from, do you mind having a look at my second edit?
    – Skydiver
    Nov 30 '20 at 16:27
  • 2
    @Skydiver Added as requested
    – egreg
    Nov 30 '20 at 17:41
  • 1
    Thank you very much, this works as expected.
    – Skydiver
    Nov 30 '20 at 18:16
3

I would do that with stackengine , which has a \Vectorstack command for math mode:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{stackengine}

\begin{document}

\scriptsize

$S=\begin{pmatrix}\sigma_1 & 0 & 0\\
                0 &\sigma_2 & \Vectorstack{\vdots}\\
                0 &\dots &
\end{pmatrix}$

\end{document} 

enter image description here

For a \vdots centred w.r.t. the middle of the 0 in the row, you can try this:

$S=\begin{pmatrix}\sigma_1 & 0 & 0\\[0.5ex]
                0 &\sigma_2 & \raisebox{-0.12\height}[0pt][0pt]{$\vdots$}\\[0.5ex]
                0 &\dots &
\end{pmatrix}$

enter image description here

4
  • Thanks for the suggestion, but now the \vdots are still not vertically centered in the second row. Is it possible to align them correctly as well?
    – Skydiver
    Nov 30 '20 at 15:31
  • The middle dot is aligned on the baseline. What do you want exactly?
    – Bernard
    Nov 30 '20 at 15:52
  • Fair enough, I was hoping to have the middle dot aligned with the middle of the $0$ however.
    – Skydiver
    Nov 30 '20 at 15:54
  • 1
    @Skydiver: I've posted another code to satisfy your requirement. I'm not sure it looks beter than the other solution, and the code is more complex, though.
    – Bernard
    Nov 30 '20 at 16:18
3

Using the package nicematrix adjusting the values of \NiceMatrixOptions to -5pt (minimum value),

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{nicematrix}

\begin{document}
\NiceMatrixOptions{cell-space-top-limit=-5pt,cell-space-bottom-limit=-5pt}
$S=\begin{pNiceMatrix}
\sigma_{1} & 0 & 0\\
0 & \sigma_{2} & \vdots \\
0 & \ldots &
\end{pNiceMatrix}$

\end{document}

you can obtain similar output.

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.