6

Couldn't find any answer to this question on anywhere. I have this one particular solution in my hands, which helps only if the equation to be disregarded for alignment is the first or the last of the array of equations, which is simply:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
    \begin{gather} % or gather*
        2 + 5 + 123 + 45 = 175\\ % the equation I am taking out of alignment
        \begin{aligned}
             2 + 3 &= 5\\
            11 + 5 &= 16
        \end{aligned}
    \end{gather}
\end{document}

Which doesn't really look good to my eyes. Works though; works exactly as I hoped it to, and looks exactly as I wanted it to.

Then again, what would be the proper way to do it, which preferably also manages to deal with a not-aligned equation in between, rather than just at the beginning or the end? Heard and read about this ancient \noalign command, but also read that it is not supported or something like that.

  • 4
    You are are lot more likely to get help if you do as Jubobs ask. Then those answering does not have to add anything to the mwe, they can copy it and work on it immediately. – daleif Dec 28 '14 at 21:44
  • 4
    Just one line in your preamble that you don't tell us about can affect the answer. A MWE is almost always useful because it (and your typesetting engine, e.g. pdflatex) unambiguously tells us what the problem is. A question without an MWE is, in many cases, akin to asking what the sound of one hand clapping is like. – jub0bs Dec 28 '14 at 21:45
  • 2
    Exactly, there have been so many cases here, where users have not told everything resulting in tedious commenting back and forth until we reached an mwe that actually showed the real problem. – daleif Dec 28 '14 at 21:47
  • 2
    @ThoAppelsin I'm not much for counterfactual history, but I can tell you that I wouldn't have upvoted your answer if you hadn't edited it to add an MWE. Consider it a form of politeness (see daleif's earlier comment). I can assure you that, on TeX.SE, you'll be much better off if you endeavour having an MWE in your question. I rest my case. – jub0bs Dec 28 '14 at 21:51
  • 3
    I would also add that it should be common decency to make a question as easy as possible to answer. Some questions can be answered of the top of your head. But whenever I'm at a computer, I always compile and test before I answer. So by providing something that compiles without additions makes my time more worthwhile to spend on a question. – daleif Dec 28 '14 at 21:55
7

You can use \mathclap from the mathtools package:

enter image description here

References:

Code:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{align}
    \mathclap{2 + 5 + 123 + 45 = 175}\\ % the equation I am taking out of alignment
         2 + 3 &= 5\\
        11 + 5 &= 16
\end{align}
\end{document}
  • Much better than mine, and works if the unaligned equation is in the middle, too. – Mike Renfro Dec 28 '14 at 22:11
  • If one combined it with environ one could turn this into an centeredeq env instead of having to wrap it in a macro (thus hiding the macro) – daleif Dec 28 '14 at 22:14
  • I am not certain about what \mathclap does, but I guess it places the equation inside into a zero-width box, then centres its contents, is that right? Nice looking by the way, thanks for that. – ThoAppelsin Dec 28 '14 at 22:17
  • One caveat to this solution: if the eq is long, align will not know and will not move the eq number – daleif Dec 28 '14 at 22:17
  • @ThoAppelsin: Yep that is exactly what it does. Have added a link where this and other related macros are described in more detail. – Peter Grill Dec 28 '14 at 23:15
1

The first alternative below is close, but not perfect (and definitely an abuse of \intertext). No equation number is added to the middle equation as a result. The second alternative (from Center one equation of many in align?) puts all the unaligned content to one side of the alignment character, which probably isn't desirable.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
2 + 3 &= 5
\intertext{\centering\(2 + 5 + 123 + 45 = 175\)}
11 + 5 &= 16
\end{align}
\begin{align}
2 + 3 &= 5 \\
\begin{gathered}2 + 5 + 123 + 45 = 175\end{gathered} \\
11 + 5 &= 16
\end{align}
\end{document}

enter image description here

  • Mike, could you retry (I'm not at pc) and use the gathered env instead of the intertext? There was a question about this very thing earlier today, where the answer used gathered (AFAIR) – daleif Dec 28 '14 at 21:58
  • 1
    It's not the same result, since the gathered content goes on one side of the alignment character. Will edit accordingly, maybe there's a tweak to be made yet. – Mike Renfro Dec 28 '14 at 22:00
  • No it doesn't, see this answer tex.stackexchange.com/a/165014/3929 – daleif Dec 28 '14 at 22:01
  • 1
    There, I see 'and if we remove dog' all to the left of the '=' signs on equations 1, 2, and 4. That's what I meant. – Mike Renfro Dec 28 '14 at 22:04
  • No, you're right, didn't read the comments carefully enough. I think I'd see if I could turn Peters answer into an environment (as I like that better as an interface) – daleif Dec 28 '14 at 22:10

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.