[Tex/LaTex] How to format text inside a node

nodestikz-trees

I'm making an academic family tree and I'd like to put a couple of bullet points of info for each person. I'm just starting with LaTeX, so this is the simplest code possible:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[sibling distance=10em,
  every node/.style = {shape=rectangle, rounded corners,
    draw, align=center,
    top color=white, bottom color=blue!20}]]
  \node {Manfred Kock}
    child { node {Karsten Danzmann}
      child { node {\underline{Guido Mueller} }
        child { node [draw, align=left]{\underline{Marina Longnickel} \\blah} }
        child { node {Aaron Spector} }
        child { node {James Ira Thorpe} } 
        child { node {Alix Preston} }
            }
      child { node {Oliver Jennrich} }
      child { node {Gerhard Heinzel} }
         };
\end{tikzpicture}
\end{document}

Is there a way to edit text the way one would in a Word document – underline, make bullet points, change font and size, etc?

Best Answer

Something like this?

enter image description here

I only change far left bottom node. Beside used underline in tabular environment are other possibilities which I can elaborate latter.

Code of above image is:

\documentclass[border=10pt]{standalone}
    \usepackage{tikz}
    \usepackage{paralist}
    \usepackage{ragged2e}
\begin{document}
\begin{tikzpicture}[sibling distance=10em,
  every node/.style = {shape=rectangle, rounded corners,
                       draw, anchor=north, align=center,
                       top color=white, bottom color=blue!20}]]
  \node {Manfred Kock}
    child { node {Karsten Danzmann}
      child { node {Guido Mueller}
        child { node {Marina Longnickel\\ 
                            \scriptsize
                        \begin{tabular}{l}%or c or 
                    \hline
                    \textbullet\ some additional\\
                                information about\\ 
                                person\\
                    \textbullet\ simple manual\\
                                formatting
                        \end{tabular}}}
        child { node {\underline{Aaron Spector}\\
                    \begin{minipage}{28mm}
                        \footnotesize\RaggedLeft
                        \begin{compactitem}[\textbullet]
                    \item some text
                    \item some longer text which need two lines
                        \end{compactitem}
                    \end{minipage}
                     } }
        child { node {James Ira Thorpe} }
        child { node {Alix Preston} }
            }
      child { node {Oliver Jennrich} }
      child { node {Gerhard Heinzel} }
         };
\end{tikzpicture}
\end{document}

Edit: In above code, according to additional information received in comments, I extend my first code with two case:

  • let be emphasized, that nodes top ar in-line, I add anchor=north in definition of node features.
  • far left bottom node use tabular and \textbullet for additional text. Instead of \underline} for line under name I use\hline` in tabular,
  • in the next node on right I use minipage and compactitem from package paralist. Here the left to setting width of minipage manually, however, it can be set width of node width text width=31mm and then omit minipage

    \node[text width=33mm]\begin{compactitem}[\textbullet] ...

enter image description here

Edit (2): For use in beamer (as follows from your comment) you need to solve, how to fit image in frame. Frame's width is about 124 mm (if recall correct). Therefore I decided to have all nodes with the same fixed width determined by text width=22mm and sibling distance=26mm. Also I select for size for main text in node \scriptsize and for comments in items tiny size. Of course, you can change this selection to your taste and wish. Obtained image is:

enter image description here

As you can see, now I pay attention to connection between nodes and use the same style as proposed cfr, but I still persist on pure TikZ solution. Code for above image is:

\documentclass{beamer}
    \usepackage{tikz}
\usetikzlibrary{trees}
    \usepackage{paralist}
    \usepackage{ragged2e}
    \begin{document}
\begin{frame}
\hspace*{-4mm}% for horizontal centering of image on frame
\begin{tikzpicture}[
   sibling distance = 26mm,% newmeasure
  every node/.style = {shape=rectangle, rounded corners,
                       draw, anchor=north, font=\scriptsize,
                       text width=22mm, align=center,% fixed width of nodes
                       top color=white, bottom color=blue!20},
%edge from parent/.append style={thick},
    edge from parent fork down,
                        ]
  \node {Manfred Kock}
    child { node {Karsten Danzmann}
      child { node {Guido Mueller}
        child { node {\underline{Marina Longnickel}\\
                        \tiny\RaggedLeft
                        \begin{compactitem}[\textbullet]
                    \item some additional information about person
                    \item simple manual formatting
                        \end{compactitem}
                    } }
        child { node {\underline{Aaron Spector}\\
                        \tiny\RaggedLeft
                        \begin{compactitem}[\textbullet]
                    \item some text
                    \item some longer text which need two lines
                        \end{compactitem}
                     } }
        child { node {James Ira Thorpe} }
        child { node {Alix Preston} }
            }
      child { node {Oliver Jennrich} }
      child { node {Gerhard Heinzel} }
         };
\end{tikzpicture}
\end{frame}
    \end{document}