In this example, I would expect all "MMM" to be well-aligned to each other. But they aren't:
\documentclass{article}%
\usepackage{amsmath}%
\newcommand{\before}{mmm}%
\newcommand{\after}{MMM}%
\newlength{\myplus}%
\begin{document}%
\begin{multline}%
\settowidth{\myplus}{\before}%
\the\myplus\hfill\\%
\before,\after\hfill\\%
%
\hspace{\myplus},\after\hfill\\%
\hspace*{\myplus},\after\hfill\\%
%
\setlength{\myplus}{25pt}%
\hspace{\myplus},\after\hfill\\%
\hspace*{\myplus},\after\hfill\\%
%
\hspace{25pt},\after\hfill\\%
\hspace*{25pt},\after\hfill\\%
\end{multline}%
\end{document}
In particular, \mylength
and 25pt
behave differently even after \setlength{\myplus}{25pt}
. Also, settowidth
sets the width to 25pt
, but \myplus
acts even different after that.
Why is that, and how can I achieve spacing in combination with setlength
?
Best Answer
You have set the length in a local group, so it is 0pt again on the following line, also you have set it to the width of
mmm
in the text font, but show it set in math italic,perhaps you want
outside (before) the
multline
, depending on your real use case.