6

While creating presentations with beamer, I have the problem described in broken matrix gaps in brackets. Using the solution proposed by Loop Space, I discovered that \vdots have an annoying whitepsace in tikz matrices (wich is also discussed here).

Now I wonder, why those whitespaces are not displayed when you use the standard bmatrix and how I can avoid these whitespaces in the tikz matrix.

Here is a MWE that shows the difference:

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[every node/.style={draw}, baseline=(dots)]
\matrix [draw=red]
{
    \node{Hallo}; \fill[blue!50] (0,0) circle (2pt); \\
    \fill[blue!50] (0,0) circle (2pt); \node(dots) {$\vdots$}; \\
    \node{g}; \fill[blue!50] (0,0) circle (2pt); \\
};
\end{tikzpicture}
$
\begin{bmatrix}
    \text{Hallo} \\
    \vdots \\
    \text{g}
\end{bmatrix}
$
\end{document}

Which results

Difference between vdots in tikz matrix and bmatrix

Ktree
  • 688
  • 2
    Try comparing the second matrix with the one you get typing \text{world} in the middle row: you'll see the vertical space inserted by \vdots as well. – egreg Dec 10 '15 at 08:39
  • OK, so there still is whitespace in the bmatrix, and the \vdots don't look perfectly centered if you write an uppercase letter below it. But how is the spacing computed in the bmatrix then? For usage with the tikz matrix I implemented a solution by redefining the \vdots command: \renewcommand{\vdots} { \tikz{ \fill(0,0)rectangle++(0.75pt,0.75pt); \fill(0,4pt)rectangle++(.75pt,.75pt); \fill(0,8pt)rectangle++(.75pt,.75pt); } } which works perfect in the tikz matrix. Unfortunatelly, using it in the bmatrix leads to an asymetric (shifted up) placement of the dots. – Ktree Dec 10 '15 at 09:46
  • 2
    Maybe you can use http://tex.stackexchange.com/a/112212/4427 – egreg Dec 10 '15 at 09:55
  • This is the non-tikz re-implementation of the vdots command, I really like it, thanks for that. So now I have a command to use in the tikz matrices but the problem with bmatrix remains. The dots look good in tikz, but why are they somehow shifted upwards in bmatrix? – Ktree Dec 10 '15 at 10:01

1 Answers1

5

Since the question was "why," the following shows that the baseline for \rvdots is at the bottom. Note that \vcenter does not center relative to the baseline, but relative to the \strut.

\documentclass[border=5pt]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}


\DeclareRobustCommand{\rvdots}{%
  \vbox{%
    \baselineskip=4pt
    \lineskiplimit=0pt
    \kern-1pt
    \hbox{.}\hbox{.}\hbox{.}
  }}

\DeclareRobustCommand{\cvdots}{%
  \vcenter{%
    \baselineskip=4pt %spacing
    \hbox{.}\hbox{.}\hbox{.}
  }}

\begin{document}
\begin{tikzpicture}[every node/.style={scale=5,anchor=base,draw=red,inner sep=0pt}]
 \draw[blue] (0,0) -- (4,0);% baseline
 \node at (1,0) {$\rvdots$};
 \node at (2,0) {$\cvdots$};
 \node at (3,0) {\strut};
\end{tikzpicture}

\end{document}

dots nn baseline

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thanks for that, it's interesting, as it shows that \rvdots actually are not perfectly centered in the tikz matrix (because the frame in the left picture doesnt include the upper "."). This leads me to a tikz-based solution for the \vdots again. I reworked it as \renewcommand{\vdots}{ \tikz[baseline, every node/.style={inner sep=0}]{ \node at (0,0){.}; \node at (0,4pt){.}; \node at (0,8pt){.}; } } so it really uses font-dependend dots. But still the question about how elements are placed in the bmatrix remains open. Is it just "baselines in fixed distances"? – Ktree Dec 11 '15 at 07:33