4
$\begingroup$

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.)

$\endgroup$
2
  • 1
    $\begingroup$ 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. $\endgroup$ Nov 10 at 22:06
  • $\begingroup$ @DavideCervone, thanks! $\endgroup$
    – LSpice
    Nov 10 at 23:02

1 Answer 1

5
$\begingroup$

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.

$\endgroup$
4
  • 1
    $\begingroup$ Probably this is related: github.com/mathjax/MathJax/issues/1700 ? $\endgroup$ Nov 8 at 10:50
  • $\begingroup$ 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. $\endgroup$ Nov 10 at 19:21
  • 1
    $\begingroup$ @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. $\endgroup$ Nov 10 at 22:03
  • $\begingroup$ Oh yes, sorry, you are right. $\endgroup$ Nov 10 at 22:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .