Tikz Diagram in align environment with picture nodes
I am trying to reproduce an image. I could probably do alone but it may not be the best way so I am asking what is the fastest and easiest way achieve the result:
documentclass{article}
usepackage{amsmath,tikz}
newcommand{der}[2]{dfrac{d#1}{d#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} cdot x^{5}) \ \
&=x^{2} cdot textcolor{red}{5x^{4}}+x^{5} cdot
textcolor{red}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
end{document}
This outputs:
I am trying to achieve:
tikz-pgf
add a comment |
I am trying to reproduce an image. I could probably do alone but it may not be the best way so I am asking what is the fastest and easiest way achieve the result:
documentclass{article}
usepackage{amsmath,tikz}
newcommand{der}[2]{dfrac{d#1}{d#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} cdot x^{5}) \ \
&=x^{2} cdot textcolor{red}{5x^{4}}+x^{5} cdot
textcolor{red}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
end{document}
This outputs:
I am trying to achieve:
tikz-pgf
add a comment |
I am trying to reproduce an image. I could probably do alone but it may not be the best way so I am asking what is the fastest and easiest way achieve the result:
documentclass{article}
usepackage{amsmath,tikz}
newcommand{der}[2]{dfrac{d#1}{d#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} cdot x^{5}) \ \
&=x^{2} cdot textcolor{red}{5x^{4}}+x^{5} cdot
textcolor{red}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
end{document}
This outputs:
I am trying to achieve:
tikz-pgf
I am trying to reproduce an image. I could probably do alone but it may not be the best way so I am asking what is the fastest and easiest way achieve the result:
documentclass{article}
usepackage{amsmath,tikz}
newcommand{der}[2]{dfrac{d#1}{d#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} cdot x^{5}) \ \
&=x^{2} cdot textcolor{red}{5x^{4}}+x^{5} cdot
textcolor{red}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
end{document}
This outputs:
I am trying to achieve:
tikz-pgf
tikz-pgf
asked Dec 5 at 16:23
MathScholar
5848
5848
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Here's a proposal. It requires the latest version of tikzmark, i.e. should work if you have updated your TeX installation in the past 2 months or so.
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} tikzmarknode{5}{cdot}
tikzmarknode[red]{4}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
path ([yshift=-4pt]5.south) node[below,circle,draw,font=small,inner
sep=1pt]{5};
end{tikzpicture}
end{document}
or (it is hard for me to judge where the 5
node should be sitting)
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark,positioning}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} cdot
tikzmarknode[red]{4}{2x}\
&=5x^{6}+tikzmarknode{5}{2x^{6}}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
node[right=3pt of 5,circle,draw,font=small,inner sep=1pt]{5};
end{tikzpicture}
end{document}
I was just going to post this small issue. Thanks Marmot. This is very helpful!
– MathScholar
Dec 5 at 20:31
Every student knows (or should know) that is the same, but I'd swap2x
andx^5
... lol
– Sigur
Dec 5 at 20:31
@Sigur Yes, thanks for the heads up. I guess that's the OP's decision. ;-)
– marmot
Dec 5 at 20:34
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
});
}
});
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%2f463341%2ftikz-diagram-in-align-environment-with-picture-nodes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here's a proposal. It requires the latest version of tikzmark, i.e. should work if you have updated your TeX installation in the past 2 months or so.
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} tikzmarknode{5}{cdot}
tikzmarknode[red]{4}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
path ([yshift=-4pt]5.south) node[below,circle,draw,font=small,inner
sep=1pt]{5};
end{tikzpicture}
end{document}
or (it is hard for me to judge where the 5
node should be sitting)
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark,positioning}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} cdot
tikzmarknode[red]{4}{2x}\
&=5x^{6}+tikzmarknode{5}{2x^{6}}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
node[right=3pt of 5,circle,draw,font=small,inner sep=1pt]{5};
end{tikzpicture}
end{document}
I was just going to post this small issue. Thanks Marmot. This is very helpful!
– MathScholar
Dec 5 at 20:31
Every student knows (or should know) that is the same, but I'd swap2x
andx^5
... lol
– Sigur
Dec 5 at 20:31
@Sigur Yes, thanks for the heads up. I guess that's the OP's decision. ;-)
– marmot
Dec 5 at 20:34
add a comment |
Here's a proposal. It requires the latest version of tikzmark, i.e. should work if you have updated your TeX installation in the past 2 months or so.
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} tikzmarknode{5}{cdot}
tikzmarknode[red]{4}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
path ([yshift=-4pt]5.south) node[below,circle,draw,font=small,inner
sep=1pt]{5};
end{tikzpicture}
end{document}
or (it is hard for me to judge where the 5
node should be sitting)
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark,positioning}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} cdot
tikzmarknode[red]{4}{2x}\
&=5x^{6}+tikzmarknode{5}{2x^{6}}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
node[right=3pt of 5,circle,draw,font=small,inner sep=1pt]{5};
end{tikzpicture}
end{document}
I was just going to post this small issue. Thanks Marmot. This is very helpful!
– MathScholar
Dec 5 at 20:31
Every student knows (or should know) that is the same, but I'd swap2x
andx^5
... lol
– Sigur
Dec 5 at 20:31
@Sigur Yes, thanks for the heads up. I guess that's the OP's decision. ;-)
– marmot
Dec 5 at 20:34
add a comment |
Here's a proposal. It requires the latest version of tikzmark, i.e. should work if you have updated your TeX installation in the past 2 months or so.
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} tikzmarknode{5}{cdot}
tikzmarknode[red]{4}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
path ([yshift=-4pt]5.south) node[below,circle,draw,font=small,inner
sep=1pt]{5};
end{tikzpicture}
end{document}
or (it is hard for me to judge where the 5
node should be sitting)
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark,positioning}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} cdot
tikzmarknode[red]{4}{2x}\
&=5x^{6}+tikzmarknode{5}{2x^{6}}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
node[right=3pt of 5,circle,draw,font=small,inner sep=1pt]{5};
end{tikzpicture}
end{document}
Here's a proposal. It requires the latest version of tikzmark, i.e. should work if you have updated your TeX installation in the past 2 months or so.
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} tikzmarknode{5}{cdot}
tikzmarknode[red]{4}{2x}\
&=5x^{6}+2x^{6}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
path ([yshift=-4pt]5.south) node[below,circle,draw,font=small,inner
sep=1pt]{5};
end{tikzpicture}
end{document}
or (it is hard for me to judge where the 5
node should be sitting)
documentclass{article}
usepackage{amsmath,tikz}
usetikzlibrary{tikzmark,positioning}
newcommand{der}[2]{dfrac{mathrm{d}#1}{mathrm{d}#2}}
begin{document}
begin{center}
$begin{aligned}[t]
&phantom{==}der{}{x} (x^{2} tikzmarknode{0}{cdot} x^{5}) \[0.8cm]
&=tikzmarknode{1}{x^{2}} cdot
tikzmarknode[red]{2}{5x^{4}}+
tikzmarknode{3}{x^{5}} cdot
tikzmarknode[red]{4}{2x}\
&=5x^{6}+tikzmarknode{5}{2x^{6}}\
&=7x^{6}
end{aligned}$
end{center}
begin{tikzpicture}[overlay,remember picture,cyan!70]
path ([yshift=0.1cm]1.north) coordinate (aux);
foreach X in {1,...,4}
{draw (X |-aux) node[above,circle,draw,font=small,inner sep=1pt]
(LX){X};}
draw[very thick] ([xshift=-2pt,yshift=2pt]L1.west) |-
([xshift=2pt,yshift=8pt]L4.east) coordinate (aux2) -- ([xshift=2pt]L4.east);
draw[very thick,-latex] (0.south) -- (0|-aux2);
node[right=3pt of 5,circle,draw,font=small,inner sep=1pt]{5};
end{tikzpicture}
end{document}
edited Dec 5 at 20:28
answered Dec 5 at 18:45
marmot
84.9k495179
84.9k495179
I was just going to post this small issue. Thanks Marmot. This is very helpful!
– MathScholar
Dec 5 at 20:31
Every student knows (or should know) that is the same, but I'd swap2x
andx^5
... lol
– Sigur
Dec 5 at 20:31
@Sigur Yes, thanks for the heads up. I guess that's the OP's decision. ;-)
– marmot
Dec 5 at 20:34
add a comment |
I was just going to post this small issue. Thanks Marmot. This is very helpful!
– MathScholar
Dec 5 at 20:31
Every student knows (or should know) that is the same, but I'd swap2x
andx^5
... lol
– Sigur
Dec 5 at 20:31
@Sigur Yes, thanks for the heads up. I guess that's the OP's decision. ;-)
– marmot
Dec 5 at 20:34
I was just going to post this small issue. Thanks Marmot. This is very helpful!
– MathScholar
Dec 5 at 20:31
I was just going to post this small issue. Thanks Marmot. This is very helpful!
– MathScholar
Dec 5 at 20:31
Every student knows (or should know) that is the same, but I'd swap
2x
and x^5
... lol– Sigur
Dec 5 at 20:31
Every student knows (or should know) that is the same, but I'd swap
2x
and x^5
... lol– Sigur
Dec 5 at 20:31
@Sigur Yes, thanks for the heads up. I guess that's the OP's decision. ;-)
– marmot
Dec 5 at 20:34
@Sigur Yes, thanks for the heads up. I guess that's the OP's decision. ;-)
– marmot
Dec 5 at 20:34
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f463341%2ftikz-diagram-in-align-environment-with-picture-nodes%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