This question already has an answer here:


\[\phantom{\ast}\hfil a\hfil\ast\]
As you can see, the \verb"\hfil"s get ignored… or at least the one on the right does. But if I swap \verb"\phantom" and \verb"\ast", I get:
\[\ast\hfil a\hfil\phantom{\ast},\]
where the \verb"\hfil" is still being ignored. Therefore I infer both are being ignored.

Why does that happen?

marked as duplicate by David Carlisle math-mode Oct 10 '14 at 20:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    It's the same as saying \hbox{a\hfil b}; display math material is typeset at its natural width, so glue doesn't stretch. – egreg Oct 10 '14 at 20:20

Saying \hfil is the same as saying \hskip 0pt plus 1fil or, in LaTeXspeak, \hspace{0pt plus 1fil}.

However, TeX uses the stretch component only if it has to. For instance, in

\hbox{a\hfil b} % Plain TeX
\makebox{a\hfil b} % LaTeX (or \mbox{a\hfil b})

the stretch component will do nothing and there will be no space between “a” and “b”. Conversely, a spacing will appear with

\hbox to 2cm{a\hfil b} % Plain TeX
\makebox[2cm][s]{a\hfil b} % LaTeX

because TeX wants to occupy the stated length.

A formula in display math is typeset at its natural width, so glue will use only the length component and not the stretch component. The length component for \hfil is zero.

If you want to fill all the available space, you should say


but it's surely better to say


using amsmath features.

Not the answer you're looking for? Browse other questions tagged or ask your own question.