# What is a supported use of \hfill?

According to Supported TeX/LaTeX commands, \hfill is supported. However, as expected, it doesn't work in ordinary text \hfill ; and using it in math mode seems to produce "Unsupported use of \hfill" in inline mode $$\hfill$$ or in display mode $$\hfill .$$ What is a supported use of \hfill?

(EDIT: I see "Unsupported use of \hfill" while authoring the post, but, on rendering, it seems to become just the word "\hfill" in an \fbox.)

• You note that 'I see "Unsupported use of \hfill" while authoring the post, but, on rendering, it seems to become just the word "\hfill" in an \fbox'. This is because during editing, MathJax's error messages are displayed, but for finished posts, if an expression contains a TeX error, the original TeX is shown in a box, since it is usually more helpful to a reader to get to see what the author was trying to say rather than the error message. Nov 10, 2022 at 22:06
• @DavideCervone, thanks! Nov 10, 2022 at 23:02

MathJax doesn't have the idea of stretchable glue that TeX uses to implement \hfill, so it can only be used in limited situations in MathJax, namely at the beginning of end of table cells in order to change the default alignment of the cell. So you can use

$$\begin{array}{cc} aaa & bbb\\ a \hfill & \hfill b \\ a & b \end{array}$$


to change the centering to left and right alignment on the middle row.

$$\begin{array}{cc} aaa & bbb\\ a \hfill & \hfill b \\ a & b \end{array}$$

Since MathJax only processes math-mode material, it never even sees the \hfill you used in the main text of your post, so that certainly is not a supported use (no macro other than \begin, \ref, and \eqref) are processed outside of math delimiters).

Inside math, it only makes sense to use \hfill inside a box that is larger than the math it contains, and those are hard to come by in MathJax, since it doesn't support \hbox to <dimen> or other similar constructs. Table cells is one of the few places that can happen, and even there, the use of \hfill is only allowed at the ends (not the interior) of the cell.

• Probably this is related: github.com/mathjax/MathJax/issues/1700 ? Nov 8, 2022 at 10:50
• Since MathJax only processes math-mode material, it never even sees the \hfill you used in the main text of your post That hfill is in math-mode though; inline math mode to be precise. Nov 10, 2022 at 19:21
• @FedericoPoloni, I was referring to the one mentioned as "it doesn't work in ordinary text \hfill" that was before the OP talked about using it in math mode. Nov 10, 2022 at 22:03
• Oh yes, sorry, you are right. Nov 10, 2022 at 22:40