5

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.

5
  • 1
    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.
    – Ernest A
    Jan 6, 2016 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, 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.
    – Ernest A
    Jan 6, 2016 at 22:32

1 Answer 1

4

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.

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

You must log in to answer this question.

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