答案1
也许你打算tikz-cd
:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[every arrow/.append style={dash},
row sep = 10pt]
&&d\ar[dddd]\\
&b\ar[ur]\\
a\ar[dr]\ar[ur]\\
&c\ar[dr]\\
&&e\\
\end{tikzcd}
\end{document}
如果您的节点不是数学节点,您可以使用包\text{...}
中的节点:amsmath
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\begin{document}
\begin{tikzcd}[every arrow/.append style={dash}, row sep = 10pt]
&&\text{d}\ar[dddd]\\
&\text{b}\ar[ur]\\
\text{a}\ar[dr]\ar[ur]\\
&\text{c}\ar[dr]\\
&&\text{e}\\
\end{tikzcd}
\end{document}
或者,如果您的文本比简单的字母更复杂,则tikz matrix
直接:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[row sep = 10pt,
column sep=20pt,
matrix of nodes] (m) {
&&d\\
&b\\
a\\
&c\\
&&e\\
};
\draw (m-1-3) -- (m-2-2) -- (m-3-1) -- (m-4-2) -- (m-5-3) -- (m-1-3);
\end{tikzpicture}
\end{document}
或者不使用任何矩阵:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[node distance=10pt and 20pt]
\node (d) {d};
\node[below left = of d] (b) {b};
\node[below left = of b] (a) {a};
\node[below right = of a] (c) {c};
\node[below right = of c] (e) {e};
\draw (a) -- (b) -- (d) -- (e) -- (c) -- (a);
\end{tikzpicture}
\end{document}
(结果和以前一样)。
答案2
另外tikz-cd
,您可以使用此代码。
\documentclass[10pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (a) {$a$} node (b) at (2,1) {$p$} node (c) at (2,-1) {$d$};
\draw (a) -- (b);
\draw (a) -- (c);
\draw (b) -- (c);
\node[fill=white,text=black] at (1,0.5) {$e$} ;
\node[fill=white,text=black] (v1) at (1,-0.5) {$f$};
\end{tikzpicture}
\end{document}