我们怎样才能用包含箭头替换右箭头,同时保持底部箭头笔直?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
{
M,\phi,\xi,\eta,g & C(M),\omega,\bar{g},\bar{\phi}\\
Z,\Omega,h,J \\};
\path[-stealth]
(m-1-1) [right hook->] edge node[anchor=east] {}
node [right] {} (m-1-2)
edge node [left] {} (m-2-1);
\end{tikzpicture}
\end{document}
答案1
我建议使用tikz-cd
语法更简单的方法:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
M,\phi,\xi,\eta,g \arrow[r,hook] \arrow[d] & C(M),\omega,\bar{g},\bar{\phi}\\
Z,\Omega,h,J
\end{tikzcd}
\end{document}
如果您想要stealth
箭头,您可以全局设置它们:
\documentclass{article}
\usepackage{tikz-cd}
\tikzcdset{
arrow style=tikz,
diagrams={>=stealth},
}
\begin{document}
\begin{tikzcd}
M,\phi,\xi,\eta,g \arrow[r,hook] \arrow[d] & C(M),\omega,\bar{g},\bar{\phi}\\
Z,\Omega,h,J
\end{tikzcd}
\end{document}
答案2
虽然我同意egreg's suggestion
关于如何使用tikz-cd
,以下是如何在当前设置下使用。您有两种选择:
- 将箭头规范中的更改括在括号中,以使其保持本地化。
[-stealth]
在边缘之前添加以恢复箭头类型。
我在下面说明了这两个选项。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}[>=stealth]
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
{
M,\phi,\xi,\eta,g & C(M),\omega,\bar{g},\bar{\phi}\\
Z,\Omega,h,J \\
};
\path[->]
(m-1-1) [right hook-stealth] edge node[anchor=east] {}
node [right] {} (m-1-2)
[->] edge node [left] {} (m-2-1);
\end{tikzpicture}\par\bigskip
\begin{tikzpicture}[>=stealth]
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
{
M,\phi,\xi,\eta,g & C(M),\omega,\bar{g},\bar{\phi}\\
Z,\Omega,h,J \\
};
\path[->]
(m-1-1) {[right hook->] edge node[anchor=east] {}
node [right] {} (m-1-2)}
edge node [left] {} (m-2-1);
\end{tikzpicture}
\end{document}