TransWikia.com

How do I align this long equation?

TeX - LaTeX Asked by spandna28 on August 17, 2021

My current code is like this:

begin{multline}
Q_{K_4} =[l_1,(l_2,l_3),(l_4,l_5),(l_2,l_6,l_4),(l_5,l_6,l_3)].[l_2,l_3,(l_6,l_4),(l_6,l_5)].[l_4,l_6,l_5]
=cfrac{l_1 (l_2,l_3)(l_4,l_5) (l_2,l_4,l_6)(l_3,l_5,l_6)}{(l_1,(l_2,l_3),( l_4,l_5),(l_2,l_4,l_6),(l_3,l_5,l_6))}.cfrac{l_2 l_3(l_6,l_4) (l_5,l_6)}{(l_2,l_3(l_6,l_4),(l_6,l_5))}.[l_4,l_5,l_6]
=cfrac{(l_4,l_5)(l_5,l_6)(l_6,l_4)[l_4,l_5,l_6]l_1 l_2 l_3 ( l_2,l_3 ) (l_2,l_4,l_6) (l_3,l_5,l_6)}{((l_1,l_2,l_3,(l_4,l_5)),(l_2,l_4,l_6,(l_3,l_5,l_6)))(l_2,l_3,l_6,l_4,(l_6,l_5))}
=cfrac{l_4l_5l_6(l_4,l_5,l_6)l_1l_2l_3(l_2,l_3)(l_2,l_6,l_4)(l_5,l_6,l_3)}{ ((l_1,l_2,l_3,l_4,l_5),(l_2,l_4,l_6, l_3,l_5))(l_2,l_3,l_6,l_4,l_6,l_5)} [ (l_4l_5)(l_5,l_6)(l_6,l_4)[l_4,l_6,l_5] = l_4l_5l_6(l_4,l_5,l_6) ]
=cfrac{l_1 l_2 l_3 l_4 l_5 l_6 (l_2,l_3)(l_2,l_4,l_6)(l_3,l_5,l_6)(l_4, l_5, l_6)}{((l_1,l_2,l_3,l_4,l_5 ),(l_2,l_3,l_4, l_5,l_6))(l_2,l_3,l_4,l_5,l_6)}
end{multline}

But then it shows up like this. How do I align it properly, so that the equation number is also visible?
code image

2 Answers

I’m not sure I’m understanding what you’re asking for, but is it something like this?

documentclass{article}
usepackage{newcomputermodern} % Or your font of choice.
usepackage{amsmath} % Already loaded.

begin{document}
begin{equation}
begin{aligned}
Q_{K_4} &= [l_1,(l_2,l_3),(l_4,l_5),(l_2,l_6,l_4),(l_5,l_6,l_3)].[l_2,l_3,(l_6,l_4),(l_6,l_5)].[l_4,l_6,l_5]
        &= cfrac{l_1 (l_2,l_3)(l_4,l_5) (l_2,l_4,l_6)(l_3,l_5,l_6)}{(l_1,(l_2,l_3),( l_4,l_5),(l_2,l_4,l_6),(l_3,l_5,l_6))}.
           cfrac{l_2 l_3(l_6,l_4) (l_5,l_6)}{(l_2,l_3(l_6,l_4),(l_6,l_5))}.[l_4,l_5,l_6]
        &= cfrac{(l_4,l_5)(l_5,l_6)(l_6,l_4)[l_4,l_5,l_6]l_1 l_2 l_3 ( l_2,l_3 ) (l_2,l_4,l_6)
           (l_3,l_5,l_6)}{((l_1,l_2,l_3,(l_4,l_5)),(l_2,l_4,l_6,(l_3,l_5,l_6)))(l_2,l_3,l_6,l_4,(l_6,l_5))}
        &= cfrac{l_4l_5l_6(l_4,l_5,l_6)l_1l_2l_3(l_2,l_3)(l_2,l_6,l_4)(l_5,l_6,l_3)}{ ((l_1,l_2,l_3,l_4,l_5),
           (l_2,l_4,l_6, l_3,l_5))(l_2,l_3,l_6,l_4,l_6,l_5)}
        &qquad [ (l_4l_5)(l_5,l_6)(l_6,l_4)[l_4,l_6,l_5] = l_4l_5l_6(l_4,l_5,l_6) ]
        &= cfrac{l_1 l_2 l_3 l_4 l_5 l_6 (l_2,l_3)(l_2,l_4,l_6)(l_3,l_5,l_6)(l_4, l_5, l_6)}
           {((l_1,l_2,l_3,l_4,l_5 ),(l_2,l_3,l_4, l_5,l_6))(l_2,l_3,l_4,l_5,l_6)}
end{aligned}
end{equation}
end{document}

New Computer Modern Book Sample

Using aligned within an equation gets you aligned equations with a single number at the end.

Here is an example that combines aligned with split to give aligned, split equations. I took the liberty of indenting for readability, making outer nested parentheses and brackets larger than the ones they enclose, and changing all the fractions to frac.

documentclass{article}
usepackage{newcomputermodern} % Or your font of choice.
usepackage{amsmath} % Already loaded.

begin{document}
begin{equation}
begin{aligned}
Q_{K_4} &= begin{split} &[l_1,(l_2,l_3),(l_4,l_5),(l_2,l_6,l_4),(l_5,l_6,l_3)].
 &quad[l_2,l_3,(l_6,l_4),(l_6,l_5)].[l_4,l_6,l_5]
           end{split}
        &= begin{split} &frac{l_1 (l_2,l_3)(l_4,l_5) (l_2,l_4,l_6)(l_3,l_5,l_6)}
                               {bigl(l_1,(l_2,l_3),( l_4,l_5),(l_2,l_4,l_6),(l_3,l_5,l_6)bigr)}.
                         &quadfrac{l_2 l_3(l_6,l_4) (l_5,l_6)}{bigl(l_2,l_3(l_6,l_4),(l_6,l_5)bigr)}.[l_4,l_5,l_6]
           end{split}
        &=   frac{(l_4,l_5)(l_5,l_6)(l_6,l_4)[l_4,l_5,l_6]l_1 l_2 l_3 ( l_2,l_3 ) (l_2,l_4,l_6)
                   (l_3,l_5,l_6)}
                  {Bigl((l_1,l_2,l_3,(l_4,l_5)bigr),
                   bigl(l_2,l_4,l_6,bigl(l_3,l_5,l_6)bigr)Bigr)bigl(l_2,l_3,l_6,l_4,(l_6,l_5)bigr)}
        &= begin{split} &frac{l_4l_5l_6(l_4,l_5,l_6)l_1l_2l_3(l_2,l_3)(l_2,l_6,l_4)(l_5,l_6,l_3)}
                               { bigl((l_1,l_2,l_3,l_4,l_5), (l_2,l_4,l_6, l_3,l_5)bigr)(l_2,l_3,l_6,l_4,l_6,l_5)}
                         &quad bigl[ (l_4l_5)(l_5,l_6)(l_6,l_4)[l_4,l_6,l_5] = l_4l_5l_6(l_4,l_5,l_6) bigr]
           end{split}
        &= frac{l_1 l_2 l_3 l_4 l_5 l_6 (l_2,l_3)(l_2,l_4,l_6)(l_3,l_5,l_6)(l_4, l_5, l_6)}
                {bigl((l_1,l_2,l_3,l_4,l_5 ),(l_2,l_3,l_4, l_5,l_6)bigr)(l_2,l_3,l_4,l_5,l_6)}
end{aligned}
end{equation}
end{document}

New Computer Modern Sample

Correct answer by Davislor on August 17, 2021

Unfortunately you not provide any information about your document. So we don't know the size of textwidth, used fonts etc. This has strong influence on equation formatting (if there is enough space for equation number or it is necessary to make more breaks):

He case with bigger textwidth:

documentclass{article}
usepackage{geometry} % for bigger textwidth
usepackage{mathtools}

begin{document}
    begin{equation}label{eq:longequation}
begin{aligned}
Q_{K_4}
& = bigl[l_1,(l_2,l_3),(l_4,l_5),(l_2,l_6,l_4),(l_5,l_6,l_3)bigr]{cdot}
    bigl[l_2,l_3,(l_6,l_4),(l_6,l_5)].[l_4,l_6,l_5bigr]                                   
& = frac{l_1 (l_2,l_3)(l_4,l_5) (l_2,l_4,l_6)(l_3,l_5,l_6)}
         {bigl(l_1,(l_2,l_3),( l_4,l_5),(l_2,l_4,l_6),(l_3,l_5,l_6)bigr)}{cdot}
    frac{l_2 l_3(l_6,l_4) (l_5,l_6)}
         {bigl(l_2,l_3(l_6,l_4),(l_6,l_5)bigr)}{cdot}[l_4,l_5,l_6]                                       
& = frac{(l_4,l_5)(l_5,l_6)(l_6,l_4)[l_4,l_5,l_6]l_1 l_2 l_3 (l_2,l_3)(l_2,l_4,l_6) (l_3,l_5,l_6)}
         {bigl((l_1,l_2,l_3,(l_4,l_5)),(l_2,l_4,l_6,(l_3,l_5,l_6))bigr)
          bigl(l_2,l_3,l_6,l_4,(l_6,l_5)bigr)} 
& = begin{multlined}[t]
        frac{l_4l_5l_6(l_4,l_5,l_6)l_1l_2l_3(l_2,l_3)(l_2,l_6,l_4)(l_5,l_6,l_3)}
         {bigl((l_1,l_2,l_3,l_4,l_5),(l_2,l_4,l_6, l_3,l_5)bigr)
                (l_2,l_3,l_6,l_4,l_6,l_5)}{cdot}
         bigl[(l_4l_5)(l_5,l_6)(l_6,l_4)[l_4,l_6,l_5] = l_4l_5l_6(l_4,l_5,l_6)bigr]
    end{multlined}                                                                         
& = frac{l_1 l_2 l_3 l_4 l_5 l_6 (l_2,l_3)(l_2,l_4,l_6)(l_3,l_5,l_6)(l_4, l_5, l_6)}
         {((l_1,l_2,l_3,l_4,l_5 ),(l_2,l_3,l_4, l_5,l_6))(l_2,l_3,l_4,l_5,l_6)}
end{aligned}
    end{equation}
end{document}

enter image description here

A case with smaller (standard article) textwidth:

documentclass{article}
%usepackage{newtxmath}
usepackage{mathtools}

begin{document}
    begin{equation}label{eq:longequation}
begin{aligned}
Q_{K_4}
& = begin{multlined}[t]
    bigl[l_1,(l_2,l_3),(l_4,l_5),(l_2,l_6,l_4),(l_5,l_6,l_3)bigr]{cdot}  
    bigl[l_2,l_3,(l_6,l_4),(l_6,l_5)].[l_4,l_6,l_5bigr]                                   
    end{multlined}                                                                          
& = begin{multlined}[t]
    frac{l_1 (l_2,l_3)(l_4,l_5) (l_2,l_4,l_6)(l_3,l_5,l_6)}
         {bigl(l_1,(l_2,l_3),( l_4,l_5),(l_2,l_4,l_6),(l_3,l_5,l_6)bigr)}{cdot}
    frac{l_2 l_3(l_6,l_4) (l_5,l_6)}
         {bigl(l_2,l_3(l_6,l_4),(l_6,l_5)bigr)}{cdot}[l_4,l_5,l_6]                     
    end{multlined}                                                                          
& = frac{(l_4,l_5)(l_5,l_6)(l_6,l_4)[l_4,l_5,l_6]l_1 l_2 l_3 (l_2,l_3)(l_2,l_4,l_6) (l_3,l_5,l_6)}
         {bigl((l_1,l_2,l_3,(l_4,l_5)),(l_2,l_4,l_6,(l_3,l_5,l_6))bigr)
          bigl(l_2,l_3,l_6,l_4,(l_6,l_5)bigr)} 
& = begin{multlined}[t]
        frac{l_4l_5l_6(l_4,l_5,l_6)l_1l_2l_3(l_2,l_3)(l_2,l_6,l_4)(l_5,l_6,l_3)}
         {bigl((l_1,l_2,l_3,l_4,l_5),(l_2,l_4,l_6, l_3,l_5)bigr)
                (l_2,l_3,l_6,l_4,l_6,l_5)}{cdot}
         bigl[(l_4l_5)(l_5,l_6)(l_6,l_4)[l_4,l_6,l_5] = l_4l_5l_6(l_4,l_5,l_6)bigr]
    end{multlined}                                                                         
& = frac{l_1 l_2 l_3 l_4 l_5 l_6 (l_2,l_3)(l_2,l_4,l_6)(l_3,l_5,l_6)(l_4, l_5, l_6)}
         {((l_1,l_2,l_3,l_4,l_5 ),(l_2,l_3,l_4, l_5,l_6))(l_2,l_3,l_4,l_5,l_6)}
end{aligned}
    end{equation}
end{document}

enter image description here

Answered by Zarko on August 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP