我有一棵向上生长的树,显示了证明的流程,如下所示:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\resizebox{\textwidth}{!}{%
\begin{tikzpicture}[edge from parent path=
{(\tikzparentnode.north) .. controls +(0,1) and +(0,-1)
.. (\tikzchildnode.south)}]
\node {L5. $(A)\rightarrow(A)$} [grow'=up] %node[above]{MP}
[sibling distance=60mm]
child {node {L3. $(A)\rightarrow((A)\lor(A))$}
child {node {P2. $(x)\rightarrow((x)\lor(y))$}}
}
child {node {$((A)\rightarrow((A)\lor(A)))\rightarrow((A)\rightarrow(A))$}
child {node {L4. $((\lnot(A))\lor((A)\lor(A)))\rightarrow((\lnot(A))\lor(A))$} edge from parent[dashed]
[sibling distance=80mm]
child {node {L1. $((A)\lor(A))\rightarrow(A)$} edge from parent[solid]
child{node {P1. $((x)\lor(x))\rightarrow(x)$}}}
child {node {L2. $(((A)\lor(A))\rightarrow(A))\rightarrow(((\lnot(A))\lor((A)\lor(A)))\rightarrow((\lnot(A))\lor(A)))$} edge from parent[solid]
child{node {P2. $(x)\rightarrow((x)\lor(y))$}}}}
};
\end{tikzpicture}
}
\end{document}
我想在“L5.”和“L4.”分叉上方(在括号上方,而不是在括号和语句之间)放置一个短小的标签(“MP”),但在我尝试过的所有地方添加节点都会以各种方式破坏图表。我是否只是错误地添加了节点,或者是否需要将这样的标签与树分开处理(通过显式放置等)?
提前致谢。
答案1
这是一个解决方案,为树中的这两个节点添加内部标签 (L4) 和 (L5)。然后在树的末尾使用带选项\node
的命令放置标签。above
MP
代码
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\resizebox{\textwidth}{!}{%
\begin{tikzpicture}[edge from parent path=
{(\tikzparentnode.north) .. controls +(0,1) and +(0,-1)
.. (\tikzchildnode.south)}]
\node (L5){L5. $(A)\rightarrow(A)$} [grow'=up] %node[above]{MP}
[sibling distance=60mm]
child {node {L3. $(A)\rightarrow((A)\lor(A))$}
child {node {P2. $(x)\rightarrow((x)\lor(y))$}}
}
child {node {$((A)\rightarrow((A)\lor(A)))\rightarrow((A)\rightarrow(A))$}
child {node (L4) {L4. $((\lnot(A))\lor((A)\lor(A)))\rightarrow((\lnot(A))\lor(A))$} edge from parent[dashed]
[sibling distance=80mm]
child {node {L1. $((A)\lor(A))\rightarrow(A)$} edge from parent[solid]
child{node {P1. $((x)\lor(x))\rightarrow(x)$}}}
child {node {L2. $(((A)\lor(A))\rightarrow(A))\rightarrow(((\lnot(A))\lor((A)\lor(A)))\rightarrow((\lnot(A))\lor(A)))$} edge from parent[solid]
child{node {P2. $(x)\rightarrow((x)\lor(y))$}}}}
};
\node[above=0.6cm] at (L4){\small MP};
\node[above=0.6cm] at (L5){\small MP};
\end{tikzpicture}
}
\end{document}