# Is \hspace* equivalent to \strut\hspace?

Is using \hspace* essentially the same as \strut\hspace?

The description at \hspace vs. \hspace* seems to suggest that this may be the case, but I was wondering the cases where they might differ.

## 2 Answers

\hspace* is also valid at the beginning of a line:

\documentclass{article}
\usepackage[a6paper]{geometry}
\parindent=0pt

\begin{document}
\hrulefill\sloppy

This is a sentence which makes no sense.
\hspace{3cm} And so on \ldots

This is a sentence which makes no sense.
\hspace*{3cm} And so on \ldots

This is a sentence which makes no sense.
\strut\hspace{3cm} And so on \ldots

\end{document}


\strut is only a box with height and depth from ( and no width! The behaviour of \hspace* is similiar to \vspace* for the vertical shift.

• Oh interesting, thanks Herbert. I expected \strut\hspace would work at the beginning of a line i.e. that the strut would make the hspace no longer at said beginning of line. :) This is helpful – I was clearly confused about what the strut does. I'm also curious about the case of \hspace{1em}\strut\hspace{1em} – Brian M. Hunt Jul 28 '15 at 13:54
• \strut is the same as an invisible character/word. With \hspace{1em}\strut\hspace{1em} it is possible to split the the space if \strut appears at the beginning of a line, then the second \hspace{1em} is used. – user2478 Jul 28 '15 at 13:57
• Thanks Herbert. I would not have expected the visibility or width of the strut to determine whether it is considered present/existent from the layout perspective. Unexpected, but not really surprising. 😀 – Brian M. Hunt Jul 28 '15 at 14:11
• @BrianM.Hunt \strut does have the effect of stopping hspace being dropped at the beginning of a line, the main difference, as shown in egreg's answer with \hspace* is that as a \strut has a vertical size it can affect vertical position if it ends up being the largest thing on that line. – David Carlisle Jul 28 '15 at 16:49
• @DavidCarlisle Herbert's example in this answer seems to show that \strut does not have the effect of stopping \hspace being dropped at the beginning of the line. Am I misunderstanding in some way? – Colin McLarty Jul 29 '15 at 1:37

No, they're not the same. When you use \hspace*{1cm} (or whatever length), LaTeX transforms this into

\@hspacer{1cm}


which in turn becomes

\vrule \@width \z@ \nobreak \hskip #1\hskip \z@skip


as described in my answer to the question you linked. The rule is as high and deep as the horizontal box that eventually it is typeset in.

On the contrary, \strut does \unhcopy\strutbox, that is, it delivers the contents of a box register that also contain a zero width rule, but such that the sum of height and depth equals the (natural size of the) current baseline skip. The box register's contents is updated whenever a font size changing command (such as \normalsize, \footnotesize, \large or even \fontsize{...}{...}\selectfont) is processed, so the height and depth of \strut always (well, almost) reflects the current baseline skip. LaTeX divides the amount in 7 to 3 proportion, so if the baselineskip is 12pt, the height and depth of the strut are 8.4pt and 3.6pt respectively. See Definition of \strut explained for a subtle point about \strut, but it is relevant only if math mode is concerned.

That's the difference: the height and depth of a line where \hspace* appears is only influenced by the letters in it, more precisely by the boxes in it; with \strut\hspace{1cm} you get height and depth whose sum is at least equal to 1\baselineskip (it can be bigger if unusually large boxes are contained in the list).

Moreover, \strut\hspace{1cm} has a feasible break point between the strut and the glue, which \hspace*{1cm} hasn't. Another difference is that \strut\hspace{1cm} will disappear at the end of a paragraph (not the strut, but the glue), because TeX does \unskip there; on the other hand \hspace*{1cm} will not disappear even if \unskip is applied, because of the trailing \hskip\z@skip glue, so \unskip will cancel this and not the main glue.