9

Is it possible to add some snow on the syntax trees drawn by tikz-qtree? A simple example:

\documentclass[11pt]{article}
\usepackage{fontspec}
\usepackage{savetrees}
\setmainfont[Mapping=tex-text]{DejaVu Sans}
\usepackage{tikz-qtree, tikz-qtree-compat}
\tikzset{every tree node/.style={align=center, anchor=north}}
\providecommand{\alert}[1]{\textbf{#1}}

\title{tree}
\author{}
\date{\today}

\begin{document}

\section{Tree}
\label{sec-1}

\begin{tikzpicture}
\tikzset{every tree node/.style={align=center, anchor=north}}
\Tree [.TP [.DP \edge[roof ];\\I ] [.T' ] [.T\\ø ] [.VP [.V' [.V\\eat ]
      [.DP \edge[roof ];\\potatoes ] ] ] ]

\end{tikzpicture}

\end{document}
3
  • 6
    Oh TikZmas tree... :)
    – Count Zero
    Dec 9 '12 at 20:46
  • Where would you like them? As terminal nodes? Or somewhere else?
    – Alan Munn
    Dec 9 '12 at 21:16
  • On the diagonal edges of the tree, preferably also applicable at larger trees. Dec 9 '12 at 21:17
17

Here's a tree with randomly chosen and sized snowflakes on the edges of nodes. If you can find more snowflake characters, they can be added to the list. Each time you compile the document the pattern will change. I've used LuaTeX to compile, since XeTeX doesn't provide good access to any quickly changing time value to seed the random number generator. PGF uses \time * \year as the seed by default and so the image will only change every minute if you compile with XeTeX.

% !TEX TS-program = LuaLaTeX

\documentclass{article}
\usepackage{pdftexcmds} % used to give LuaTeX access to \pdf@elapsedtime
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Linux Biolinum O}
\usepackage{tikz-qtree, tikz-qtree-compat}
\tikzset{every tree node/.style={align=center, anchor=north}}
\newfontfamily\zapf{Zapf Dingbats}
\newcommand*{\flakeA}{\zapf❄}
\newcommand*{\flakeB}{\zapf❅}
\newcommand*{\flakeC}{\zapf❆}
\makeatletter
\pgfmathsetseed{\the\pdf@elapsedtime} % remove this if using XeTeX
\makeatother
\pgfmathdeclarerandomlist{size}{{Large}{huge}{large}{normalsize}}
\pgfmathdeclarerandomlist{flake}{{flakeA}{flakeB}{flakeC}}
\newcommand{\Rnd}{\pgfmathrandomitem{\S}{size}\pgfmathrandomitem{\FF}{flake}}
\newcommand*{\Flake}{\Rnd\csname\S\endcsname\csname\FF\endcsname}
\tikzset{every tree node/.style={align=center, anchor=north}
}
\begin{document}

\begin{tikzpicture}[sibling distance=1cm]
\Tree [.TP \edge node[auto=right]{\Flake};  
        [.DP\\We ] \edge node[auto=left]{\Flake}; 
        [.T\1 \edge node[auto=right]{\Flake};  
          [.T ]  \edge node[auto=left]{\Flake}; 
          [.VP \edge node[auto=right]{\Flake};
            [.V\\wish ] \edge node[auto=left]{\Flake};
            [.DP\\you ] \edge node[auto=left]{\Flake};
            [.DP \edge node[auto=right]{\Flake};
              [.D\\a ] \edge node[auto=left]{\Flake};
              [.NP \edge node[auto=right]{\Flake};
                [.AP\\Merry ] \edge node[auto=left]{\Flake};
                [.NP\\Christmas ] 
              ]
            ]
          ]
        ]
      ]
\end{tikzpicture}

\end{document}

output of code

1
  • Awesome, Alan! This would be an excelent X-mas card for linguists. :) Dec 10 '12 at 9:12

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.