align is aligning to the right
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
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.
add a comment |
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
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 thanalign.
– JouleV
yesterday
Welcome to TeX.SE! You should not havebegin{align*}insidebegin{equation*}... end{equation*}, did you mean to usealigned?
– marmot
yesterday
I did use aligned before, I tried to use align as a fix but didn't work either.
– Jannes Braet
yesterday
add a comment |
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
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
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.
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 thanalign.
– JouleV
yesterday
Welcome to TeX.SE! You should not havebegin{align*}insidebegin{equation*}... end{equation*}, did you mean to usealigned?
– marmot
yesterday
I did use aligned before, I tried to use align as a fix but didn't work either.
– Jannes Braet
yesterday
add a comment |
Maybe you have to use something other thanalign.
– JouleV
yesterday
Welcome to TeX.SE! You should not havebegin{align*}insidebegin{equation*}... end{equation*}, did you mean to usealigned?
– 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
add a comment |
4 Answers
4
active
oldest
votes
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}

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
add a comment |
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}

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&.
add a comment |
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}

add a comment |
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}

add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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}

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
add a comment |
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}

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
add a comment |
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}

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}

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
add a comment |
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
add a comment |
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}

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&.
add a comment |
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}

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&.
add a comment |
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}

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&.
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}

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&.
answered yesterday
egregegreg
721k8719113210
721k8719113210
add a comment |
add a comment |
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}

add a comment |
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}

add a comment |
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}

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}

answered yesterday
BernardBernard
170k775201
170k775201
add a comment |
add a comment |
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}

add a comment |
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}

add a comment |
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}

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}

answered yesterday
ZarkoZarko
125k867164
125k867164
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Maybe you have to use something other than
align.– JouleV
yesterday
Welcome to TeX.SE! You should not have
begin{align*}insidebegin{equation*}... end{equation*}, did you mean to usealigned?– marmot
yesterday
I did use aligned before, I tried to use align as a fix but didn't work either.
– Jannes Braet
yesterday