The LaTeX reference card states for example
\strut
box w/ ht and depth of “(”, zero width
I came to see text as a two dimensional feature, but I must be missing out on something...
(following was off-topic: by the way, im trying to find documentation on how to use \vbox
, \hbox
,… i.e. to align a hbox within a vbox to the right)
I made the following diagram for the adjustbox
bundle. It will be part of the
trimclip
manual
[1] (The trimclip
package will be an extracted part of the current adjustbox
package).
As you can see the text lies on the baseline, the height is everything above it and the depth everything below it. Usually only some lower-case character and punctuation go below it. Both together is the totalheight. Note that the coordinate system for the depth is going down, i.e. it is always positive. The width is the normal width of the content.
The macros in the document show how to access these values in LaTeX macros like \raisebox
(first line) or with a TeX box register called \br
here (second line).
There are further diagram which explain the trimming and clipping of boxes. The current work-in-progress version of the manual with this diagrams can be downloaded as PDF [2] from the code repository [3]. The source code for this and all other diagrams [4] are also available.
[1] https://ctan.math.illinois.edu/macros/latex/contrib/adjustbox/trimclip.pdf\height
is also used in the LaTeX kernel for \ht\@tempboxa
. So I think it can be a little bit irritate. - Marco Daniel
\height
is usually \ht\@tempboxa
or \ht\someotherboxregister
, same for \width
and \depth
. Only for \totalheight
a temporary length register is used. These macros are just a higher-level LaTeX interface to the lower-level TeX code. - Martin Scharrer
This is what you want:
And use the height and width of (
for \structbox
:
You may need to read the TeXbook or similar books for Plain TeX (esp. free books
TeX for the Impatient
[1] and
TeX by Topic
[2]) to understand the \hbox
and \vbox
well.
Indeed for TeX letters are three dimensional objects. TeX lines up characters at their baseline, what goes below the baseline is their depth.
As
Feynman
[1] once explained there are always different perspectives to out common understanding -- in this case -- the words three dimensional. For metafont
there are multitude of dimensions describing a particular letter. Use the package layouts
to see the values and generate the image above.
\documentclass{article}
\usepackage{layouts}
\begin{document}
\printparameterstrue
\drawfontframelabel{\Huge\textbf{tangling}}
\fbox{\Huge m}\fbox{\Huge g}\fbox{\Huge t}
\end{document}
[1] http://lesswrong.com/r/discussion/lw/99c/transcript_richard_feynman_on_why_questions/#thingrow_t3_99cIn TeX speak, every "box" -- think of a rectangle, except that the rectangle could have one or more of its "dimensions" set equal to zero -- has height, depth, and width. The width part has the obvious meaning, being measured along the horizontal axis. The height of a box is measured up from the baseline, and its depth is measured down from the baseline. (One could refer to the sum of the height and depth of a box as its "total" height.) For typesetting purposes, it's essential to know both the height and depth of a box because when TeX creates a line of text out of a series of boxes, the boxes need to be aligned on the baseline.
Two quick examples. The box that contains the lowercase letter x
has positive height and width but zero depth because the letter doesn't reach below the baseline. The lowercase letter j
, in contrast, would be encased by a box that has positive height, width, and depth because it has a descender (a component that reaches below the baseline).
The strut
you bring up in your question is a special TeX box which has the height and depth of the parenthesis symbol -- (
-- but has zero width and is therefore invisible. Being able to insert such a special box is a very handy typographic tool, because it forces the box that encloses it and the other ("real") items in the group of boxes to have at least the height and depth of a parenthesis.
The following code demonstrates how inserting struts can make the output look more polished. (The formula I've come up with is obviously highly contrived!)
In the first version of the formula, all three surds (the square-root symbols) have different depths and heights. The formula's appearance isn't exactly dreadful, but there's a distracting element: whereas the q
, x
, and k
symbols are nicely aligned along the baseline, the three surds provide a second "line of sight" that rises at a slight diagonal from left to right.
In the second formula, inserting a \mathstrut
-- TeX's \mathstrut
generates a "box" that has the same height and depth as a parenthesis and has zero width -- inside the arguments of the three \sqrt
macros makes the surds all have the same height and depth. As a result, the "line of sight" created by the three surds is now also perfectly horizontal.
Hopefully, then, the insertion of the struts will make for a more polished and thereby more visually pleasing appearance of the overall formula.
\documentclass{article}
\begin{document}
\noindent
A simple formula without struts \ldots
\[\sqrt{q} = \sqrt{x} + \sqrt{k}\]
\ldots\ and with struts.
\[\sqrt{\mathstrut q} = \sqrt{\mathstrut a} + \sqrt{\mathstrut k}\]
\end{document}
The following image is inspired by an image from the TeXBook and shows the different parameters:
For more information about commands like \hbox
and \vbox
you can have a look at The TeXBook or TeX by Topic (or any other number of TeX related books, I assume).
height
and (possibly) drops below it bydepth
. For instance, thep
has a depth. Thewidth
is just the width of the text. For documentation on\vbox
\hbox
etc. you can have a look at TeX by Topic. - Roelof SpijkerTeX by Topic
is a good starting point. Also, for in-depth explanation I'd recommendThe TeXbook
. For a simple explanation on struts and text height, checkThe Not So Short Introduction to LaTeX
, especially pages 49 and 133-136. - Count Zero\vbox
and\hbox
, as this topic isn't very closely related to that of the dimensions of a TeX box. - Mico