# How to set the baseline of a box?

I want to change the baseline of a box so that the depth of the box is equal to that of a letter with a descender in the current font. So far I have only been successful in setting the baseline to the bottom of the box by wrapping the box in a \vbox and using \vtop, but this isn't exactly what I want.

\documentclass{article}

\def\aberrantbox{\vrule height8pt depth5pt width5pt}

\begin{document}
Line \aberrantbox \vtop{\vbox{\hbox{\aberrantbox}\kern 0pt}}.
\end{document}


I tried various combinations of \smash and \phantom but I couldn't make it work.

• Do you want something like this?
– Werner
Jan 6, 2016 at 22:17
• @Werner I want this alignment at the bottom but without changing the total height. Jan 6, 2016 at 22:20
– Werner
Jan 6, 2016 at 22:21
• depending on the font (and after looking at @Werner;s example), you could try \vphantom{qb}, \vphantom{XQ} and \vphantom{()} since different fonts have different designs with heights/depths of ascenders, descenders, and fences; those examples should give you an idea of what's an appropriate setting.. Jan 6, 2016 at 22:26
• I mean that I want the height + depth of the box to remain unchanged. In your picture the box is clipped at the top. Jan 6, 2016 at 22:32

Raise the box by its depth minus the depth of a letter with a descender:

\documentclass{article}

\newcommand{\aberrantbox}{\vrule height8pt depth5pt width5pt}

\begin{document}
Line \aberrantbox
\raisebox{\dimexpr\depth-\fontchardp\fonty}{\aberrantbox}y
\end{document}


The result seems imprecise at high resolution, because the descender of y` overshoots.

• ...as can be seen here.
– Werner
Jan 6, 2016 at 22:24