3

How do I centre the equation number of a single multiline equation in a flalign environment while maintaining alignment with other equations at the equals sign?

Basically, I want this

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{flalign}
            AAA &= 2 X Y - D Z & \\
            B &= 2 X Y \left( h_1 v_1 + v_2 \right) & \nonumber  \\
                & \qquad - X^3 \left( 2 h_2 v_2 + K_2 \right) & 
\end{flalign}

\end{document}

but with the equation number (2) centred between the two lines of the second equation.

I've seen several answers to this question, but they either involve only a single multiline equation that does not need to be aligned with other equations (e.g. Have one centred equation number in the flalign enviroment), in which case the centred equation number is easily achieved using aligned or split, or it is a scenario where the expressions to the left of the equals sign of both equations just happen to have the same length and thus align naturally (e.g. Aligning multiline equation to the left with only one equation number).

Edit: here is the screenshot.

enter image description here

3
  • What do you have against using aligned or split? There's another possibility: with multlined.
    – Bernard
    Sep 15, 2021 at 11:30
  • It seems to me that maintaining the alignment with other equations at the equals sign is not possible with aligned or split (see also my comment to the answer below). If this is in fact possible, then I'm more than happy to use aligned or split. Sep 15, 2021 at 12:08
  • maintaining alignment is exactly what split (not aligned) is designed to do Sep 15, 2021 at 14:05

2 Answers 2

4

I suggest you place rows 2 and 3 inside nested aligned environments.

The following screenshot shows the outputs of both your original code and the suggested replacement code.

enter image description here

Speaking for myself, I can't help but wonder what you could possibly be trying to achieve by centering the second equation number across rows 2 and 3 of the 3-row construct. That said, I also can't fathom why you're using an flalign environment instead of an align environment.

\documentclass{article}
\usepackage{mathtools,calc,xcolor}
\newcommand\mybox[1]{%
   \parbox{\widthof{$AAA$}}{\raggedleft$\displaystyle #1 $}}
\begin{document}

\noindent
\textcolor{red}{before}
\begin{flalign}
            AAA &= 2 X Y - D Z & \\
            B &= 2 X Y \left( h_1 v_1 + v_2 \right) & \nonumber  \\
                & \qquad - X^3 \left( 2 h_2 v_2 + K_2 \right) & 
\end{flalign}

\bigskip\noindent
\textcolor{red}{after}
\begin{flalign}
       &AAA = 2 X Y - D Z & \\
       &\begin{aligned}
          \begin{aligned}
            &\mybox{B} = 2 X Y ( h_1 v_1 + v_2 )  \\
            & \qquad\qquad - X^3 ( 2 h_2 v_2 + K_2 ) 
          \end{aligned}
        \end{aligned}
\end{flalign}
    
\end{document}
5
  • I see your point about using align instead of flalign in this instance, but I don't understand your criticism regarding centring equation numbers. Anyway, I've copied your solution, but unfortunately I don't get the same output: the equations are not aligned at the equals sign. I will attach a screenshot above. Any ideas on what went wrong here? Sep 15, 2021 at 12:03
  • @cookieDestroyer - How old is your TeX distribution? If it's more than about 5 years old, you'll need to insert \! ("negative thinspace") before each instance of \begin{aligned}.
    – Mico
    Sep 15, 2021 at 12:32
  • Yep, that did the trick. Thank you for your help! Sep 15, 2021 at 12:57
  • @cookieDestroyer - If you have the opportunity to update your TeX distribution, that might be an effort worth making. :-)
    – Mico
    Sep 15, 2021 at 13:08
  • 1
    I'm planning to look into it after I'm done with my current project. Sep 16, 2021 at 4:01
4

enter image description here

split is designed for this use case, although you can get finer control with \raisetag

\documentclass{article}
\usepackage{amsmath}

\begin{document}

Original
\begin{flalign}
            AAA &= 2 X Y - D Z & \\
            B &= 2 X Y \left( h_1 v_1 + v_2 \right) & \nonumber  \\
                & \qquad - X^3 \left( 2 h_2 v_2 + K_2 \right) & 
\end{flalign}

raisetag
\begin{flalign}
            AAA &= 2 X Y - D Z & \\
            B &= 2 X Y \left( h_1 v_1 + v_2 \right) & \nonumber  \\
                & \qquad - X^3 \left( 2 h_2 v_2 + K_2 \right) & \hspace{.6\textwidth}\raisetag{22pt}
\end{flalign}


split
\begin{flalign}
            AAA &= 2 X Y - D Z & \\
            \begin{split}B &= 2 X Y \left( h_1 v_1 + v_2 \right) \\
                & \qquad - X^3 \left( 2 h_2 v_2 + K_2 \right) \end{split}
\end{flalign}

\end{document}
1
  • 1
    I left this as flalign but why "full length align` here, a standard align would seem more suitable. Sep 15, 2021 at 13:38

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.