How to use tikzmark inside tikz-cd?
up vote
5
down vote
favorite
I want to use tikzmark in tikzcd.
However, even the following sample returns errors
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
The error report is
Package tikz Error: Cannot parse this coordinate. tikzmark{u1}A
Package tikz Error: Cannot parse this coordinate. C & tikzmark{u2}D
Package pgf Error: No shape named u1 is known. draw[->] (u1)
Package pgf Error: No shape named u1 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u2 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u2 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u1 is known. draw[->] (u1) edge
(u2)
Label(s) may have changed. Rerun to get cross-references right.
How to fix this kind of errors?
Update:
I have tried this
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}[remember picture]
aaaaaasubnode{u1}{A} & B\
C & subnode{u2}{D}ddddddd
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
and this
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}[remember picture]
aaaaaatikzmarknode{u1}{A} & B\
C & tikzmarknode{u2}{D}ddddddd
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
But none of them put the arrow in correct location.
Update:
The tikzmarknode command does work correctly if I use LuaLaTex instead of XeLaTeX.
tikz-cd tikzmark
add a comment |
up vote
5
down vote
favorite
I want to use tikzmark in tikzcd.
However, even the following sample returns errors
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
The error report is
Package tikz Error: Cannot parse this coordinate. tikzmark{u1}A
Package tikz Error: Cannot parse this coordinate. C & tikzmark{u2}D
Package pgf Error: No shape named u1 is known. draw[->] (u1)
Package pgf Error: No shape named u1 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u2 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u2 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u1 is known. draw[->] (u1) edge
(u2)
Label(s) may have changed. Rerun to get cross-references right.
How to fix this kind of errors?
Update:
I have tried this
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}[remember picture]
aaaaaasubnode{u1}{A} & B\
C & subnode{u2}{D}ddddddd
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
and this
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}[remember picture]
aaaaaatikzmarknode{u1}{A} & B\
C & tikzmarknode{u2}{D}ddddddd
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
But none of them put the arrow in correct location.
Update:
The tikzmarknode command does work correctly if I use LuaLaTex instead of XeLaTeX.
tikz-cd tikzmark
You don't. Just addremember picture
to thetikzcd
and refer to the nodes with(tikzcdmatrixname-1-1)
and so on.
– marmot
Nov 4 at 19:38
Note that xelatex has known issues with positioning, and so with tikzmark.
– Loop Space
Nov 4 at 20:46
Thanks for accepting my answer. However, the answer by LoopSpace is clearly better, Could you please accept it instead?
– marmot
Nov 4 at 20:50
add a comment |
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I want to use tikzmark in tikzcd.
However, even the following sample returns errors
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
The error report is
Package tikz Error: Cannot parse this coordinate. tikzmark{u1}A
Package tikz Error: Cannot parse this coordinate. C & tikzmark{u2}D
Package pgf Error: No shape named u1 is known. draw[->] (u1)
Package pgf Error: No shape named u1 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u2 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u2 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u1 is known. draw[->] (u1) edge
(u2)
Label(s) may have changed. Rerun to get cross-references right.
How to fix this kind of errors?
Update:
I have tried this
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}[remember picture]
aaaaaasubnode{u1}{A} & B\
C & subnode{u2}{D}ddddddd
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
and this
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}[remember picture]
aaaaaatikzmarknode{u1}{A} & B\
C & tikzmarknode{u2}{D}ddddddd
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
But none of them put the arrow in correct location.
Update:
The tikzmarknode command does work correctly if I use LuaLaTex instead of XeLaTeX.
tikz-cd tikzmark
I want to use tikzmark in tikzcd.
However, even the following sample returns errors
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
The error report is
Package tikz Error: Cannot parse this coordinate. tikzmark{u1}A
Package tikz Error: Cannot parse this coordinate. C & tikzmark{u2}D
Package pgf Error: No shape named u1 is known. draw[->] (u1)
Package pgf Error: No shape named u1 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u2 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u2 is known. draw[->] (u1) edge
(u2)
Package pgf Error: No shape named u1 is known. draw[->] (u1) edge
(u2)
Label(s) may have changed. Rerun to get cross-references right.
How to fix this kind of errors?
Update:
I have tried this
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}[remember picture]
aaaaaasubnode{u1}{A} & B\
C & subnode{u2}{D}ddddddd
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
and this
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
begin{document}
begin{tikzcd}[remember picture]
aaaaaatikzmarknode{u1}{A} & B\
C & tikzmarknode{u2}{D}ddddddd
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (u1) edge (u2);
end{tikzpicture}
end{document}
But none of them put the arrow in correct location.
Update:
The tikzmarknode command does work correctly if I use LuaLaTex instead of XeLaTeX.
tikz-cd tikzmark
tikz-cd tikzmark
edited Nov 4 at 20:38
asked Nov 4 at 19:31
Gau-Syu
1627
1627
You don't. Just addremember picture
to thetikzcd
and refer to the nodes with(tikzcdmatrixname-1-1)
and so on.
– marmot
Nov 4 at 19:38
Note that xelatex has known issues with positioning, and so with tikzmark.
– Loop Space
Nov 4 at 20:46
Thanks for accepting my answer. However, the answer by LoopSpace is clearly better, Could you please accept it instead?
– marmot
Nov 4 at 20:50
add a comment |
You don't. Just addremember picture
to thetikzcd
and refer to the nodes with(tikzcdmatrixname-1-1)
and so on.
– marmot
Nov 4 at 19:38
Note that xelatex has known issues with positioning, and so with tikzmark.
– Loop Space
Nov 4 at 20:46
Thanks for accepting my answer. However, the answer by LoopSpace is clearly better, Could you please accept it instead?
– marmot
Nov 4 at 20:50
You don't. Just add
remember picture
to the tikzcd
and refer to the nodes with (tikzcdmatrixname-1-1)
and so on.– marmot
Nov 4 at 19:38
You don't. Just add
remember picture
to the tikzcd
and refer to the nodes with (tikzcdmatrixname-1-1)
and so on.– marmot
Nov 4 at 19:38
Note that xelatex has known issues with positioning, and so with tikzmark.
– Loop Space
Nov 4 at 20:46
Note that xelatex has known issues with positioning, and so with tikzmark.
– Loop Space
Nov 4 at 20:46
Thanks for accepting my answer. However, the answer by LoopSpace is clearly better, Could you please accept it instead?
– marmot
Nov 4 at 20:50
Thanks for accepting my answer. However, the answer by LoopSpace is clearly better, Could you please accept it instead?
– marmot
Nov 4 at 20:50
add a comment |
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
(Note: I agree with marmot that for this particular case I wouldn't use tikzmark, but I get that it is a simple example and it reveals a bug in tikzmark.)
It would appear that when I modified tikzmark to make it possible to use inside tikzpictures, then I inadvertently broke the ability to use it inside a node (though I'm not sure if that was ever a recommended use!). A node is inside a tikzpicture but should be treated as if it weren't. My current test for whether the tikzmark is inside a tikzpicture doesn't pick up on this. Here's the corrected test:
documentclass{article}
%url{https://tex.stackexchange.com/q/458387/86}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
makeatletter
deftikzmark{%
ifxpgfpictureid@undefined
lettikzmark@next=tikzmark@outside
else
relax
ifxscopetikz@origscoperelax
lettikzmark@next=tikzmark@outside
else
lettikzmark@next=tikzmark@inside
fi
fi
tikzmark@next%
}
makeatother
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (pic cs:u1) -- (pic cs:u2);
end{tikzpicture}
end{document}
I've uploaded this to github and will send it off to CTAN once the amazing testing team of marmot has answered a few questions to check that I haven't broken something else!
Great! That's what I was hoping for! The marmot testing team used this great package in several answers and everything worked absolutely smoothly!
– marmot
Nov 4 at 20:49
My new maxim: never trust anything until it has been stress tested by a marmot.
– Loop Space
Nov 4 at 21:00
add a comment |
up vote
4
down vote
REVISED ANSWER: I could get tikzmark
to collaborate with tikz-cd
by switching to tikzmarknode
. More precisely, if I rewrite cfr's nice answer to become
documentclass{article}
usepackage{tikz-cd,amssymb}
usetikzlibrary{tikzmark,quotes}
begin{document}
begin{tikzcd}
x in tikzmarknode{u1}{U} subseteq M arrow{r}{f} & f(x) in V subseteq
tikzmarknode{n}{N} arrow{d}{psi} \
phi(x) in tikzmarknode{u2}{phi(U)} subseteq mathbb{R}^{m} arrow{r}{psi f phi^{-1}} & psi(f(x)) in psi(V) subseteq mathbb{R}^{n}
end{tikzcd}
begin{tikzpicture}[overlay, remember picture]
draw [->] (u1) edge ["$phi$", right] (u2.north -| u1);
end{tikzpicture}
end{document}
I get
which might be what you are after.
Let me also mention that for your above example you may not use tikzmark
since you have the objects already in TikZ nodes.
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
begin{document}
begin{tikzcd}[remember picture]
A & B\
C & D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (tikzcdmatrixname-1-1) edge (tikzcdmatrixname-2-2);
end{tikzpicture}
end{document}
What I mean is I cannot use tikzmark commands inside a tikzcd environment: as in my sample shows the command tikzmark just cause "Cannot parse this coordinate" error.
– Gau-Syu
Nov 4 at 19:45
@Gau-Syu Yes, that's not surprising since you are essentially nestingtikzpicture
s by doing this, which should be avoided.
– marmot
Nov 4 at 19:46
What makes me confuse is that there are some answers in Tex.SE using tikzmark inside tikzcd, for example tex.stackexchange.com/a/287727/54169 and tex.stackexchange.com/a/176572/54169
– Gau-Syu
Nov 4 at 19:49
@Gau-Syu Yes, but it is clearly stated that you need to usesubnode
then. I believe that the thing above is simpler. (As I said, I really love tikzmark, but would not use it here.)
– marmot
Nov 4 at 19:53
1
@marmot See my answer. Yet again, you've tracked down a bug in tikzmark.
– Loop Space
Nov 4 at 20:47
|
show 6 more comments
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
(Note: I agree with marmot that for this particular case I wouldn't use tikzmark, but I get that it is a simple example and it reveals a bug in tikzmark.)
It would appear that when I modified tikzmark to make it possible to use inside tikzpictures, then I inadvertently broke the ability to use it inside a node (though I'm not sure if that was ever a recommended use!). A node is inside a tikzpicture but should be treated as if it weren't. My current test for whether the tikzmark is inside a tikzpicture doesn't pick up on this. Here's the corrected test:
documentclass{article}
%url{https://tex.stackexchange.com/q/458387/86}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
makeatletter
deftikzmark{%
ifxpgfpictureid@undefined
lettikzmark@next=tikzmark@outside
else
relax
ifxscopetikz@origscoperelax
lettikzmark@next=tikzmark@outside
else
lettikzmark@next=tikzmark@inside
fi
fi
tikzmark@next%
}
makeatother
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (pic cs:u1) -- (pic cs:u2);
end{tikzpicture}
end{document}
I've uploaded this to github and will send it off to CTAN once the amazing testing team of marmot has answered a few questions to check that I haven't broken something else!
Great! That's what I was hoping for! The marmot testing team used this great package in several answers and everything worked absolutely smoothly!
– marmot
Nov 4 at 20:49
My new maxim: never trust anything until it has been stress tested by a marmot.
– Loop Space
Nov 4 at 21:00
add a comment |
up vote
5
down vote
accepted
(Note: I agree with marmot that for this particular case I wouldn't use tikzmark, but I get that it is a simple example and it reveals a bug in tikzmark.)
It would appear that when I modified tikzmark to make it possible to use inside tikzpictures, then I inadvertently broke the ability to use it inside a node (though I'm not sure if that was ever a recommended use!). A node is inside a tikzpicture but should be treated as if it weren't. My current test for whether the tikzmark is inside a tikzpicture doesn't pick up on this. Here's the corrected test:
documentclass{article}
%url{https://tex.stackexchange.com/q/458387/86}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
makeatletter
deftikzmark{%
ifxpgfpictureid@undefined
lettikzmark@next=tikzmark@outside
else
relax
ifxscopetikz@origscoperelax
lettikzmark@next=tikzmark@outside
else
lettikzmark@next=tikzmark@inside
fi
fi
tikzmark@next%
}
makeatother
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (pic cs:u1) -- (pic cs:u2);
end{tikzpicture}
end{document}
I've uploaded this to github and will send it off to CTAN once the amazing testing team of marmot has answered a few questions to check that I haven't broken something else!
Great! That's what I was hoping for! The marmot testing team used this great package in several answers and everything worked absolutely smoothly!
– marmot
Nov 4 at 20:49
My new maxim: never trust anything until it has been stress tested by a marmot.
– Loop Space
Nov 4 at 21:00
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
(Note: I agree with marmot that for this particular case I wouldn't use tikzmark, but I get that it is a simple example and it reveals a bug in tikzmark.)
It would appear that when I modified tikzmark to make it possible to use inside tikzpictures, then I inadvertently broke the ability to use it inside a node (though I'm not sure if that was ever a recommended use!). A node is inside a tikzpicture but should be treated as if it weren't. My current test for whether the tikzmark is inside a tikzpicture doesn't pick up on this. Here's the corrected test:
documentclass{article}
%url{https://tex.stackexchange.com/q/458387/86}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
makeatletter
deftikzmark{%
ifxpgfpictureid@undefined
lettikzmark@next=tikzmark@outside
else
relax
ifxscopetikz@origscoperelax
lettikzmark@next=tikzmark@outside
else
lettikzmark@next=tikzmark@inside
fi
fi
tikzmark@next%
}
makeatother
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (pic cs:u1) -- (pic cs:u2);
end{tikzpicture}
end{document}
I've uploaded this to github and will send it off to CTAN once the amazing testing team of marmot has answered a few questions to check that I haven't broken something else!
(Note: I agree with marmot that for this particular case I wouldn't use tikzmark, but I get that it is a simple example and it reveals a bug in tikzmark.)
It would appear that when I modified tikzmark to make it possible to use inside tikzpictures, then I inadvertently broke the ability to use it inside a node (though I'm not sure if that was ever a recommended use!). A node is inside a tikzpicture but should be treated as if it weren't. My current test for whether the tikzmark is inside a tikzpicture doesn't pick up on this. Here's the corrected test:
documentclass{article}
%url{https://tex.stackexchange.com/q/458387/86}
usepackage{amsmath}
usepackage{tikz-cd}
usetikzlibrary{tikzmark}
makeatletter
deftikzmark{%
ifxpgfpictureid@undefined
lettikzmark@next=tikzmark@outside
else
relax
ifxscopetikz@origscoperelax
lettikzmark@next=tikzmark@outside
else
lettikzmark@next=tikzmark@inside
fi
fi
tikzmark@next%
}
makeatother
begin{document}
begin{tikzcd}
tikzmark{u1}A & B\
C & tikzmark{u2}D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (pic cs:u1) -- (pic cs:u2);
end{tikzpicture}
end{document}
I've uploaded this to github and will send it off to CTAN once the amazing testing team of marmot has answered a few questions to check that I haven't broken something else!
answered Nov 4 at 20:44
Loop Space
110k29294599
110k29294599
Great! That's what I was hoping for! The marmot testing team used this great package in several answers and everything worked absolutely smoothly!
– marmot
Nov 4 at 20:49
My new maxim: never trust anything until it has been stress tested by a marmot.
– Loop Space
Nov 4 at 21:00
add a comment |
Great! That's what I was hoping for! The marmot testing team used this great package in several answers and everything worked absolutely smoothly!
– marmot
Nov 4 at 20:49
My new maxim: never trust anything until it has been stress tested by a marmot.
– Loop Space
Nov 4 at 21:00
Great! That's what I was hoping for! The marmot testing team used this great package in several answers and everything worked absolutely smoothly!
– marmot
Nov 4 at 20:49
Great! That's what I was hoping for! The marmot testing team used this great package in several answers and everything worked absolutely smoothly!
– marmot
Nov 4 at 20:49
My new maxim: never trust anything until it has been stress tested by a marmot.
– Loop Space
Nov 4 at 21:00
My new maxim: never trust anything until it has been stress tested by a marmot.
– Loop Space
Nov 4 at 21:00
add a comment |
up vote
4
down vote
REVISED ANSWER: I could get tikzmark
to collaborate with tikz-cd
by switching to tikzmarknode
. More precisely, if I rewrite cfr's nice answer to become
documentclass{article}
usepackage{tikz-cd,amssymb}
usetikzlibrary{tikzmark,quotes}
begin{document}
begin{tikzcd}
x in tikzmarknode{u1}{U} subseteq M arrow{r}{f} & f(x) in V subseteq
tikzmarknode{n}{N} arrow{d}{psi} \
phi(x) in tikzmarknode{u2}{phi(U)} subseteq mathbb{R}^{m} arrow{r}{psi f phi^{-1}} & psi(f(x)) in psi(V) subseteq mathbb{R}^{n}
end{tikzcd}
begin{tikzpicture}[overlay, remember picture]
draw [->] (u1) edge ["$phi$", right] (u2.north -| u1);
end{tikzpicture}
end{document}
I get
which might be what you are after.
Let me also mention that for your above example you may not use tikzmark
since you have the objects already in TikZ nodes.
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
begin{document}
begin{tikzcd}[remember picture]
A & B\
C & D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (tikzcdmatrixname-1-1) edge (tikzcdmatrixname-2-2);
end{tikzpicture}
end{document}
What I mean is I cannot use tikzmark commands inside a tikzcd environment: as in my sample shows the command tikzmark just cause "Cannot parse this coordinate" error.
– Gau-Syu
Nov 4 at 19:45
@Gau-Syu Yes, that's not surprising since you are essentially nestingtikzpicture
s by doing this, which should be avoided.
– marmot
Nov 4 at 19:46
What makes me confuse is that there are some answers in Tex.SE using tikzmark inside tikzcd, for example tex.stackexchange.com/a/287727/54169 and tex.stackexchange.com/a/176572/54169
– Gau-Syu
Nov 4 at 19:49
@Gau-Syu Yes, but it is clearly stated that you need to usesubnode
then. I believe that the thing above is simpler. (As I said, I really love tikzmark, but would not use it here.)
– marmot
Nov 4 at 19:53
1
@marmot See my answer. Yet again, you've tracked down a bug in tikzmark.
– Loop Space
Nov 4 at 20:47
|
show 6 more comments
up vote
4
down vote
REVISED ANSWER: I could get tikzmark
to collaborate with tikz-cd
by switching to tikzmarknode
. More precisely, if I rewrite cfr's nice answer to become
documentclass{article}
usepackage{tikz-cd,amssymb}
usetikzlibrary{tikzmark,quotes}
begin{document}
begin{tikzcd}
x in tikzmarknode{u1}{U} subseteq M arrow{r}{f} & f(x) in V subseteq
tikzmarknode{n}{N} arrow{d}{psi} \
phi(x) in tikzmarknode{u2}{phi(U)} subseteq mathbb{R}^{m} arrow{r}{psi f phi^{-1}} & psi(f(x)) in psi(V) subseteq mathbb{R}^{n}
end{tikzcd}
begin{tikzpicture}[overlay, remember picture]
draw [->] (u1) edge ["$phi$", right] (u2.north -| u1);
end{tikzpicture}
end{document}
I get
which might be what you are after.
Let me also mention that for your above example you may not use tikzmark
since you have the objects already in TikZ nodes.
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
begin{document}
begin{tikzcd}[remember picture]
A & B\
C & D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (tikzcdmatrixname-1-1) edge (tikzcdmatrixname-2-2);
end{tikzpicture}
end{document}
What I mean is I cannot use tikzmark commands inside a tikzcd environment: as in my sample shows the command tikzmark just cause "Cannot parse this coordinate" error.
– Gau-Syu
Nov 4 at 19:45
@Gau-Syu Yes, that's not surprising since you are essentially nestingtikzpicture
s by doing this, which should be avoided.
– marmot
Nov 4 at 19:46
What makes me confuse is that there are some answers in Tex.SE using tikzmark inside tikzcd, for example tex.stackexchange.com/a/287727/54169 and tex.stackexchange.com/a/176572/54169
– Gau-Syu
Nov 4 at 19:49
@Gau-Syu Yes, but it is clearly stated that you need to usesubnode
then. I believe that the thing above is simpler. (As I said, I really love tikzmark, but would not use it here.)
– marmot
Nov 4 at 19:53
1
@marmot See my answer. Yet again, you've tracked down a bug in tikzmark.
– Loop Space
Nov 4 at 20:47
|
show 6 more comments
up vote
4
down vote
up vote
4
down vote
REVISED ANSWER: I could get tikzmark
to collaborate with tikz-cd
by switching to tikzmarknode
. More precisely, if I rewrite cfr's nice answer to become
documentclass{article}
usepackage{tikz-cd,amssymb}
usetikzlibrary{tikzmark,quotes}
begin{document}
begin{tikzcd}
x in tikzmarknode{u1}{U} subseteq M arrow{r}{f} & f(x) in V subseteq
tikzmarknode{n}{N} arrow{d}{psi} \
phi(x) in tikzmarknode{u2}{phi(U)} subseteq mathbb{R}^{m} arrow{r}{psi f phi^{-1}} & psi(f(x)) in psi(V) subseteq mathbb{R}^{n}
end{tikzcd}
begin{tikzpicture}[overlay, remember picture]
draw [->] (u1) edge ["$phi$", right] (u2.north -| u1);
end{tikzpicture}
end{document}
I get
which might be what you are after.
Let me also mention that for your above example you may not use tikzmark
since you have the objects already in TikZ nodes.
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
begin{document}
begin{tikzcd}[remember picture]
A & B\
C & D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (tikzcdmatrixname-1-1) edge (tikzcdmatrixname-2-2);
end{tikzpicture}
end{document}
REVISED ANSWER: I could get tikzmark
to collaborate with tikz-cd
by switching to tikzmarknode
. More precisely, if I rewrite cfr's nice answer to become
documentclass{article}
usepackage{tikz-cd,amssymb}
usetikzlibrary{tikzmark,quotes}
begin{document}
begin{tikzcd}
x in tikzmarknode{u1}{U} subseteq M arrow{r}{f} & f(x) in V subseteq
tikzmarknode{n}{N} arrow{d}{psi} \
phi(x) in tikzmarknode{u2}{phi(U)} subseteq mathbb{R}^{m} arrow{r}{psi f phi^{-1}} & psi(f(x)) in psi(V) subseteq mathbb{R}^{n}
end{tikzcd}
begin{tikzpicture}[overlay, remember picture]
draw [->] (u1) edge ["$phi$", right] (u2.north -| u1);
end{tikzpicture}
end{document}
I get
which might be what you are after.
Let me also mention that for your above example you may not use tikzmark
since you have the objects already in TikZ nodes.
documentclass{article}
usepackage{amsmath}
usepackage{tikz-cd}
begin{document}
begin{tikzcd}[remember picture]
A & B\
C & D
end{tikzcd}
begin{tikzpicture}[remember picture,overlay]
draw[->] (tikzcdmatrixname-1-1) edge (tikzcdmatrixname-2-2);
end{tikzpicture}
end{document}
edited Nov 4 at 20:27
answered Nov 4 at 19:41
marmot
73.8k480155
73.8k480155
What I mean is I cannot use tikzmark commands inside a tikzcd environment: as in my sample shows the command tikzmark just cause "Cannot parse this coordinate" error.
– Gau-Syu
Nov 4 at 19:45
@Gau-Syu Yes, that's not surprising since you are essentially nestingtikzpicture
s by doing this, which should be avoided.
– marmot
Nov 4 at 19:46
What makes me confuse is that there are some answers in Tex.SE using tikzmark inside tikzcd, for example tex.stackexchange.com/a/287727/54169 and tex.stackexchange.com/a/176572/54169
– Gau-Syu
Nov 4 at 19:49
@Gau-Syu Yes, but it is clearly stated that you need to usesubnode
then. I believe that the thing above is simpler. (As I said, I really love tikzmark, but would not use it here.)
– marmot
Nov 4 at 19:53
1
@marmot See my answer. Yet again, you've tracked down a bug in tikzmark.
– Loop Space
Nov 4 at 20:47
|
show 6 more comments
What I mean is I cannot use tikzmark commands inside a tikzcd environment: as in my sample shows the command tikzmark just cause "Cannot parse this coordinate" error.
– Gau-Syu
Nov 4 at 19:45
@Gau-Syu Yes, that's not surprising since you are essentially nestingtikzpicture
s by doing this, which should be avoided.
– marmot
Nov 4 at 19:46
What makes me confuse is that there are some answers in Tex.SE using tikzmark inside tikzcd, for example tex.stackexchange.com/a/287727/54169 and tex.stackexchange.com/a/176572/54169
– Gau-Syu
Nov 4 at 19:49
@Gau-Syu Yes, but it is clearly stated that you need to usesubnode
then. I believe that the thing above is simpler. (As I said, I really love tikzmark, but would not use it here.)
– marmot
Nov 4 at 19:53
1
@marmot See my answer. Yet again, you've tracked down a bug in tikzmark.
– Loop Space
Nov 4 at 20:47
What I mean is I cannot use tikzmark commands inside a tikzcd environment: as in my sample shows the command tikzmark just cause "Cannot parse this coordinate" error.
– Gau-Syu
Nov 4 at 19:45
What I mean is I cannot use tikzmark commands inside a tikzcd environment: as in my sample shows the command tikzmark just cause "Cannot parse this coordinate" error.
– Gau-Syu
Nov 4 at 19:45
@Gau-Syu Yes, that's not surprising since you are essentially nesting
tikzpicture
s by doing this, which should be avoided.– marmot
Nov 4 at 19:46
@Gau-Syu Yes, that's not surprising since you are essentially nesting
tikzpicture
s by doing this, which should be avoided.– marmot
Nov 4 at 19:46
What makes me confuse is that there are some answers in Tex.SE using tikzmark inside tikzcd, for example tex.stackexchange.com/a/287727/54169 and tex.stackexchange.com/a/176572/54169
– Gau-Syu
Nov 4 at 19:49
What makes me confuse is that there are some answers in Tex.SE using tikzmark inside tikzcd, for example tex.stackexchange.com/a/287727/54169 and tex.stackexchange.com/a/176572/54169
– Gau-Syu
Nov 4 at 19:49
@Gau-Syu Yes, but it is clearly stated that you need to use
subnode
then. I believe that the thing above is simpler. (As I said, I really love tikzmark, but would not use it here.)– marmot
Nov 4 at 19:53
@Gau-Syu Yes, but it is clearly stated that you need to use
subnode
then. I believe that the thing above is simpler. (As I said, I really love tikzmark, but would not use it here.)– marmot
Nov 4 at 19:53
1
1
@marmot See my answer. Yet again, you've tracked down a bug in tikzmark.
– Loop Space
Nov 4 at 20:47
@marmot See my answer. Yet again, you've tracked down a bug in tikzmark.
– Loop Space
Nov 4 at 20:47
|
show 6 more comments
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
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458387%2fhow-to-use-tikzmark-inside-tikz-cd%23new-answer', 'question_page');
}
);
Post as a guest
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
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
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
You don't. Just add
remember picture
to thetikzcd
and refer to the nodes with(tikzcdmatrixname-1-1)
and so on.– marmot
Nov 4 at 19:38
Note that xelatex has known issues with positioning, and so with tikzmark.
– Loop Space
Nov 4 at 20:46
Thanks for accepting my answer. However, the answer by LoopSpace is clearly better, Could you please accept it instead?
– marmot
Nov 4 at 20:50