4

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}

enter image description here

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

  • 1
    Do you want something like this? – Werner Jan 6 '16 at 22:17
  • @Werner I want this alignment at the bottom but without changing the total height. – Ernest A Jan 6 '16 at 22:20
  • I've used \newcommand\abox{\vrule height\ht\strutbox depth\dp\strutbox width5pt} \newcommand\bbox{\setbox8=\hbox{q}\setbox9=\hbox{d}\vrule height\ht9 depth\dp8 width5pt} with the left box set using \abox and the right with \bbox. I don't understand what you mean by "without changing the total height"... – Werner Jan 6 '16 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.. – barbara beeton Jan 6 '16 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. – Ernest A Jan 6 '16 at 22:32
2

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\font`y}{\aberrantbox}y
\end{document}

enter image description here

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

  • ...as can be seen here. – Werner Jan 6 '16 at 22:24

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.