An über-minimal guide to drawing trees and features in LATEX

An über-minimal guide to drawing trees and
features in LATEX
Greg Kobele
Syntax I
Autumn 2015
Trees
The basics
I prefer using TikZ for graphics. TikZ is a front-end for the pgf macro package
(both written by the guy who wrote beamer). There is an amazing manual.
To use TikZ your preamble must include \usepackage{tikz}.
The TikZ picture environment is called tikzpicture. All drawing commands
within this environment must be terminated with a semicolon (;). Tree drawing
is effected with the following intuitive syntax:
node {text}
child { -tree 1- }
...
child { -tree n- }
The root of the tree is introduced with a backslash before the node keyword:
\node {text}
child { node {text1} }
child { node {text2}
child { node {text3} } }
In the tikzpicture environment, and terminated with a semicolon, we get:
text
text1
text2
text3
1
A more linguistic-y example is :
\begin{tikzpicture}
\node {TP}
child { node {Sub} }
child { node {T’}
child { node {T} }
child { node {VP}
child { node {V} }
child { node {Obj} } } };
\end{tikzpicture}
which gives rise to:
TP
Sub
T’
T
VP
V
Obj
The environment takes optional arguments (like sibling distance, level distance, etc) which influence the result:
\begin{tikzpicture}[
sibling distance=3em,
level distance=1em
]
\node {TP}
child { node {Sub} }
child { node {T’}
child { node {T} }
child { node {VP}
child { node {V} }
child { node {Obj} } } };
\end{tikzpicture}
TP
Sub
T’
T
VP
Obj
V
2
These optional arguments can be revised at various points in the tikzpicture
environment with the tikzset command. Nodes can be given an explicit location with the syntax at (x,y)1 , which is useful if you have more than one
graphics command in the tikzpicture environment.
\begin{tikzpicture}
\node at (-4,0) {TP}
child { node {Sub} }
child { node {T’}
child { node {T} }
child { node {VP}
child { node {V} }
child { node {Obj} } } };
\tikzset{sibling distance=3em,level distance=1em}
\node at (4,-2) {TP}
child { node {Sub} }
child { node {T’}
child { node {T} }
child { node {VP}
child { node {V} }
child { node {Obj} } } };
\tikzset{sibling distance=2em,level distance=2em}
\node at (0,-1) {TP}
child { node {Sub} }
child { node {T’}
child { node {T} }
child { node {VP}
child { node {V} }
child { node {Obj} } } };
\end{tikzpicture}
1 You don’t have to use cartesian coordinates, and you can do ‘math’ on points. See the
manual for more detail.
3
TP
TP
Sub
T’
Sub T’
T VP
T
VP
V
V Obj
TP
Sub
T’
T
VP
Obj
V
Obj
Multiple dominance
To draw multiple dominance structures (which are in the normal case mostly
trees with just a few‘extra’ branches), I build on the basic tree syntax. One way
is to make a normal tree, and then to tell TikZ to draw a line from one node in
the tree to another. To do this, we need to name nodes. This is done by giving
an identifier in parentheses after the node command:
node (name) at (x,y) {text}
We can draw a line from one node (named n1 ) to another (named n2 ) with
(variants of) the command \draw:
\draw (n1) to[out=240,in=110] (n2);
The command to[out=x,in=y] makes the line leave the node n1 at angle x,
and arrive at node n2 at angle y.
Finally, to ‘leave space’ for a subtree that isn’t there, we can tell a child
subtree that it is missing:
child[missing] {}
This allows us to draw MDSs in an easy way.
\begin{tikzpicture}[
sibling distance=4em,
level distance=2em
]
\node (root) {TP}
child { node (sub) {Sub} }
child { node {T’}
child { node {T} }
child { node (vp) {VP}
child[missing]{} %the base position of the subject
child { node {V’}
4
child { node {V} }
child { node {Obj} } } } };
\draw (vp) to[out=240,in=110] (sub);
\end{tikzpicture}
TP
Sub
T’
T
VP
V’
Obj
V
We can make things look nicer (although it becomes more of a pain for us)
by telling TikZ exactly where we want the multiply dominated substructure to
be.
\begin{tikzpicture}[
sibling distance=4em,
level distance=2em
]
\node (root) at (0,0) {TP}
child[missing] {} %spec-TP
child { node {T’}
child { node {T} }
child { node (vp) {VP}
child[missing]{} %spec-VP
child { node {V’}
child { node {V} }
child { node {Obj} } } } };
% this is the guy who is dominated by spec-TP and -VP
\node (sub) at (-2,-2) {Sub};
\draw (vp) to[out=240,in=110] (sub); %the link from spec-VP to sub
\draw (root) to[out=240,in=110] (sub); %the link from spec-TP to sub
\end{tikzpicture}
TP
T’
T
VP
Sub
V’
V
5
Obj
Just for fun, we can put names on branches, explicitly indicating the dependencytype.
\begin{tikzpicture}[
sibling distance=4em,
level distance=2em,
bagup/.style={text centered,yshift=0.2cm},
bagdown/.style={text centered,yshift=-0.2cm}
]
\node (root) at (0,0) {TP}
child[missing] {} %this will be the subject’s case position
child { node {T’}
child { node {T} }
child { node (vp) {VP}
child[missing]{} %and this the subject’s theta position
child { node {V’}
child { node {V} }
child { node {Obj} } } } };
\node (sub) at (-2,-2) {Sub};
\draw (vp) to[out=240,in=110] node[bagdown,blue] {theta} (sub);
\draw (root) to[out=240,in=110] node[bagup,red] {case} (sub);
\end{tikzpicture}
TP
T’
case
T
Sub
VP
theta
V’
V
Obj
Syntactic features in LATEX
Here are some commands I use to render syntactic features and the like in LATEX.
The features relevant for merge (left selection (=x), right selection (x=), and
categorial features (x) I write like so:
\newcommand{\csel}[1]{\hbox{\tt=}{\tt#1}}
\newcommand{\ssel}[1]{{\tt#1}\hbox{\tt=}}
\newcommand{\cat}[1]{{\tt#1}}
The features relevant for move (attractor (+x) and attractee (-x)) I write
like so:
\newcommand{\mvr}[1]{\hbox{\tt+}{\tt#1}}
\newcommand{\mvee}[1]{\hbox{\tt-}{\tt#1}}
6
Finally, I write lexical items (pairs of lexemes and feature bundles) in the
following manner:
\newcommand{\lex}[2]{\ensuremath{\langle\textsf{#1},#2\rangle}}
The lexical entry for (say) will I would write like this (the \; commands are
spacing commands)
\lex{will}{\csel{v}\;\mvr{k}\;\cat{t}}
which displays like this: hwill, =v +k ti.
A common source of errors in my LATEX code comes from forgetting the
closing curly bracket (‘}’) in a \lex command (there should be two).
Because of the hboxes (I think), sizing does not work on features. If I need
to put them in footnotes, I end up defining new commands for smaller features:
\newcommand{\fcsel}[1]{\hbox{\tt\footnotesize =}{\tt#1}}
\newcommand{\fssel}[1]{{\tt\footnotesize #1}\hbox{\tt=}}
\newcommand{\fcat}[1]{{\tt#1}}
\newcommand{\fmvr}[1]{\hbox{\tt\footnotesize +}{\tt#1}}
\newcommand{\fmvee}[1]{\hbox{\tt\footnotesize -}{\tt#1}}
Compare:
\[\begin{array}{cc}
A_{\{\csel{x}\;\mvr{y}\}}
&
B_{\{\fcsel{x}\;\fmvr{y}\}}
\end{array}\]
A{=x +y}
B{=x +y}
7