Get a box with zero depth including some text

You can use \raisebox to modify the official height and depth of some text:

\raisebox{0pt}[\height][0pt]{<text>}

This raises the text by 0pt (so not at all), keeps the official height identical to the original height and sets the depth to 0pt.


\smash{great} is a box with zero height and no depth

\documentclass{article}
\usepackage{amsmath}
\newsavebox\SBox
\begin{document}
\sbox\SBox{great}%
\the\wd\SBox\\
\the\ht\SBox\\
\the\dp\SBox

\sbox\SBox{\smash{great}}%
\the\wd\SBox\\
\the\ht\SBox\\
\the\dp\SBox

\sbox\SBox{\smash[b]{great}}%% Needs amsmath
\the\wd\SBox\\
\the\ht\SBox\\
\the\dp\SBox

\end{document}

enter image description here


I don't know exactly what you want to do but if you want a special box with special dim then you can try :

\newbox\mybox
\setbox\mybox=\hbox{}
\ht\mybox=10mm \dp\mybox=0pt \wd\mybox=20mm

But If you put some text in your initial \hbox, you can have some strange results ! When you make a box with some contents, height, depth and width depend of the context.

Tags:

Boxes