I was trying to centre some math within an enumerate list, without a lineskip.
I eventually found this discussion of \hfill
vs \hspace*{\fill}
which seems to suggest that using \hspace*{\hfill}
will avoid space on the RHS being gobbled up; however, when I implement it, I don't get any difference in rendering between the two.
NB: I resolved the specific issue by including a \null
, but would like to know what misunderstanding is leading me to expect different output,
i.e. why does \hspace*{\hfill}
still require \null
to not gobble right-hand-side space?
MWE:
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}
\item \hspace*{\fill} %
% Some math content
$y(x) = a_o + a_1 (x-k) + a_2(x-k)^2 + a_3(x-k)^3 + a_4(x-k)^4$
%
\hspace*{\fill}
%
\item \hspace*{\fill} %
% Some math content
$y(x) = a_o + a_1 (x-k) + a_2(x-k)^2 + a_3(x-k)^3 + a_4(x-k)^4$
%
\hspace*{\fill}\null
\end{enumerate}
\end{document}
Notice the difference between the first line (without \null
) and the second line (with \null
):
\hfill
or\hspace
, but they don't appear as options...\null
serves no purpose.\null
and you'll see that the output is exactly the same.item
following the final\hspace{\fill}
).