11

How do I get a tight \fbox around \vdots? There is an excess vertical space as discussed in

The code below produces:

enter image description here

Code:

\documentclass{article}

%% Defined in https://tex.stackexchange.com/a/412418/4301
\newcommand{\myvdots}{\raisebox{.006\baselineskip}{\ensuremath{\vdots}}}

\begin{document}
p
\fboxsep=0pt\fbox{\vdots}
\fboxsep=0pt\fbox{\myvdots}
y
\end{document}
2

1 Answer 1

13

The definition of \vdots in fontmath.ltx reads

\DeclareRobustCommand
  \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@
    \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}

(This is inherited from plain.tex with the addition of robustness.) I don't quite know the idea behind the \kern6\p@ bit, but removing it removes the excess box height

\documentclass{article}

\makeatletter
\DeclareRobustCommand
  \myvdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@
    \hbox{.}\hbox{.}\hbox{.}}}
\makeatother

\begin{document}

\fboxsep=0pt
p \fbox{\vdots} \fbox{\myvdots} y

\end{document}

enter image description here

2
  • 2
    Since \baselineskip is set to 4pt, the total height will be 14pt plus the height of the period. It is an example of an ad hoc macro by Knuth that was blindly copied to LaTeX.
    – egreg
    Commented Feb 17, 2020 at 9:40
  • @egrer A-ha. I was just adding that the macro is in fact inherited by plain :-)
    – campa
    Commented Feb 17, 2020 at 9:42

You must log in to answer this question.

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