1

I wish to align several equations (and center them of course) while being able to put text between them. I have the following code :

\begin{align*}
a &= b\\
c &= d
\intertext{first text working fine}
e &= \begin{aligned}[t]{} f+g+h+j &= w \\
                                x &= y
\intertext{messes things up}
                        \Aboxed{z &= 0}
\end{aligned}
\end{align*}

And it gives me this output :

enter image description here

It is the second \intertext{} command that does this but I didn't find a way to replace it.

How can I center my equations ?

Does someone have a clue of how I can put text in this situation ? And how can I choose if it goes all the way to the left or not all the way ?

If I remove that \intertext{messes things up} line, everything is nicer :

enter image description here

9
  • 2
    Intertext is not supported inside aligned, I think I should give you an error
    – daleif
    Commented May 11, 2019 at 13:03
  • 1
    The only error I get is "Overfull \hbox (18.61911pt too wide) in paragraph at lines 19--19" Here is a link : overleaf.com/read/tcyvdtxsnddt
    – Sileo
    Commented May 11, 2019 at 13:16
  • To me it looks fine. The second \intertext is part of the aligned environment, the reason why the text starts at the left margin of aligned which is vertically aligned to the f
    – user187802
    Commented May 11, 2019 at 13:20
  • Please tell us how (or in which package) \Aboxed is defined.
    – Mico
    Commented May 11, 2019 at 13:20
  • Where do you wish the argument of the second \intertext directive to be placed?
    – Mico
    Commented May 11, 2019 at 13:22

1 Answer 1

1

Using alignat* solves the problem:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
a &= b\\
c &= d
\intertext{first text working fine}
e &=  f &{}+g+h+j &= w \\
     & & x &= y \\
\intertext{doesn’t mess things any more}
      & & \Aboxed{z &= 0}
\end{alignat*}

\end{document} 

enter image description here

9
  • I don't know enough inner details of aligned to say. Is there any problem with alignat* w.r.t. your real equations?
    – Bernard
    Commented May 11, 2019 at 13:43
  • Yes, I tried it but there is a space between the e= and the f. I think it is because of the d above. In my equations, the space is much bigger, because the d term takes more space
    – Sileo
    Commented May 11, 2019 at 14:00
  • Oh! I didn't notice it. I'll try to see what can be done.
    – Bernard
    Commented May 11, 2019 at 14:03
  • I've moved & just after the letter f, added a pair of braces right after, and it seems to be fine now.
    – Bernard
    Commented May 11, 2019 at 14:16
  • works in this example but I've a long fraction instead of f+g+h+j and now the space is before the =w. you can try by replacing e &= f &{}+g+h+j &= w \\ with e &= \frac{\beta}{\sqrt{1-\beta ^2}} &{} & =w\\
    – Sileo
    Commented May 11, 2019 at 14:25

You must log in to answer this question.

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