6

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

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

| improve this answer | |
  • 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 at 9:40
  • @egrer A-ha. I was just adding that the macro is in fact inherited by plain :-) – campa Feb 17 at 9:42

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.