10

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}

Peter Grill
  • 223,288

1 Answers1

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

campa
  • 31,130
  • 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 Feb 17 '20 at 09:40
  • @egrer A-ha. I was just adding that the macro is in fact inherited by plain :-) – campa Feb 17 '20 at 09:42