我需要在“在此处写入文本”处添加注释。我不希望它成为节点的一部分。有没有办法在节点旁边添加注释。
以下是我的代码;
谢谢
\tikzstyle{every node}=[draw=white,thick,anchor=west]
\tikzstyle{selected}=[dashed,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]
\begin{tikzpicture}[%
grow via three points={one child at (0.5,-0.7) and
two children at (0.5,-0.7) and (0.5,-1.4)},
edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
\node[fill=purple] {\color{white}\textbf{{Main Theorem}}}
child { node {Lemma1: {\small Write Text Here}}}
child { node {Lemma2:}
child {node {\small Write Text Here}}}
child { node {Lemma3: {\small n}}}
child { node {Lemma4: {\small Write Text Here}}}
child { node {Lemma5: {\small Write Text Here}}}
child { node {Lemma6: {\small Write Text Here}}}
child { node [selected]{Lemma7: {\small Write Text Here}}}
child { node [selected]{Lemma8: {\small Write Text Here}}}
%child [missing] {}
child { node [selected]{Lemma9: {\small Write Text Here}}}
;
\end{tikzpicture}
答案1
在我看来,当tikz-qtree
存在 Forest 或 等选项时,它过于冗长,但对于那些喜欢打字的人来说:
\documentclass[border=10pt,tikz,multi]{standalone}
\usetikzlibrary{trees}
\begin{document}
\tikzset{% \tikzstyle is deprecated
every node/.style = {draw=white, thick, anchor=west},
selected/.style = {dashed, fill=red!30},
optional/.style = {dashed, fill=gray!50},
}
\begin{tikzpicture}[%
grow via three points = {one child at (0.5,-0.7) and two children at (0.5,-0.7) and (0.5,-1.4)},
edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)},
every label/.append style={font=\small},
]
\node[fill=purple] {\color{white}\textbf{{Main Theorem}}}
child { node [label=right:Write Text Here] {Lemma1: }}
child { node {Lemma2:}
child {node [label=right:Write Text Here] {}}}
child [missing] {}
child { node {Lemma3: {\small n}}}
child { node [label=right: Write Text Here] {Lemma4: }}
child { node [label=right:Write Text Here] {Lemma5: }}
child { node [label=right:Write Text Here] {Lemma6: }}
child { node [label=right:Write Text Here] [selected]{Lemma7: }}
child { node [label=right:Write Text Here] [selected]{Lemma8: }}
child { node [label=right:Write Text Here] [selected]{Lemma9: }}
;
\end{tikzpicture}
\end{document}
生产
毫不奇怪,我不会这样做,而是做下面这样的事情。
\documentclass[border=10pt,tikz,multi]{standalone}
\usepackage[edges]{forest}
\begin{document}
\tikzset{% \tikzstyle is deprecated
every node/.style = {draw=white, thick},
selected/.style = {dashed, fill=red!30},
optional/.style = {dashed, fill=gray!50},
every label/.append style={font=\small},
}
\begin{forest}
forked edges,
for tree={%
folder,
draw,
grow'=0
}
[\textbf{Main Theorem}, white, fill=purple
[Lemma1:, label=right:Write Text Here]
[Lemma2:
[, label=right:Write Text Here]
]
[Lemma3: {\small n}]
[Lemma4:, label=right:Write Text Here]
[Lemma5:, label=right:Write Text Here]
[Lemma6:, label=right:Write Text Here]
[Lemma7:, label=right:Write Text Here, selected]
[Lemma8:, label=right:Write Text Here, selected]
[Lemma9:, label=right:Write Text Here, selected]
]
\end{forest}
\end{document}
这得出