0

I need to add notes where "Write Text Here" is. I do not want it to be part of the node. Is there a way to add notes next to a node.

Below is my code;

Thank you

\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}  
2
  • 2
    Welcome to TeX.SX!! You can highlight code in your post using back-ticks. For code-blocks indent them by four spaces or use the {} on the gui. It is better to post a full minimal working example. For example, if you are using latex then it should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. This makes it much easier for people to help you --- and much more likely that they will! – user30471 Apr 11 '16 at 21:20
  • They are just TikZ nodes so you can label then e.g. ... node [label=right:{\small Write Text Here}] ... {Lemma2} etc. – cfr Apr 11 '16 at 22:35
1

Excessively verbose, in my view, when options such as Forest or tikz-qtree exist, but for those who enjoy typing:

\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}

produces

labelled tree

It will come as no surprise that I would not do this but instead something like the following.

\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}

This yields

Forest version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.