2

I created a new command \mathloose that stretches the spacing in an equation by suitably adjusting \thinmuskip \medmuskip and \thickmuskip lengths. The command works just fine in \[ \] and \( \) but does nothing in align environment.

Here is a mwe:

\documentclass{article}
\usepackage{amsmath}
\newcommand\mathloose
{
\thinmuskip=5mu   %Unary operator-arg   sin·x   Default: 3mu
\medmuskip=7mu    %Binary operator-LR   x·+·y   Default: 4mu
\thickmuskip=15mu  %Relations-LR         x·=·y   Default: 5mu plus 5mu
}

\begin{document}
\[
a=b + \sin x
\]
\[
\mathloose
a=b + \sin x
\]

\begin{align*}
a= & b + \sin x
\end{align*}
\begin{align*}
\mathloose
a= & b + \sin x
\end{align*}
\end{document}

And this is the output (removing the & separator in align does not solve the issue):

enter image description here

Is it because align uses different skip lengths or am I doing something wrong?

Extra question: Is there a way to make the separator & in align respect the spacing of relation symbols? You may notice that the spacings on the left and on the right of the = sign in the aligned equations are different, which is caused by the & being placed immediately after =. A solution could be writing a=&\;b but I am looking for more automatic ways to deal with it. Is it doable?

  • 2
    The extra question is solved by a&=b which is the documented syntax. – LaRiFaRi Mar 10 '15 at 10:43
  • 1
    For the extra question you can just use = {} &, then = just sees & after it, it does not add any spacing, and you get the effect you describe. – daleif Mar 10 '15 at 11:11
4

First of all, you have to put the & separator in front of the equal sign in order to get the align properly working.

The problem for you MWE is that your new command does not know where to be applied to as the align environment splits the equation into several cells (columns/terms). You will have to set the command in front of your align. In order to change the spacing just locally, you should surround it by \begingroup\endgroup. (Braces will work as well, I guess)

Please note that I have added a % in your command definition. This is mandatory here. Without it, you will get a line break when using your command outside an equation (like I did here).

% arara: pdflatex

\documentclass{article}
\usepackage{amsmath}
\newcommand\mathloose
{%
    \thinmuskip=5mu   %Unary operator-arg   sin·x   Default: 3mu
    \medmuskip=7mu    %Binary operator-LR   x·+·y   Default: 4mu
    \thickmuskip=15mu  %Relations-LR         x·=·y   Default: 5mu plus 5mu
}

\begin{document}
    \begin{align*}
    a &=  b + \sin x
    \end{align*}
    \begingroup
    \mathloose
    \begin{align*}
    a &=  b + \sin x
    \end{align*}
    \endgroup
\end{document}

enter image description here


Also your question in comment is typographically questionable, I try to help you here:

The align environment basically uses this template in order to do the spacing for you.

\hfil $\displaystyle #$ & $\displaystyle {}#$ \hfil

You can see here, why your command did not work in the first place. The cells of your align are wrapped each in $$ and are therefore not reachable. If you want to redefine your right hand side only, I would manually set your aligned formula in a tabular, put the equal sign to the left hand side, and apply your command to the right column.

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}
\usepackage{array}
\newcommand\mathloose
{%
    \thinmuskip=12mu   %Unary operator-arg   sin·x   Default: 3mu
    \medmuskip=7mu    %Binary operator-LR   x·+·y   Default: 4mu
    \thickmuskip=15mu  %Relations-LR         x·=·y   Default: 5mu plus 5mu
}

\begin{document}
    \begin{align*}
    a &=  b + \sin x
    \end{align*}
    \[\begin{tabular}{@{}r@{}>{\mathloose}l@{}}
    \hfil $\displaystyle a ={}$ & $\displaystyle {} b + \sin x$ \hfil
    \end{tabular}\]
\end{document}

enter image description here

  • Thank you, but what if I am interested in modifying just a single line/cell (e.g. to shrink a long rhs)? Is it possible? – AndreasT Mar 10 '15 at 10:55
  • 3
    @AndreasT, you should not. Rewrite, break the line. Normal users should not mess with those three setting at all. – daleif Mar 10 '15 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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