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























  • Maybe you have to use something other than align.

    – JouleV
    Feb 20 at 15:31











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

    – marmot
    Feb 20 at 15:31











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

    – Jannes Braet
    Feb 20 at 15:32
















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























  • Maybe you have to use something other than align.

    – JouleV
    Feb 20 at 15:31











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

    – marmot
    Feb 20 at 15:31











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

    – Jannes Braet
    Feb 20 at 15:32














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














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













share|improve this question











share|improve this question




share|improve this question










asked Feb 20 at 15:29









Jannes BraetJannes Braet

1183




1183













  • Maybe you have to use something other than align.

    – JouleV
    Feb 20 at 15:31











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

    – marmot
    Feb 20 at 15:31











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

    – Jannes Braet
    Feb 20 at 15:32



















  • Maybe you have to use something other than align.

    – JouleV
    Feb 20 at 15:31











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

    – marmot
    Feb 20 at 15:31











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

    – Jannes Braet
    Feb 20 at 15:32

















Maybe you have to use something other than align.

– JouleV
Feb 20 at 15:31





Maybe you have to use something other than align.

– JouleV
Feb 20 at 15:31













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

– marmot
Feb 20 at 15:31





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

– marmot
Feb 20 at 15:31













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

– Jannes Braet
Feb 20 at 15:32





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

– Jannes Braet
Feb 20 at 15:32










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
    Feb 20 at 15:47











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

    – Tiuri
    Feb 21 at 8:19



















3














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
        });


        }
        });














        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
          Feb 20 at 15:47











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

          – Tiuri
          Feb 21 at 8:19
















        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
          Feb 20 at 15:47











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

          – Tiuri
          Feb 21 at 8:19














        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 Feb 20 at 15:36









        TiuriTiuri

        5,2901631




        5,2901631













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

          – Jannes Braet
          Feb 20 at 15:47











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

          – Tiuri
          Feb 21 at 8:19



















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

          – Jannes Braet
          Feb 20 at 15:47











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

          – Tiuri
          Feb 21 at 8:19

















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

        – Jannes Braet
        Feb 20 at 15:47





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

        – Jannes Braet
        Feb 20 at 15:47













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

        – Tiuri
        Feb 21 at 8:19





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

        – Tiuri
        Feb 21 at 8:19











        3














        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




























          3














          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


























            3












            3








            3







            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 Feb 20 at 18:15









            egregegreg

            728k8819263235




            728k8819263235























                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 Feb 20 at 15:49









                    BernardBernard

                    174k776206




                    174k776206























                        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 Feb 20 at 16:45









                            ZarkoZarko

                            127k868167




                            127k868167






























                                draft saved

                                draft discarded




















































                                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

                                Index of /

                                Tribalistas

                                Listed building