How to issue a cr within a group in amsmath `align` and friends
up vote
3
down vote
favorite
I would like to enclose multiple lines in an align in a group.
Because of the group, the \ delimiting the rows generates a mistake (if I'm guessing right the group is broken at \ and latex complains about unclosed groups).
My goal is to have a macro mymath that typesets some complex formula.
The formula is a combination of fixed symbols and optional symbols that are defined via local macros (A and B) in the MWE.
I would like the definitions to be local to the arguments of the mymath macro,
but I would also like the ability to break lines and align content from "outside" the macro, i.e. without baking in align or similar environments inside the macro itself.
MWE
documentclass[12pt]{article}
usepackage{amsmath}
defA{alpha_0}defB{beta_0}
defmymath#1#2{defA{alpha}defB{beta}sum #1=[#2]}
defmymathb#1#2{defA{gamma}defB{delta}sum #1=[#2]}
defGmymath#1#2{{defA{alpha}defB{beta}sum #1=[#2]}}
defGmymathb#1#2{{defA{gamma}defB{delta}sum #1=[#2]}}
begin{document}
begin{equation}
mymath{A}{B}
+A % want alpha_0 here
mymathb{A}{B}
end{equation}
color{red}
begin{align*}
mymath{A&}{5B}\
mymathb{A&}{7B\&qquadA}
end{align*}
color{blue}
begin{multline*}
mymath{A B}{long+\B superlong A}
end{multline*}
end{document}
If I use mymath the definitions of A and B are lost once I use \, and are not local to the argument only.
If I use gmymath the extra group make align and friends very confused about the \.
Question: Is there a way in which mymath can make the \ "leak" the group?
The same story applies to alignment characters &.
align amsmath grouping
|
show 1 more comment
up vote
3
down vote
favorite
I would like to enclose multiple lines in an align in a group.
Because of the group, the \ delimiting the rows generates a mistake (if I'm guessing right the group is broken at \ and latex complains about unclosed groups).
My goal is to have a macro mymath that typesets some complex formula.
The formula is a combination of fixed symbols and optional symbols that are defined via local macros (A and B) in the MWE.
I would like the definitions to be local to the arguments of the mymath macro,
but I would also like the ability to break lines and align content from "outside" the macro, i.e. without baking in align or similar environments inside the macro itself.
MWE
documentclass[12pt]{article}
usepackage{amsmath}
defA{alpha_0}defB{beta_0}
defmymath#1#2{defA{alpha}defB{beta}sum #1=[#2]}
defmymathb#1#2{defA{gamma}defB{delta}sum #1=[#2]}
defGmymath#1#2{{defA{alpha}defB{beta}sum #1=[#2]}}
defGmymathb#1#2{{defA{gamma}defB{delta}sum #1=[#2]}}
begin{document}
begin{equation}
mymath{A}{B}
+A % want alpha_0 here
mymathb{A}{B}
end{equation}
color{red}
begin{align*}
mymath{A&}{5B}\
mymathb{A&}{7B\&qquadA}
end{align*}
color{blue}
begin{multline*}
mymath{A B}{long+\B superlong A}
end{multline*}
end{document}
If I use mymath the definitions of A and B are lost once I use \, and are not local to the argument only.
If I use gmymath the extra group make align and friends very confused about the \.
Question: Is there a way in which mymath can make the \ "leak" the group?
The same story applies to alignment characters &.
align amsmath grouping
Have you trieddefbluemath#1{{color{blue}begin{gathered}#1end{gathered}}}?
– Mico
2 days ago
@Mico that would fix the possible uses: for example I would not be able to use&. The intent is to have the user ofbluemathto be able to choose the math environment from outside. For example one may want to dobegin{align} bluemath{a&b}\bluemath{c&d}end{align}if you use an inneralignedyou can't align across rows anymore
– Bordaigorl
2 days ago
each cell of an alignment is a group, you should think of&as a special form equivalent to}{so basically what you ask is not possible.
– David Carlisle
2 days ago
1
if you remove the group, there is no error but the color only extends as far as the first&so "I know that the effect can be achieved without the groups," is rather misleading.
– David Carlisle
2 days ago
I'm not sure I fully understand your typesetting objective. (Actually, I'm pretty sure that I don't fully understand that you're trying to achieve...) In multi-line environments such asalignandgather, each row is a group onto itself. Hence, if you can't issue the instructioncolor{blue}globally, you'll have to issue it separately for each and every row that's supposed to get a non-default color.
– Mico
2 days ago
|
show 1 more comment
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I would like to enclose multiple lines in an align in a group.
Because of the group, the \ delimiting the rows generates a mistake (if I'm guessing right the group is broken at \ and latex complains about unclosed groups).
My goal is to have a macro mymath that typesets some complex formula.
The formula is a combination of fixed symbols and optional symbols that are defined via local macros (A and B) in the MWE.
I would like the definitions to be local to the arguments of the mymath macro,
but I would also like the ability to break lines and align content from "outside" the macro, i.e. without baking in align or similar environments inside the macro itself.
MWE
documentclass[12pt]{article}
usepackage{amsmath}
defA{alpha_0}defB{beta_0}
defmymath#1#2{defA{alpha}defB{beta}sum #1=[#2]}
defmymathb#1#2{defA{gamma}defB{delta}sum #1=[#2]}
defGmymath#1#2{{defA{alpha}defB{beta}sum #1=[#2]}}
defGmymathb#1#2{{defA{gamma}defB{delta}sum #1=[#2]}}
begin{document}
begin{equation}
mymath{A}{B}
+A % want alpha_0 here
mymathb{A}{B}
end{equation}
color{red}
begin{align*}
mymath{A&}{5B}\
mymathb{A&}{7B\&qquadA}
end{align*}
color{blue}
begin{multline*}
mymath{A B}{long+\B superlong A}
end{multline*}
end{document}
If I use mymath the definitions of A and B are lost once I use \, and are not local to the argument only.
If I use gmymath the extra group make align and friends very confused about the \.
Question: Is there a way in which mymath can make the \ "leak" the group?
The same story applies to alignment characters &.
align amsmath grouping
I would like to enclose multiple lines in an align in a group.
Because of the group, the \ delimiting the rows generates a mistake (if I'm guessing right the group is broken at \ and latex complains about unclosed groups).
My goal is to have a macro mymath that typesets some complex formula.
The formula is a combination of fixed symbols and optional symbols that are defined via local macros (A and B) in the MWE.
I would like the definitions to be local to the arguments of the mymath macro,
but I would also like the ability to break lines and align content from "outside" the macro, i.e. without baking in align or similar environments inside the macro itself.
MWE
documentclass[12pt]{article}
usepackage{amsmath}
defA{alpha_0}defB{beta_0}
defmymath#1#2{defA{alpha}defB{beta}sum #1=[#2]}
defmymathb#1#2{defA{gamma}defB{delta}sum #1=[#2]}
defGmymath#1#2{{defA{alpha}defB{beta}sum #1=[#2]}}
defGmymathb#1#2{{defA{gamma}defB{delta}sum #1=[#2]}}
begin{document}
begin{equation}
mymath{A}{B}
+A % want alpha_0 here
mymathb{A}{B}
end{equation}
color{red}
begin{align*}
mymath{A&}{5B}\
mymathb{A&}{7B\&qquadA}
end{align*}
color{blue}
begin{multline*}
mymath{A B}{long+\B superlong A}
end{multline*}
end{document}
If I use mymath the definitions of A and B are lost once I use \, and are not local to the argument only.
If I use gmymath the extra group make align and friends very confused about the \.
Question: Is there a way in which mymath can make the \ "leak" the group?
The same story applies to alignment characters &.
align amsmath grouping
align amsmath grouping
edited 2 days ago
asked 2 days ago
Bordaigorl
11.8k2555
11.8k2555
Have you trieddefbluemath#1{{color{blue}begin{gathered}#1end{gathered}}}?
– Mico
2 days ago
@Mico that would fix the possible uses: for example I would not be able to use&. The intent is to have the user ofbluemathto be able to choose the math environment from outside. For example one may want to dobegin{align} bluemath{a&b}\bluemath{c&d}end{align}if you use an inneralignedyou can't align across rows anymore
– Bordaigorl
2 days ago
each cell of an alignment is a group, you should think of&as a special form equivalent to}{so basically what you ask is not possible.
– David Carlisle
2 days ago
1
if you remove the group, there is no error but the color only extends as far as the first&so "I know that the effect can be achieved without the groups," is rather misleading.
– David Carlisle
2 days ago
I'm not sure I fully understand your typesetting objective. (Actually, I'm pretty sure that I don't fully understand that you're trying to achieve...) In multi-line environments such asalignandgather, each row is a group onto itself. Hence, if you can't issue the instructioncolor{blue}globally, you'll have to issue it separately for each and every row that's supposed to get a non-default color.
– Mico
2 days ago
|
show 1 more comment
Have you trieddefbluemath#1{{color{blue}begin{gathered}#1end{gathered}}}?
– Mico
2 days ago
@Mico that would fix the possible uses: for example I would not be able to use&. The intent is to have the user ofbluemathto be able to choose the math environment from outside. For example one may want to dobegin{align} bluemath{a&b}\bluemath{c&d}end{align}if you use an inneralignedyou can't align across rows anymore
– Bordaigorl
2 days ago
each cell of an alignment is a group, you should think of&as a special form equivalent to}{so basically what you ask is not possible.
– David Carlisle
2 days ago
1
if you remove the group, there is no error but the color only extends as far as the first&so "I know that the effect can be achieved without the groups," is rather misleading.
– David Carlisle
2 days ago
I'm not sure I fully understand your typesetting objective. (Actually, I'm pretty sure that I don't fully understand that you're trying to achieve...) In multi-line environments such asalignandgather, each row is a group onto itself. Hence, if you can't issue the instructioncolor{blue}globally, you'll have to issue it separately for each and every row that's supposed to get a non-default color.
– Mico
2 days ago
Have you tried
defbluemath#1{{color{blue}begin{gathered}#1end{gathered}}}?– Mico
2 days ago
Have you tried
defbluemath#1{{color{blue}begin{gathered}#1end{gathered}}}?– Mico
2 days ago
@Mico that would fix the possible uses: for example I would not be able to use
&. The intent is to have the user of bluemath to be able to choose the math environment from outside. For example one may want to do begin{align} bluemath{a&b}\bluemath{c&d}end{align} if you use an inner aligned you can't align across rows anymore– Bordaigorl
2 days ago
@Mico that would fix the possible uses: for example I would not be able to use
&. The intent is to have the user of bluemath to be able to choose the math environment from outside. For example one may want to do begin{align} bluemath{a&b}\bluemath{c&d}end{align} if you use an inner aligned you can't align across rows anymore– Bordaigorl
2 days ago
each cell of an alignment is a group, you should think of
& as a special form equivalent to }{ so basically what you ask is not possible.– David Carlisle
2 days ago
each cell of an alignment is a group, you should think of
& as a special form equivalent to }{ so basically what you ask is not possible.– David Carlisle
2 days ago
1
1
if you remove the group, there is no error but the color only extends as far as the first
& so "I know that the effect can be achieved without the groups," is rather misleading.– David Carlisle
2 days ago
if you remove the group, there is no error but the color only extends as far as the first
& so "I know that the effect can be achieved without the groups," is rather misleading.– David Carlisle
2 days ago
I'm not sure I fully understand your typesetting objective. (Actually, I'm pretty sure that I don't fully understand that you're trying to achieve...) In multi-line environments such as
align and gather, each row is a group onto itself. Hence, if you can't issue the instruction color{blue} globally, you'll have to issue it separately for each and every row that's supposed to get a non-default color.– Mico
2 days ago
I'm not sure I fully understand your typesetting objective. (Actually, I'm pretty sure that I don't fully understand that you're trying to achieve...) In multi-line environments such as
align and gather, each row is a group onto itself. Hence, if you can't issue the instruction color{blue} globally, you'll have to issue it separately for each and every row that's supposed to get a non-default color.– Mico
2 days ago
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f460454%2fhow-to-issue-a-cr-within-a-group-in-amsmath-align-and-friends%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
Have you tried
defbluemath#1{{color{blue}begin{gathered}#1end{gathered}}}?– Mico
2 days ago
@Mico that would fix the possible uses: for example I would not be able to use
&. The intent is to have the user ofbluemathto be able to choose the math environment from outside. For example one may want to dobegin{align} bluemath{a&b}\bluemath{c&d}end{align}if you use an inneralignedyou can't align across rows anymore– Bordaigorl
2 days ago
each cell of an alignment is a group, you should think of
&as a special form equivalent to}{so basically what you ask is not possible.– David Carlisle
2 days ago
1
if you remove the group, there is no error but the color only extends as far as the first
&so "I know that the effect can be achieved without the groups," is rather misleading.– David Carlisle
2 days ago
I'm not sure I fully understand your typesetting objective. (Actually, I'm pretty sure that I don't fully understand that you're trying to achieve...) In multi-line environments such as
alignandgather, each row is a group onto itself. Hence, if you can't issue the instructioncolor{blue}globally, you'll have to issue it separately for each and every row that's supposed to get a non-default color.– Mico
2 days ago