# Relationship between strut and baselineskip

Here, it is said that a strut is defined as:

\rule[-.3\baselineskip]{0pt}{\baselineskip}


However, if I do:

\newlength{\strutheight}
\settoheight{\strutheight}{\strut}\printlength{\strutheight}
\printlength{\baselineskip}


It prints:

8.39996pt 12.0pt


8.39996 is equal to 0.7*12. However, what I don't understand is that according to its definition the height of the strut should be \baselineskip, because -.3\baselineskip only refers to a vertical alignment offset. Why does \settoheight on a \strut produces this behaviour?

The height of the whole \strut is \baselineskip, however it is lowered by 0.3\baselineskip form the baseline. Its depth plus its height totals \baselineskip:

\documentclass{article}
\begin{document}
\newlength{\strutheight}
\newlength{\strutdepth}
\settoheight{\strutheight}{\strut}
\settodepth{\strutdepth}{\strut}
$\the\strutheight+\the\strutdepth=\the\baselineskip$
\end{document}


this prints 8.39996pt + 3.60004pt = 12.0pt.

In TeX, the “height” of a box is not its total height, but the height above the baseline, and the “depth” is the amount that box goes below that baseline. And when you do \settoheight you get only the height of the box, not the total height.

You can draw the \strut and its height and depth to see:

\documentclass{article}
\begin{document}
\fboxsep0pt
\fboxrule0.1pt

\fbox{\strut}
\fbox{\rule{0pt}{0.7\baselineskip}}
\fbox{\rule[-0.3\baselineskip]{0pt}{0.3\baselineskip}}
\end{document}


Well, the definition of \strut is

% latex.ltx, line 594:
\def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi}


The code \rule[-0.3\baselineskip]{0pt}{\baselineskip} is a less efficient way to say \unhcopy\strutbox, but amounts to essentially the same. Part of the strut is below the baseline, to cope with characters with descenders like p or y.

The \strutbox is updated whenever a \fontsize command is processed:

% latex.ltx, line 2808:
\def\set@fontsize#1#2#3{%
\@defaultunits\@tempdimb#2pt\relax\@nnil
\edef\f@size{\strip@pt\@tempdimb}%
\@defaultunits\@tempskipa#3pt\relax\@nnil
\edef\f@baselineskip{\the\@tempskipa}%
\def\size@update{%
\baselineskip\f@baselineskip\relax
\normalbaselineskip\baselineskip
\setbox\strutbox\hbox{%
\vrule\@height.7\baselineskip
\@depth.3\baselineskip
\@width\z@}%
\let\size@update\relax}%
}


So the \strutbox is a box containing a zero width rule, with height 70% of the baseline skip and depth 30% of the baseline skip.

You can access the current dimensions as \ht\strutbox and \dp\strutbox:

\documentclass{article}
\begin{document}

\the\ht\strutbox\ (height)

\the\dp\strutbox\ (depth)

\the\dimexpr\ht\strutbox+\dp\strutbox\ (total)

\the\baselineskip\ (baselineskip)

\end{document}