align is aligning to the right












3















I would like to align the + and the if's below eachother but for some reason the ifs all get aligned to the right even though I used the &. I don't understand why this is happening and I would like to know how to fix it such that the ifs come under each other.



documentclass[12pt]{article}
usepackage{amsmath}

begin{document}

begin{equation*}
left{begin{align*}
f(x) quad &+ quad g(x) & text{ if } f(x)geq 0 text{, } g(x) geq 0 \
0 quad &+ quad 0 & text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
f(x)-(-g(x)) quad &+ quad 0 & text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
0 quad &+ quad 0 & text{ if } f(x)<0 text{, } g(x)< 0 \
end{align*}
right.
end{equation*}


align










share|improve this question







New contributor




Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Maybe you have to use something other than align.

    – JouleV
    yesterday











  • Welcome to TeX.SE! You should not have begin{align*} inside begin{equation*}... end{equation*} , did you mean to use aligned?

    – marmot
    yesterday











  • I did use aligned before, I tried to use align as a fix but didn't work either.

    – Jannes Braet
    yesterday
















3















I would like to align the + and the if's below eachother but for some reason the ifs all get aligned to the right even though I used the &. I don't understand why this is happening and I would like to know how to fix it such that the ifs come under each other.



documentclass[12pt]{article}
usepackage{amsmath}

begin{document}

begin{equation*}
left{begin{align*}
f(x) quad &+ quad g(x) & text{ if } f(x)geq 0 text{, } g(x) geq 0 \
0 quad &+ quad 0 & text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
f(x)-(-g(x)) quad &+ quad 0 & text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
0 quad &+ quad 0 & text{ if } f(x)<0 text{, } g(x)< 0 \
end{align*}
right.
end{equation*}


align










share|improve this question







New contributor




Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Maybe you have to use something other than align.

    – JouleV
    yesterday











  • Welcome to TeX.SE! You should not have begin{align*} inside begin{equation*}... end{equation*} , did you mean to use aligned?

    – marmot
    yesterday











  • I did use aligned before, I tried to use align as a fix but didn't work either.

    – Jannes Braet
    yesterday














3












3








3








I would like to align the + and the if's below eachother but for some reason the ifs all get aligned to the right even though I used the &. I don't understand why this is happening and I would like to know how to fix it such that the ifs come under each other.



documentclass[12pt]{article}
usepackage{amsmath}

begin{document}

begin{equation*}
left{begin{align*}
f(x) quad &+ quad g(x) & text{ if } f(x)geq 0 text{, } g(x) geq 0 \
0 quad &+ quad 0 & text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
f(x)-(-g(x)) quad &+ quad 0 & text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
0 quad &+ quad 0 & text{ if } f(x)<0 text{, } g(x)< 0 \
end{align*}
right.
end{equation*}


align










share|improve this question







New contributor




Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I would like to align the + and the if's below eachother but for some reason the ifs all get aligned to the right even though I used the &. I don't understand why this is happening and I would like to know how to fix it such that the ifs come under each other.



documentclass[12pt]{article}
usepackage{amsmath}

begin{document}

begin{equation*}
left{begin{align*}
f(x) quad &+ quad g(x) & text{ if } f(x)geq 0 text{, } g(x) geq 0 \
0 quad &+ quad 0 & text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
f(x)-(-g(x)) quad &+ quad 0 & text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
0 quad &+ quad 0 & text{ if } f(x)<0 text{, } g(x)< 0 \
end{align*}
right.
end{equation*}


align







align






share|improve this question







New contributor




Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Jannes BraetJannes Braet

1183




1183




New contributor




Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Jannes Braet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Maybe you have to use something other than align.

    – JouleV
    yesterday











  • Welcome to TeX.SE! You should not have begin{align*} inside begin{equation*}... end{equation*} , did you mean to use aligned?

    – marmot
    yesterday











  • I did use aligned before, I tried to use align as a fix but didn't work either.

    – Jannes Braet
    yesterday



















  • Maybe you have to use something other than align.

    – JouleV
    yesterday











  • Welcome to TeX.SE! You should not have begin{align*} inside begin{equation*}... end{equation*} , did you mean to use aligned?

    – marmot
    yesterday











  • I did use aligned before, I tried to use align as a fix but didn't work either.

    – Jannes Braet
    yesterday

















Maybe you have to use something other than align.

– JouleV
yesterday





Maybe you have to use something other than align.

– JouleV
yesterday













Welcome to TeX.SE! You should not have begin{align*} inside begin{equation*}... end{equation*} , did you mean to use aligned?

– marmot
yesterday





Welcome to TeX.SE! You should not have begin{align*} inside begin{equation*}... end{equation*} , did you mean to use aligned?

– marmot
yesterday













I did use aligned before, I tried to use align as a fix but didn't work either.

– Jannes Braet
yesterday





I did use aligned before, I tried to use align as a fix but didn't work either.

– Jannes Braet
yesterday










4 Answers
4






active

oldest

votes


















1














The first, third, fifth, ... & left-align the following expressions, while the second, fourth, sixth, ... & right-align the following expressions. Your solution here: Use && instead of & at the second appearance in each line:



documentclass[12pt]{article}
usepackage{amsmath}
begin{document}
begin{equation*}
left{begin{aligned}
f(x) quad &+ quad g(x) && text{ if } f(x)geq 0 text{, } g(x) geq 0 \
0 quad &+ quad 0 && text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
f(x)-(-g(x)) quad &+ quad 0 && text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
0 quad &+ quad 0 && text{ if } f(x)<0 text{, } g(x)< 0 \
end{aligned}right.
end{equation*}
end{document}


enter image description here






share|improve this answer
























  • Does this also extend to &&& if theres another thing to align on ?

    – Jannes Braet
    yesterday











  • No. If you only care about left-aligning stuff, then the first occurence gets a single & and every consequent one a &&.

    – Tiuri
    12 hours ago



















4














I see no reason for aligning at the + sign, but perhaps you have.



documentclass[12pt]{article}
usepackage{amsmath}

begin{document}

Alignment at $+$
begin{equation*}
begin{cases}
begin{alignedat}{2}
f(x) &+ g(x) &qquad& text{if $f(x)geq 0$, $g(x)geq 0$} \
0 &+ 0 &qquad& text{if $f(x)geq 0$, $g(x) < -f(x)$} \
f(x)-(-g(x)) &+ 0 &qquad& text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
0 &+ 0 &qquad& text{if $f(x)<0$, $g(x)< 0$}
end{alignedat}
end{cases}
end{equation*}

Better with no artificial alignment?
begin{equation*}
begin{cases}
f(x) + g(x) & text{if $f(x)geq 0$, $g(x)geq 0$} \
0 + 0 & text{if $f(x)geq 0$, $g(x) < -f(x)$} \
f(x)-(-g(x)) + 0 & text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
0 + 0 & text{if $f(x)<0$, $g(x)< 0$}
end{cases}
end{equation*}

end{document}


enter image description here



The top display could have been simply managed with aligned, but because of the alignment at +, I think it's better to have more space between the two parts. Try with aligned and && instead of &qquad&.






share|improve this answer































    2














    That's the normal behaviour if you specify alignment points with an ampersand: it is implicitly added at the end of each line. Furthermore, n columns of alignment require 2n–1 ampersands: one ampersang to introduce each new column but the first, and one ampersand to set the alignment point inside that column.



    I also propose a simpler code, with the empheq package (wich loads amthtools, which loads amsmath). I suppose this is what you want:



    documentclass[12pt]{article}
    usepackage{empheq}

    begin{document}

    begin{empheq}[left=empheqlbrace]{align*}
    f(x) quad &+ quad g(x) &text{ if }& f(x)geq 0, g(x) geq 0 \
    0 quad &+ quad 0 & text{ if } & f(x)geq 0 , g(x) < -f(x) \
    f(x)-(-g(x)) quad &+ quad 0 & text{ if } & f(x)geq 0 , -f(x) leq g(x) < 0 \
    0 quad &+ quad 0 & text{ if } & f(x)<0 , g(x)< 0 \
    end{empheq}

    end{document}


    enter image description here






    share|improve this answer































      1














      with use of array:



      documentclass[12pt]{article}
      usepackage{array}
      usepackage{amsmath}

      begin{document}
      [setlengtharraycolsep{2pt}
      left{begin{array}{rcl @{qquad}r l}
      f(x) & + & g(x) & text{if } & f(x)geq 0, g(x) geq 0 \
      0 & + & 0 & text{if } & f(x)geq 0, g(x) < -f(x) \
      f(x)-(-g(x)) & + & 0 & text{if } & f(x)geq 0, -f(x) leq g(x) < 0 \
      0 & + & 0 & text{if } & f(x)<0 , g(x)< 0 \
      end{array}right.
      ]

      end{document}


      enter image description here






      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "85"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });






        Jannes Braet is a new contributor. Be nice, and check out our Code of Conduct.










        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475841%2falign-is-aligning-to-the-right%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        The first, third, fifth, ... & left-align the following expressions, while the second, fourth, sixth, ... & right-align the following expressions. Your solution here: Use && instead of & at the second appearance in each line:



        documentclass[12pt]{article}
        usepackage{amsmath}
        begin{document}
        begin{equation*}
        left{begin{aligned}
        f(x) quad &+ quad g(x) && text{ if } f(x)geq 0 text{, } g(x) geq 0 \
        0 quad &+ quad 0 && text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
        f(x)-(-g(x)) quad &+ quad 0 && text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
        0 quad &+ quad 0 && text{ if } f(x)<0 text{, } g(x)< 0 \
        end{aligned}right.
        end{equation*}
        end{document}


        enter image description here






        share|improve this answer
























        • Does this also extend to &&& if theres another thing to align on ?

          – Jannes Braet
          yesterday











        • No. If you only care about left-aligning stuff, then the first occurence gets a single & and every consequent one a &&.

          – Tiuri
          12 hours ago
















        1














        The first, third, fifth, ... & left-align the following expressions, while the second, fourth, sixth, ... & right-align the following expressions. Your solution here: Use && instead of & at the second appearance in each line:



        documentclass[12pt]{article}
        usepackage{amsmath}
        begin{document}
        begin{equation*}
        left{begin{aligned}
        f(x) quad &+ quad g(x) && text{ if } f(x)geq 0 text{, } g(x) geq 0 \
        0 quad &+ quad 0 && text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
        f(x)-(-g(x)) quad &+ quad 0 && text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
        0 quad &+ quad 0 && text{ if } f(x)<0 text{, } g(x)< 0 \
        end{aligned}right.
        end{equation*}
        end{document}


        enter image description here






        share|improve this answer
























        • Does this also extend to &&& if theres another thing to align on ?

          – Jannes Braet
          yesterday











        • No. If you only care about left-aligning stuff, then the first occurence gets a single & and every consequent one a &&.

          – Tiuri
          12 hours ago














        1












        1








        1







        The first, third, fifth, ... & left-align the following expressions, while the second, fourth, sixth, ... & right-align the following expressions. Your solution here: Use && instead of & at the second appearance in each line:



        documentclass[12pt]{article}
        usepackage{amsmath}
        begin{document}
        begin{equation*}
        left{begin{aligned}
        f(x) quad &+ quad g(x) && text{ if } f(x)geq 0 text{, } g(x) geq 0 \
        0 quad &+ quad 0 && text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
        f(x)-(-g(x)) quad &+ quad 0 && text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
        0 quad &+ quad 0 && text{ if } f(x)<0 text{, } g(x)< 0 \
        end{aligned}right.
        end{equation*}
        end{document}


        enter image description here






        share|improve this answer













        The first, third, fifth, ... & left-align the following expressions, while the second, fourth, sixth, ... & right-align the following expressions. Your solution here: Use && instead of & at the second appearance in each line:



        documentclass[12pt]{article}
        usepackage{amsmath}
        begin{document}
        begin{equation*}
        left{begin{aligned}
        f(x) quad &+ quad g(x) && text{ if } f(x)geq 0 text{, } g(x) geq 0 \
        0 quad &+ quad 0 && text{ if } f(x)geq 0 text{, } g(x) < -f(x) \
        f(x)-(-g(x)) quad &+ quad 0 && text{ if } f(x)geq 0 text{, } -f(x) leq g(x) < 0 \
        0 quad &+ quad 0 && text{ if } f(x)<0 text{, } g(x)< 0 \
        end{aligned}right.
        end{equation*}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        TiuriTiuri

        5,2721631




        5,2721631













        • Does this also extend to &&& if theres another thing to align on ?

          – Jannes Braet
          yesterday











        • No. If you only care about left-aligning stuff, then the first occurence gets a single & and every consequent one a &&.

          – Tiuri
          12 hours ago



















        • Does this also extend to &&& if theres another thing to align on ?

          – Jannes Braet
          yesterday











        • No. If you only care about left-aligning stuff, then the first occurence gets a single & and every consequent one a &&.

          – Tiuri
          12 hours ago

















        Does this also extend to &&& if theres another thing to align on ?

        – Jannes Braet
        yesterday





        Does this also extend to &&& if theres another thing to align on ?

        – Jannes Braet
        yesterday













        No. If you only care about left-aligning stuff, then the first occurence gets a single & and every consequent one a &&.

        – Tiuri
        12 hours ago





        No. If you only care about left-aligning stuff, then the first occurence gets a single & and every consequent one a &&.

        – Tiuri
        12 hours ago











        4














        I see no reason for aligning at the + sign, but perhaps you have.



        documentclass[12pt]{article}
        usepackage{amsmath}

        begin{document}

        Alignment at $+$
        begin{equation*}
        begin{cases}
        begin{alignedat}{2}
        f(x) &+ g(x) &qquad& text{if $f(x)geq 0$, $g(x)geq 0$} \
        0 &+ 0 &qquad& text{if $f(x)geq 0$, $g(x) < -f(x)$} \
        f(x)-(-g(x)) &+ 0 &qquad& text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
        0 &+ 0 &qquad& text{if $f(x)<0$, $g(x)< 0$}
        end{alignedat}
        end{cases}
        end{equation*}

        Better with no artificial alignment?
        begin{equation*}
        begin{cases}
        f(x) + g(x) & text{if $f(x)geq 0$, $g(x)geq 0$} \
        0 + 0 & text{if $f(x)geq 0$, $g(x) < -f(x)$} \
        f(x)-(-g(x)) + 0 & text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
        0 + 0 & text{if $f(x)<0$, $g(x)< 0$}
        end{cases}
        end{equation*}

        end{document}


        enter image description here



        The top display could have been simply managed with aligned, but because of the alignment at +, I think it's better to have more space between the two parts. Try with aligned and && instead of &qquad&.






        share|improve this answer




























          4














          I see no reason for aligning at the + sign, but perhaps you have.



          documentclass[12pt]{article}
          usepackage{amsmath}

          begin{document}

          Alignment at $+$
          begin{equation*}
          begin{cases}
          begin{alignedat}{2}
          f(x) &+ g(x) &qquad& text{if $f(x)geq 0$, $g(x)geq 0$} \
          0 &+ 0 &qquad& text{if $f(x)geq 0$, $g(x) < -f(x)$} \
          f(x)-(-g(x)) &+ 0 &qquad& text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
          0 &+ 0 &qquad& text{if $f(x)<0$, $g(x)< 0$}
          end{alignedat}
          end{cases}
          end{equation*}

          Better with no artificial alignment?
          begin{equation*}
          begin{cases}
          f(x) + g(x) & text{if $f(x)geq 0$, $g(x)geq 0$} \
          0 + 0 & text{if $f(x)geq 0$, $g(x) < -f(x)$} \
          f(x)-(-g(x)) + 0 & text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
          0 + 0 & text{if $f(x)<0$, $g(x)< 0$}
          end{cases}
          end{equation*}

          end{document}


          enter image description here



          The top display could have been simply managed with aligned, but because of the alignment at +, I think it's better to have more space between the two parts. Try with aligned and && instead of &qquad&.






          share|improve this answer


























            4












            4








            4







            I see no reason for aligning at the + sign, but perhaps you have.



            documentclass[12pt]{article}
            usepackage{amsmath}

            begin{document}

            Alignment at $+$
            begin{equation*}
            begin{cases}
            begin{alignedat}{2}
            f(x) &+ g(x) &qquad& text{if $f(x)geq 0$, $g(x)geq 0$} \
            0 &+ 0 &qquad& text{if $f(x)geq 0$, $g(x) < -f(x)$} \
            f(x)-(-g(x)) &+ 0 &qquad& text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
            0 &+ 0 &qquad& text{if $f(x)<0$, $g(x)< 0$}
            end{alignedat}
            end{cases}
            end{equation*}

            Better with no artificial alignment?
            begin{equation*}
            begin{cases}
            f(x) + g(x) & text{if $f(x)geq 0$, $g(x)geq 0$} \
            0 + 0 & text{if $f(x)geq 0$, $g(x) < -f(x)$} \
            f(x)-(-g(x)) + 0 & text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
            0 + 0 & text{if $f(x)<0$, $g(x)< 0$}
            end{cases}
            end{equation*}

            end{document}


            enter image description here



            The top display could have been simply managed with aligned, but because of the alignment at +, I think it's better to have more space between the two parts. Try with aligned and && instead of &qquad&.






            share|improve this answer













            I see no reason for aligning at the + sign, but perhaps you have.



            documentclass[12pt]{article}
            usepackage{amsmath}

            begin{document}

            Alignment at $+$
            begin{equation*}
            begin{cases}
            begin{alignedat}{2}
            f(x) &+ g(x) &qquad& text{if $f(x)geq 0$, $g(x)geq 0$} \
            0 &+ 0 &qquad& text{if $f(x)geq 0$, $g(x) < -f(x)$} \
            f(x)-(-g(x)) &+ 0 &qquad& text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
            0 &+ 0 &qquad& text{if $f(x)<0$, $g(x)< 0$}
            end{alignedat}
            end{cases}
            end{equation*}

            Better with no artificial alignment?
            begin{equation*}
            begin{cases}
            f(x) + g(x) & text{if $f(x)geq 0$, $g(x)geq 0$} \
            0 + 0 & text{if $f(x)geq 0$, $g(x) < -f(x)$} \
            f(x)-(-g(x)) + 0 & text{if $f(x)geq 0$, $-f(x) leq g(x) < 0$} \
            0 + 0 & text{if $f(x)<0$, $g(x)< 0$}
            end{cases}
            end{equation*}

            end{document}


            enter image description here



            The top display could have been simply managed with aligned, but because of the alignment at +, I think it's better to have more space between the two parts. Try with aligned and && instead of &qquad&.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            egregegreg

            721k8719113210




            721k8719113210























                2














                That's the normal behaviour if you specify alignment points with an ampersand: it is implicitly added at the end of each line. Furthermore, n columns of alignment require 2n–1 ampersands: one ampersang to introduce each new column but the first, and one ampersand to set the alignment point inside that column.



                I also propose a simpler code, with the empheq package (wich loads amthtools, which loads amsmath). I suppose this is what you want:



                documentclass[12pt]{article}
                usepackage{empheq}

                begin{document}

                begin{empheq}[left=empheqlbrace]{align*}
                f(x) quad &+ quad g(x) &text{ if }& f(x)geq 0, g(x) geq 0 \
                0 quad &+ quad 0 & text{ if } & f(x)geq 0 , g(x) < -f(x) \
                f(x)-(-g(x)) quad &+ quad 0 & text{ if } & f(x)geq 0 , -f(x) leq g(x) < 0 \
                0 quad &+ quad 0 & text{ if } & f(x)<0 , g(x)< 0 \
                end{empheq}

                end{document}


                enter image description here






                share|improve this answer




























                  2














                  That's the normal behaviour if you specify alignment points with an ampersand: it is implicitly added at the end of each line. Furthermore, n columns of alignment require 2n–1 ampersands: one ampersang to introduce each new column but the first, and one ampersand to set the alignment point inside that column.



                  I also propose a simpler code, with the empheq package (wich loads amthtools, which loads amsmath). I suppose this is what you want:



                  documentclass[12pt]{article}
                  usepackage{empheq}

                  begin{document}

                  begin{empheq}[left=empheqlbrace]{align*}
                  f(x) quad &+ quad g(x) &text{ if }& f(x)geq 0, g(x) geq 0 \
                  0 quad &+ quad 0 & text{ if } & f(x)geq 0 , g(x) < -f(x) \
                  f(x)-(-g(x)) quad &+ quad 0 & text{ if } & f(x)geq 0 , -f(x) leq g(x) < 0 \
                  0 quad &+ quad 0 & text{ if } & f(x)<0 , g(x)< 0 \
                  end{empheq}

                  end{document}


                  enter image description here






                  share|improve this answer


























                    2












                    2








                    2







                    That's the normal behaviour if you specify alignment points with an ampersand: it is implicitly added at the end of each line. Furthermore, n columns of alignment require 2n–1 ampersands: one ampersang to introduce each new column but the first, and one ampersand to set the alignment point inside that column.



                    I also propose a simpler code, with the empheq package (wich loads amthtools, which loads amsmath). I suppose this is what you want:



                    documentclass[12pt]{article}
                    usepackage{empheq}

                    begin{document}

                    begin{empheq}[left=empheqlbrace]{align*}
                    f(x) quad &+ quad g(x) &text{ if }& f(x)geq 0, g(x) geq 0 \
                    0 quad &+ quad 0 & text{ if } & f(x)geq 0 , g(x) < -f(x) \
                    f(x)-(-g(x)) quad &+ quad 0 & text{ if } & f(x)geq 0 , -f(x) leq g(x) < 0 \
                    0 quad &+ quad 0 & text{ if } & f(x)<0 , g(x)< 0 \
                    end{empheq}

                    end{document}


                    enter image description here






                    share|improve this answer













                    That's the normal behaviour if you specify alignment points with an ampersand: it is implicitly added at the end of each line. Furthermore, n columns of alignment require 2n–1 ampersands: one ampersang to introduce each new column but the first, and one ampersand to set the alignment point inside that column.



                    I also propose a simpler code, with the empheq package (wich loads amthtools, which loads amsmath). I suppose this is what you want:



                    documentclass[12pt]{article}
                    usepackage{empheq}

                    begin{document}

                    begin{empheq}[left=empheqlbrace]{align*}
                    f(x) quad &+ quad g(x) &text{ if }& f(x)geq 0, g(x) geq 0 \
                    0 quad &+ quad 0 & text{ if } & f(x)geq 0 , g(x) < -f(x) \
                    f(x)-(-g(x)) quad &+ quad 0 & text{ if } & f(x)geq 0 , -f(x) leq g(x) < 0 \
                    0 quad &+ quad 0 & text{ if } & f(x)<0 , g(x)< 0 \
                    end{empheq}

                    end{document}


                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered yesterday









                    BernardBernard

                    170k775201




                    170k775201























                        1














                        with use of array:



                        documentclass[12pt]{article}
                        usepackage{array}
                        usepackage{amsmath}

                        begin{document}
                        [setlengtharraycolsep{2pt}
                        left{begin{array}{rcl @{qquad}r l}
                        f(x) & + & g(x) & text{if } & f(x)geq 0, g(x) geq 0 \
                        0 & + & 0 & text{if } & f(x)geq 0, g(x) < -f(x) \
                        f(x)-(-g(x)) & + & 0 & text{if } & f(x)geq 0, -f(x) leq g(x) < 0 \
                        0 & + & 0 & text{if } & f(x)<0 , g(x)< 0 \
                        end{array}right.
                        ]

                        end{document}


                        enter image description here






                        share|improve this answer




























                          1














                          with use of array:



                          documentclass[12pt]{article}
                          usepackage{array}
                          usepackage{amsmath}

                          begin{document}
                          [setlengtharraycolsep{2pt}
                          left{begin{array}{rcl @{qquad}r l}
                          f(x) & + & g(x) & text{if } & f(x)geq 0, g(x) geq 0 \
                          0 & + & 0 & text{if } & f(x)geq 0, g(x) < -f(x) \
                          f(x)-(-g(x)) & + & 0 & text{if } & f(x)geq 0, -f(x) leq g(x) < 0 \
                          0 & + & 0 & text{if } & f(x)<0 , g(x)< 0 \
                          end{array}right.
                          ]

                          end{document}


                          enter image description here






                          share|improve this answer


























                            1












                            1








                            1







                            with use of array:



                            documentclass[12pt]{article}
                            usepackage{array}
                            usepackage{amsmath}

                            begin{document}
                            [setlengtharraycolsep{2pt}
                            left{begin{array}{rcl @{qquad}r l}
                            f(x) & + & g(x) & text{if } & f(x)geq 0, g(x) geq 0 \
                            0 & + & 0 & text{if } & f(x)geq 0, g(x) < -f(x) \
                            f(x)-(-g(x)) & + & 0 & text{if } & f(x)geq 0, -f(x) leq g(x) < 0 \
                            0 & + & 0 & text{if } & f(x)<0 , g(x)< 0 \
                            end{array}right.
                            ]

                            end{document}


                            enter image description here






                            share|improve this answer













                            with use of array:



                            documentclass[12pt]{article}
                            usepackage{array}
                            usepackage{amsmath}

                            begin{document}
                            [setlengtharraycolsep{2pt}
                            left{begin{array}{rcl @{qquad}r l}
                            f(x) & + & g(x) & text{if } & f(x)geq 0, g(x) geq 0 \
                            0 & + & 0 & text{if } & f(x)geq 0, g(x) < -f(x) \
                            f(x)-(-g(x)) & + & 0 & text{if } & f(x)geq 0, -f(x) leq g(x) < 0 \
                            0 & + & 0 & text{if } & f(x)<0 , g(x)< 0 \
                            end{array}right.
                            ]

                            end{document}


                            enter image description here







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered yesterday









                            ZarkoZarko

                            125k867164




                            125k867164






















                                Jannes Braet is a new contributor. Be nice, and check out our Code of Conduct.










                                draft saved

                                draft discarded


















                                Jannes Braet is a new contributor. Be nice, and check out our Code of Conduct.













                                Jannes Braet is a new contributor. Be nice, and check out our Code of Conduct.












                                Jannes Braet is a new contributor. Be nice, and check out our Code of Conduct.
















                                Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475841%2falign-is-aligning-to-the-right%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Callistus I

                                Tabula Rosettana

                                How to label and detect the document text images