8
\begin{alignat*}{3}
  a &= b &+& c &+& d\\
  b &= b &+& c &+& d\\
  c &= b &+& c &+& d\\
  aoeu &= \mathrm{something long here}
\end{alignat*}

produces

MWE

How do I remove the space circled in red while keeping the "=" signs circled in green aligned? (Also, I want the "+" signs aligned.)

4
  • How should the "a", "b", "c", and "d" elements be aligned in their respective columns: left-aligned, centered, or right-aligned? Please advise.
    – Mico
    May 18, 2018 at 21:43
  • @Mico left-aligned (so there's no space between the "+" and "c" of "+c" or between the "+" and "d" of "+d")
    – Geremia
    May 18, 2018 at 23:53
  • Thanks for this reply; I've adjusted the code in my answer accordingly.
    – Mico
    May 19, 2018 at 4:55
  • You've actually applied the & separators here in the manner appropriate for the array environment, not align. If you do want to use align in the future, you should read the documentation for the amsmath package (texdoc ams;doc). Mar 17, 2021 at 14:13

2 Answers 2

10

I am assuming that your real equation contains more thrilling entries than a, b, c, and d. If that's the case, you may be better off employing a flexible array environment.

enter image description here

\documentclass{article}
\usepackage{array} % for '\newcolumntype' macro
\newcolumntype{C}{>{{}}c<{{}}} % for binary and relational operators
\newcolumntype{L}{>{\displaystyle}l} % automatic display-style math mode, left-aligned
\newcolumntype{R}{>{\displaystyle}r} % automatic display-style math mode, right-aligned
\begin{document}
\[
\setlength\arraycolsep{0pt}
\renewcommand\arraystretch{1.2} % to emulate vert. spacing of 'align' env.
\begin{array}{RCLCLCLl} % the final column is a "dummy" column
  a &=& b &+& c &+& d\\
  b &=& b &+& c &+& d\\
  c &=& b &+& c &+& d\\
  aoeu &=& \multicolumn{6}{l}{\mbox{something long here}}
\end{array}
\]
\end{document}
5
  • 2
    I'd add the local setting \renewcommand{\arraystretch}{1.2} to better emulate align*.
    – egreg
    May 18, 2018 at 20:21
  • 1
    @egreg - Many thanks for the suggestion. I took it on board right away. :-)
    – Mico
    May 18, 2018 at 20:37
  • I tried using this code, and it got stuck in an infinite loop. I think there’s a typo in line 4, which should be \newcolumntype{L}{>{\displaystyle}l}.
    – bradrn
    Mar 17, 2021 at 13:04
  • @bradrn - Many thanks for contacting me and poiting out the problem. You're absolutely right, it should have been l, not L. I've fixed the code.
    – Mico
    Mar 17, 2021 at 13:12
  • Thanks for the quick reply @Mico! Seems to be working now.
    – bradrn
    Mar 17, 2021 at 13:43
10

As I don't know the real stuff that will be in your alignat* environment, I kept the three alignment columns. A solution consists in putting the r.h.s. of the last row in an \rlap command, which makes it have 0 width. In case this r.h.s. were a maths formula, mathtools defines a \mathrlap command, which has the same effect in math mode:

\documentclass[11pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{3}
  a &= b &{}+{}& c &{}+{}& d\\
  b &= b &{}+{}& c &{}+{}& d\\
  c &= b &{}+{}& c &{}+{}& d\\
  aoeu &= \rlap{something long here}\\
 a & =\mathrlap{\frac{-b\pm\sqrt{b^2-4ac}}{2a}}
\end{alignat*}

\end{document}

enter image description here

4
  • 1
    you lose the \mathbin spacing of + with &+& May 18, 2018 at 19:31
  • @DavidCarlisle: Oh! yes. I didn't notice it as I focused on the extra spacing. I'll fix that in a moment. Thanks for pointing it!
    – Bernard
    May 18, 2018 at 19:53
  • You lose the proper centering.
    – egreg
    May 18, 2018 at 20:21
  • @egreg: That's right with the present code. With the real code, I don't know: either it may be unimportant (e.g. one wants to have only the significant part of the alignment centred, or it will be compensated by some formula.In each case, I think it's a matter of lavorazione a mano.
    – Bernard
    May 18, 2018 at 20:36

You must log in to answer this question.

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