下面的代码
\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{shadows,matrix,arrows}
\begin{document}
\begin{tikzpicture}\small\begin{scope}[->,shorten >=3pt,shorten <=3pt]
\matrix (m) [matrix of math nodes,row sep=0.5cm, column sep=1cm,outer sep=0pt,inner sep=0pt]
{ & \\
&e_{12}e_{14}e_{25}e_{25}e_{25} \\
e_{14}e_{15}e_{24}e_{25}&e_{12}e_{15}e_{24}e_{25}e_{25} \\
&e_{13}e_{14}e_{35}e_{25}e_{25} \\
&e_{13}e_{15}e_{34}e_{25}e_{25} \\
&e_{13}e_{25}e_{34}e_{25}e_{25} \\};
\path[-] (m-3-1) edge (m-2-2) edge (m-3-2) edge (m-4-2) edge (m-5-2) edge (m-6-2);
\path[-,red] (m-3-1) edge (m-5-2);
\end{scope}\end{tikzpicture}
\end{document}
生产。
如何实现来自/到某个节点的所有边都有一个共同的起点/终点?
答案1
您插入的边多于必要边。您需要 4 个黑色边和 1 个红色边。正如 @Ignasi 所引用的,您可以将节点锚点更改为west
并将更改为east
。
如果有必要,\path
如果您认为某个位置不太好,只需使用另一个带有不同锚点的命令即可。例如,您可以使用south
或south west
等等。
\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{shadows,matrix,arrows}
\begin{document}
\begin{tikzpicture}\small
\begin{scope}[->,shorten >=3pt,shorten <=3pt]
\matrix (m) [matrix of math nodes,row sep=0.5cm, column sep=1cm,outer sep=0pt,inner sep=0pt]
{ & \\
& e_{12}e_{14}e_{25}e_{25}e_{25} \\
e_{14}e_{15}e_{24}e_{25}&e_{12}e_{15}e_{24}e_{25}e_{25} \\
& e_{13}e_{14}e_{35}e_{25}e_{25} \\
& e_{13}e_{15}e_{34}e_{25}e_{25} \\
& e_{13}e_{25}e_{34}e_{25}e_{25} \\
};
\path[-] (m-3-1.east) edge (m-2-2.west) edge (m-3-2.west) edge (m-4-2.west) edge (m-6-2.west);
\path[-,red] (m-3-1.east) edge (m-5-2.west);
\end{scope}
\end{tikzpicture}
\end{document}
答案2
和tikz-cd
:
\documentclass[10pt]{amsart}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[row sep=2ex]
&e_{12}e_{14}e_{25}e_{25}e_{25} \\
e_{14}e_{15}e_{24}e_{25}
\ar[ur,dash,start anchor=real east,end anchor=real west]
\ar[r,dash,start anchor=real east,end anchor=real west]
\ar[dr,dash,start anchor=real east,end anchor=real west]
\ar[ddr,dash,start anchor=real east,end anchor=real west,red]
\ar[dddr,dash,start anchor=real east,end anchor=real west]
&e_{12}e_{15}e_{24}e_{25}e_{25} \\
&e_{13}e_{14}e_{35}e_{25}e_{25} \\
&e_{13}e_{15}e_{34}e_{25}e_{25} \\
&e_{13}e_{25}e_{34}e_{25}e_{25}
\end{tikzcd}
\end{document}
由于所有箭头都具有相同的属性,因此可以在选项中将它们设置为\begin{tikzcd}
(感谢 Gonzalo Medina 的建议):
\begin{tikzcd}[
row sep=2ex,
arrows=dash,
start anchor=real east,
end anchor=real west,
]
&e_{12}e_{14}e_{25}e_{25}e_{25} \\
e_{14}e_{15}e_{24}e_{25}
\ar[ur]
\ar[r]
\ar[dr]
\ar[ddr,red]
\ar[dddr]
&e_{12}e_{15}e_{24}e_{25}e_{25} \\
&e_{13}e_{14}e_{35}e_{25}e_{25} \\
&e_{13}e_{15}e_{34}e_{25}e_{25} \\
&e_{13}e_{25}e_{34}e_{25}e_{25}
\end{tikzcd}
答案3
只是为了好玩和练习,一个解决方案forest
\documentclass[10pt]{amsart}
\usepackage{forest}
\begin{document}
\begin{forest}
[$e_{14}e_{15}e_{24}e_{25}$, grow'=east,
for tree={parent anchor=east,child anchor=west}, l sep=.75cm
[$e_{12}e_{14}e_{25}e_{25}e_{25}$]
[$e_{12}e_{15}e_{24}e_{25}e_{25}$, calign with current]
[$e_{13}e_{14}e_{35}e_{25}e_{25}$]
[$e_{13}e_{15}e_{34}e_{25}e_{25}$, edge={red}]
[$e_{13}e_{25}e_{34}e_{25}e_{25}$]]
\end{forest}
\end{document}