diff options
author | Karl Berry <karl@freefriends.org> | 2006-07-12 22:36:03 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-07-12 22:36:03 +0000 |
commit | d80b07e0e893dbfd60b9066eb5301370e7dbef3c (patch) | |
tree | fc82339633b94a46e122394a35b5a36d65bbda34 | |
parent | 5d6e223c42e66a96895d050c5ba962ed60263dd6 (diff) |
new linguistics package qtree
git-svn-id: svn://tug.org/texlive/trunk@1828 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Build/tools/tpm-ctan-check | 1 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/qtree/README | 25 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/qtree/qarrows.pdf | bin | 0 -> 20181 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/qtree/qarrows.tex | 100 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/qtree/qtreenotes.pdf | bin | 0 -> 228412 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/qtree/qtreenotes.tex | 1073 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/qtree/qtree.sty | 1007 | ||||
-rw-r--r-- | Master/texmf-dist/tpm/qtree.tpm | 28 | ||||
-rw-r--r-- | Master/texmf/lists/qtree | 10 | ||||
-rw-r--r-- | Master/texmf/tpm/collection-latexextra.tpm | 1 |
10 files changed, 2245 insertions, 0 deletions
diff --git a/Build/tools/tpm-ctan-check b/Build/tools/tpm-ctan-check index 4c3431331a5..4a9a3c3b828 100755 --- a/Build/tools/tpm-ctan-check +++ b/Build/tools/tpm-ctan-check @@ -80,6 +80,7 @@ sub main "ppr-prv", "preview", "proof", "pstricks", "pstricks-add", "pst-3d", "pst-barcode", "pst-blur", "pst-eucl", "pst-func", "pst-labo", "pst-lens", "pst-osci", "pst-pdf", "pst-pdgr", "pst-slpe", + "qtree", "randbild", "robustcommand", "sciposter", "sectionbox", "sectsty", "semantic", "seminar", "semioneside", diff --git a/Master/texmf-dist/doc/latex/qtree/README b/Master/texmf-dist/doc/latex/qtree/README new file mode 100644 index 00000000000..98a8ebd4b30 --- /dev/null +++ b/Master/texmf-dist/doc/latex/qtree/README @@ -0,0 +1,25 @@ +This is the distribution directory for QTREE, a LaTeX package for +drawing syntax trees. Qtree allows trees to be specified in a simple +bracket notation, automatically calculates branch sizes, and supports +both DVI/PostScript and PDF output. + +This is Qtree version 3.1, 10 July 2006. Qtree is distributed +under the LaTeX Project Public License (LPPL). + + +*** Source files: + +qtree.sty The style file +qtreenotes.tex The documentation +qarrows.tex Additional info on drawing movement arrows + + +*** Formatted versions of the documentation: + +qtreenotes.pdf +qtreearrows.pdf + + +Alexis Dimitriadis (alexis@ling.upenn.edu) + + diff --git a/Master/texmf-dist/doc/latex/qtree/qarrows.pdf b/Master/texmf-dist/doc/latex/qtree/qarrows.pdf Binary files differnew file mode 100644 index 00000000000..fff9d5602e9 --- /dev/null +++ b/Master/texmf-dist/doc/latex/qtree/qarrows.pdf diff --git a/Master/texmf-dist/doc/latex/qtree/qarrows.tex b/Master/texmf-dist/doc/latex/qtree/qarrows.tex new file mode 100644 index 00000000000..9925cbbc1ae --- /dev/null +++ b/Master/texmf-dist/doc/latex/qtree/qarrows.tex @@ -0,0 +1,100 @@ +% You need the tree-dvips package to process this file. +% Alexis Dimitriadis (alexis@ling.upenn.edu) 10/10/99 + +\documentclass{article} + +\advance\textheight by 1in +\advance\textwidth by 0.5in +\topmargin=-0.3in + +\usepackage{tree-dvips} +\usepackage{qtree} + +% PostScript to PDF conversion using ghostscript (alias ps2pdf) +% looks better on-screen if one of the built-in PDF fonts is used: +\usepackage{times} + +\begin{document} +\centerline{\large\bf Examples: Drawing arrows on \emph{qtree} trees} +\medskip +The arrow-drawing capabilities of the package \emph{tree-dvips} (written by +Emma Pease) can be used with trees drawn with \emph{qtree}. The two packages +are fully compatible. + +Note, however, that tree-dvips relies on PostScript specials, and thus does not work with pdf\LaTeX. This file was generated as DVI and then converted to pdf. + +\emph{Tree-dvips} is not included in the distribution of \emph{qtree;} it is +available on CTAN. + +Thanks to Seth Kulick for telling me about the combination, and to Amanda +Seidl for contributing the verb-movement example. +\bigskip + +\hskip 1.5cm\Tree [ [ \node{subj1}subj_i ].NP [ [ + T+v_n+\node{V}V_j+Apl_k + ].T [ \node{io}{ }IO_l + [ \node{subj2}t_i [ \node{v1}t_n [ \node{do}DO_m [ \node{io1}t_l + [ \node{apl1}t_k [ [ \node{V1}t_j ].V + \node{do1}t_m ].VP ].Apl\1 + ].Apl\1 ].AplP ].{\it v}\1 ].{\it v}\1 ].{\it v}P ].T\1 ].TP + + \anodecurve[bl]{subj2}[bl]{subj1}{0.4in}% + \anodecurve[bl]{do1}[bl]{do}{0.4in}% + {\makedash{4pt}\anodecurve[t]{io1}[r]{io}{.5in}}% + \anodecurve[bl]{V1}[bl]{apl1}{0.6in}% + \anodecurve[bl]{apl1}[bl]{v1}{1in}% + \anodecurve[bl]{v1}[bl]{V}{0.9in}% + +% These would give square movement arrows instead: +% +% \abarnodeconnect[-6pt]{subj2}{subj1}{0.4in} +% \abarnodeconnect[-6pt]{do1}{do}{0.4in} +% {\makedash{4pt}{\anodecurve[t]{io1}[r]{io}{.5in}}} +% \abarnodeconnect[-6pt]{V1}{apl1}{0.6in} +% \abarnodeconnect[-6pt]{apl1}{v1}{1in} +% \abarnodeconnect[-6pt]{v1}{V}{0.9in} + +\vspace*{-0.95in} +\noindent +{\small\begin{verbatim} +\Tree +[ [ \node{subj1}subj_i ].NP + [ [ T+v_n+\node{V}V_j+Apl_k ].T + [ \node{io}{ }IO_l + [ \node{subj2}t_i [ \node{v1}t_n + [ \node{do}DO_m [ \node{io1}t_l + [ \node{apl1}t_k [ [ \node{V1}t_j ].V + \node{do1}t_m ].VP ].Apl\1 + ].Apl\1 ].AplP ].{\it v}\1 ].{\it v}\1 + ].{\it v}P ].T\1 ].TP + +\anodecurve[bl]{subj2}[bl]{subj1}{0.4in} +\anodecurve[bl]{do1}[bl]{do}{0.4in} +{\makedash{4pt}\anodecurve[t]{io1}[r]{io}{.5in}} +\anodecurve[bl]{V1}[bl]{apl1}{0.6in} +\anodecurve[bl]{apl1}[bl]{v1}{1in} +\anodecurve[bl]{v1}[bl]{V}{0.9in} +\end{verbatim}} + +% A little bug: Because of how TeX assigns type categories to its input, the +% automatic math-mode switching of label subscripts does not work inside +% footnotes or boxes. To work around this, invoke \verb|\automath| +% \emph{before} entering in the box or footnote. (This will enable +% auto-switching to math mode anywhere in the text). +\automath + +\noindent\hskip-0.3cm +\parbox{1.2in}{% +\Tree [.S [.NP \node{subj}{subj_i} ] + [.VP [.V verb ] [.NP \node{t}{t_i} ]]] \bigskip} +\abarnodeconnect[-6pt]{t}{subj} +% Another problem: \verbatim cannot be used inside anything boxes or +% footnotes (for the same reason). Use this substitute. +{\obeyspaces\obeylines% +\parbox{3.9in}{\tt\chardef\\=`\\% % Let \\ be \backslash +\\Tree [.S [.NP \\node\{subj\}\{subj\_i\} ] +\ [.VP [.V verb ] [.NP \\node\{t\}\{t\_i\} ]]] +~ +\\abarnodeconnect[-6pt]\{t\}\{subj\}}} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/qtree/qtreenotes.pdf b/Master/texmf-dist/doc/latex/qtree/qtreenotes.pdf Binary files differnew file mode 100644 index 00000000000..f5e3c7349c7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/qtree/qtreenotes.pdf diff --git a/Master/texmf-dist/doc/latex/qtree/qtreenotes.tex b/Master/texmf-dist/doc/latex/qtree/qtreenotes.tex new file mode 100644 index 00000000000..dcd0f6de4f1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/qtree/qtreenotes.tex @@ -0,0 +1,1073 @@ +% Demo and documentation for qtree.sty, the front end to the +% Qobitree tree-drawing package + +% (LaTeX) + +\documentclass[11pt,a4paper]{ltxdoc} + +% You can safely comment this out if you don't have hyperref +\usepackage[bookmarks]{hyperref} + +% We stick with the text width set by ltxdoc.cls + +% Fairly-balanced A4 margins: +\topmargin=-0.25in +\textheight=9in + +\parskip=4pt +\parindent=0pt +\raggedbottom + +\DeleteShortVerb{\|} +\AtBeginDocument{\OnlyDescription} % There's no code, anyway + +% Like \DescribeMacro, but arbitrary text +\def\marginpost#1{\leavevmode \marginpar{~\hfill\texttt{#1}}\ignorespaces} + +% The name of the package, capitalized or not. +\def\QT{\textsf{\emph{Qtree}}} +\def\Qt{\textsf{\emph{qtree}}} + +\def\pstyle#1{\textsf{#1}} % style filenames + +\def\argplain#1{\textit{$\langle$#1$\rangle$}} % Like \marg, but without { } + + +\usepackage{qtree} + +% Break page unless requested amount of space remains +% Must be used BETWEEN paragraphs +% +\makeatletter +\def\vneed#1{\par \penalty-100 \begingroup % preserve \dimen@, \dimen@i + \ifdim\prevdepth>\maxdepth \dimen@i\maxdepth \else \dimen@i\prevdepth\fi + \kern-\dimen@i + \dimen@\pagegoal \advance\dimen@-\pagetotal % space left + \ifdim #1>\dimen@ \vfil \eject \fi + \kern\dimen@i + \endgroup} +\makeatother + + +\begin{document} + +\begin{center} +\Large {\bf Qtree, a \LaTeX\ tree-drawing package}\footnote{ +Thanks to Jeff Siskind for permission to distribute the QobiTree code. +Please direct comments to Alexis Dimitriadis +(\emph{alexis@ling.upenn.edu}).} +\large +\\[8pt] Jeffrey Mark Siskind (tree drawing and core package)\\[4pt] + Alexis Dimitriadis (parser and extensions) \\[8pt] +Version \qTreeVersion, 10 July 2006 + \\[8pt] \Large % For the paragraph spacing +\end{center} + +\section{Overview} + +The \QT\ package consists of QobiTree, a package of tree-drawing +macros written by Jeff Siskind, and a front end that allows trees to be +specified in bracket notation, using whitespace to separate tokens. Tree +nodes can have labels of any size or complexity, and are automatically +arranged on the page, usually with quite good results. Provisions exist for +fine-tuning the default layout. The front end also centers trees (by default) +and provides some other nice features. + +A simple tree may look like this, +\begin{verbatim} +\Tree [.S This [.VP [.V is ] \qroof{a simple tree}.NP ] ] +\end{verbatim} +which produces: +\par +\Tree [.S This [.VP [.V is ] \qroof{a simple tree}.NP ] ] +\bigskip + +The node labels in trees may be quite complicated; they may contain font +changes and math-mode text, line breaks introduced with \verb|\\| (which +produce centered lines), etc. The trees produced are constrained to a +maximum depth of 20 levels, with a maximum of five branches at any one node. +\QT\ automatically adjusts for the +width and height of tree labels, and is pretty good at arranging nodes on +the page. + +Trees are defined using a version of the bracket notation familiar to +linguists. Tree elements are delimited by white space; braces can be +used to enclose multi-word labels. \QT\ does not rely on +\verb|\catcode| changes for its operation, allowing trees to be +included in footnotes and other moving environments without problems. (But +see the discussion of \verb|\automath| below). + +Thanks to recent improvements in \LaTeX's support for PDF, \Qt\ can now +produce good-looking graphics for both DVI/PostScript and PDF output. By default, \Qt\ will load the package \pstyle{pict2e.sty}, which improves the native picture-drawing facilities of \LaTeX\ and transparently supports both +PostScript and PDF output.\footnote{% +Earlier versions of \Qt\ loaded \pstyle{eepic.sty}, which does not work with PDF. You can still use \Qt\ with \pstyle{eepic} if you wish; see section \ref{s:options}. +} +This version of Qtree also provides hooks for customization, and +contains many small enhancements and corrections of minor glitches. + +Many of the new features were inspired by questions or requests from \Qt\ +users. Thank you all for your contributions to \Qt, and keep them coming! + + +\subsection{New features} + +\begin{enumerate} + \item Full PDF and PostScript support using + \pstyle{pict2e.sty}. This package, which extends the limited capabilities + of the standard \verb|picture| environment, was planned long ago by the + \LaTeX\ developers but has only recently been released. It provides + enhanced drawing quality for both DVI and PDF output. + +\item Customization hooks allow easy adjustments to the default style of + leaf and branch labels, and to a number of other aspects of tree + appearance. + +\item Extraneous whitespace around trees has been removed. + +\item Reorganized and rewritten code is easier to customize (with a moderate + amount of \LaTeX\ hacking skills). + +\item The documentation has been extended and reorganized. An FAQ section + has been added with explanations of various frequently requested + tasks. + +\item Several functions have been added, including a ``balancing'' command + that will produce trees with more evenly sized branches. + +\item \QT\ is now (finally) available on CTAN. + +\end{enumerate} + + +\subsection{Home page} + +The \Qt\ home page is at: + +\begin{center} +http://www.ling.upenn.edu/advice/latex/qtree/. +\end{center} + + + + + +\newpage +\tableofcontents +\newpage + +\section{Invocation} + +\pstyle{Qtree.sty} is a \LaTeX\ package. It should be installed in a +directory of style files, and included with the \LaTeXe\ command +\verb|\usepackage{qtree}|. + +\subsection{Package options} +\label{s:options} + +\DescribeMacro{[center]} Horizontally center trees on the line. This is the +default behavior. (See also the commands \verb|\qtreecentertrue| and +\verb|\qtreecenterfalse|, below). %in section \ref{s:params}). + +\DescribeMacro{[nocenter]} Do not center trees. Trees are positioned on the +page like ordinary text, and can be manually aligned to the left or right +(or centered). + +\DescribeMacro{[noload]} Suppress automatic loading of the graphics +extensions library \pstyle{pict2e.sty}. \pstyle{Pict2e} supports both +PostScript and PDF graphics, but automatic loading can be inhibited if it +causes problems, or if you want to pass your own options to \pstyle{pict2e}. + +Earlier versions of \Qt\ used \pstyle{eepic.sty} as the graphics enhancement library; if you want to use it instead of \pstyle{pict2e}, invoke \Qt\ with the package option \texttt{[noload]} and load \pstyle{eepic.sty} manually (using \verb|\usepackage{eepic}|). + + +\subsection{Customization parameters} +\label{s:params} + +\DescribeMacro{\qtreecentertrue} +\DescribeMacro{\qtreecenterfalse} +Trees are horizontally centered on the line by default, but you can turn +centering on and off at any point with these commands. They obey the usual +scoping rules; if used inside an \verb|enumerate| environment, for example, +their effect will only last until the end of that environment. (See also the +\texttt{[(no)center]} package options). + +\paragraph{Length parameters} +The following macros can be redefined to customize various aspects of tree +construction. (Note that they are all \emph{macros,} not counters). + +\DescribeMacro{\qtreepadding} The amount of whitespace inserted around +labels and leaf nodes as the tree is built. The default is the value of the +\LaTeX\ parameter \cmd{\tabcolsep} (usually set to \texttt{6pt}). It is safe +to change the value of this macro for different trees, but modifying it in +the middle of a tree could lead to somewhat strange behaviour. + +\DescribeMacro{\qroofpadding} +The amount of whitespace inserted around text placed under a +roof; that is, the width of the ``eaves'' of the roof that extend beyond the +text. The default is \texttt{0.4em.} + +\DescribeMacro{\qtreeunaryht} +The height of the line connecting the labels of non-branching +nodes to their leaves. The default is \texttt{2ex}. + +\paragraph{Customization hooks} +The following macros are empty by default, but they can be defined to +customize the appearance of labels and leaves. They can safely change font +styles etc., since they are invoked inside another environment. + +\DescribeMacro{\qtreeinithook} Called at the beginning +of each tree, before processing begins. It can be used for definitions or +modifications of commands that should only be in effect during tree +construction. (For example, to use the \verb|\small| font size for all trees). + +\DescribeMacro{\qtreefinalhook} Called after the completed tree has been +printed out; it might be used, for example, to end an environment opened +with \verb|\qtreeinithook|. + +\DescribeMacro{\qleafhook} +\DescribeMacro{\qlabelhook} +\verb|\qleafhook| is called for each leaf node, and \verb|\qlabelhook| for +each non-terminal label. +They can be used to define default fonts, etc., for +text in these places. Their use is explained in section \ref{s:ftune}. + +\vneed{2in} +\section{Basic usage} + +\subsection{Tree syntax} + +\DescribeMacro{\Tree} +The front end of \Qt\ reads a tree description +written in the familiar (to linguists) bracket notation. Tree labels are +delimited by whitespace. To make a multi-word node label, enclose it in +braces. Note also that +\TeX\ discards the spaces immediately after {\it control +sequences\/} (commands whose name consists of a backslash followed by +letters); hence if a node label ends with a control sequence, like +\verb|\ldots| in the following example, you need to enclose it in braces +too. + +\Tree [.CP [.{\sc Spec}(CP) {which car} ] {\ldots} ] +\begin{verbatim} +\Tree [.CP [.{\sc Spec}(CP) {which car} ] {\ldots} ] +\end{verbatim} + +\subsection{Label matching} +For convenience, a label for a non-terminal node can be written either after +the left bracket or after the right bracket corresponding to that node. Thus +the following are equivalent: +\begin{verbatim} +\Tree [.S when [.NP the cat ] sleeps ] +\Tree [.S when [ the cat ].NP sleeps ] +\end{verbatim} +To help keep braces matched when editing large trees, the front end allows +the option of writing a label after both the left and the right bracket of +the same node, as shown for the node NP below. In this case the two labels +provided must be identical, token for token. +\begin{verbatim} +\Tree [.S when [.NP the cat ].NP sleeps ] +\end{verbatim} + +\vneed{3cm} +\subsection{Branching without labels} + +Sometimes we want to draw an abbreviated tree without a label on some or all +intermediate nodes. \QT\ will handle such trees correctly: + +% \medskip +% \Tree [ [.np Eve ] [ [.(np$\backslash$s)/np ate ] [ [.np/n the ] [.n apple ] +% ]]] + +\medskip +\Tree [.CP Spec(CP) [ C^0 [.IP I^0 Comp(IP) ] ] ] +\begin{verbatim} +\Tree [.CP Spec(CP) [ C^0 [.IP I^0 Comp(IP) ] ] ] +\end{verbatim} + +\subsection{Roofs} +\DescribeMacro{\qroof} +\DescribeMacro{\qroofx} +\DescribeMacro{\qroofy} +The command \verb|\qroof| draws a triangular ``roof'' above a phrase that is +treated as a unit. It can appear anywhere a {\it leaf\/} can appear. The slope +of the roof is equal to the ratio \verb|\qroofy / \qroofx| (these counters may +be reset to any pair of integers between zero and six; the default is 1/3). + +To create a roof +labeled {\it NP\/} over the phrase {\it the book,} write +\begin{flushleft} +\begin{verbatim} + \qroof{the book}.NP +\end{verbatim} + +\vspace{-0.75cm} +\hfil\hfil \leaf{\qroof{the book}.NP } \qobitree +\end{flushleft} + + +If the phrase contains line breaks introduced with \verb|\\|, the resulting +lines are flush left, not centered. Again, it is possible for the ``phrase'' +to be a construction of arbitrary complexity; but the syntax of +\verb|\qroof| does not allow further branches of the tree to appear under +the roof, since a roof is meant to cover material that is not +analyzed.\footnote{% + \QT\ internally implements a roof as a large leaf. +} % END FOOTNOTE +An example is given on page \pageref{roof}. + +% Although the parsing messes up, it IS possible to work qroof into a +% non-terminal label: +% \Tree [.A this [.{\qroof{Cheat}.ME } x [ below ] ]] + + +\subsection{Subscripts, superscripts and primes} +\label{s:super} + +\QT\ defines the following formatting commands in such a way that they are +only in effect during tree construction. They have their regular meaning (or +none) in the rest of the document. + +\DescribeMacro{\automath} +\DescribeMacro{\noautomath} +Trees are constructed in a special environment in which things like +\verb|NP_i|, \verb|N^0|, automatically format their subscripts or +superscripts in math mode, giving NP$_i$ and N$^0$, respectively. The +command that arranges this is called \verb|\automath|, and can also be enabled outside the tree environment, if desired. (It is turned off with +\verb|\noautomath|). + +Because this feature relies on +\verb|\catcode| changes for its operation, \cmd{\automath} has no +effect when called inside footnotes or floats; in such trees, all sub- or +superscripts should be explicitly placed in math mode, as you would ordinarily do. Alternately, you can turn on \cmd{\automath} before entering the footnote or float. + + +\vneed{1in} +\marginpost{\cmd{\0},\cmd{\1},\cmd{\2}} +{\makeatletter \qtreeprimes@internal +As a further convenience, constructions like \verb|X$'$|, producing X\1, can +be abbreviated \verb|X\1|. (If you simply type \verb|X'| you get X', with an +apostrophe rather than a prime). There is also \verb|X\2|, producing X\2, and +\verb|X\0|, producing X\0. These commands also arrange for subtle +improvements in the centering of labels that use them, by using \cmd{\rlap} +to set the superscript.} + +\DescribeMacro{\qtreeprimes} +\qtreeprimes +If you want to use commands like \cmd{\1} in your text (outside of trees), +you can cause all three to be defined by putting the command +\cmd{\qtreeprimes} in your preamble. The version defined in this way does +not use \cmd{\rlap} around the superscripts, since this is inappropriate for +running text. Thus you get X\1, X\2, and X\0. (Notice the position of the +punctuation compared to the previous paragraph). The versions that use +\cmd{\rlap} will still be used inside trees. + +\bigskip +\vneed{2in} +Here is an example using some of these features: + +\label{roof} +\Tree +[.IP [ Roses ].NP_i [.I\1 [ are ].I\0 + [.VP t_i [ [ going ].V\0 \qroof{out of style}.PP ].V\1 ].VP +].I\1 ] +\begin{verbatim} +\Tree +[.IP [ Roses ].NP_i [.I\1 [ are ].I\0 + [.VP t_i [ [ going ].V\0 \qroof{out of style}.PP ].V\1 ].VP +].I\1 ] +\end{verbatim} +Granted, by the time the examples get this big, the bracketed format isn't +all that readable; but it's certainly no worse than any other tree format, +and you can add white space to make it a little better. + +\subsection{Customizing text appearance} +\label{s:ftune} + +\DescribeMacro{\qleafhook} +\DescribeMacro{\qlabelhook} +The macros \cmd{\qleafhook} and \cmd{\qlabelhook} don't do anything by default, +but they can be defined to control the appearance of the text in +leaves and in branch labels, respectively. The macros can be defined +either with or without an argument; the following examples illustrate both options. +\begin{verbatim} + \newcommand{\qlabelhook}{\bf} + \newcommand{\qleafhook}[1]{\emph{#1}} + \newcommand{\qlabelhook}{\framebox} +\end{verbatim} + +\paragraph{Details:} For some effects it is important to know that + the argument of +the hook is not just the text of the leaf or label, but a small +\texttt{tabular} environment (which inserts whitespace controlled by +\cmd{\qtreepadding}). In simplified form, the code that uses the hooks looks +like this (where \verb|#1| is the text of the branch label). + +\begin{verbatim} + ... \qlabelhook {\begin{tabular}[t]{c} #1 \end{tabular}} +\end{verbatim} + +This arrangement makes it possible for leaves and labels to contain line +breaks (\verb|\\|). But one consequence is that the hooks cannot +put their argument in math mode, since a table cannot appear inside math +mode. Fortunately, there is a simple work-around: We get the same effect by +making +\Qt\ use the \verb|array| environment in place of \verb|tabular|.\footnote{% + This works because \texttt{tabular} and \texttt{array} are internally + implemented identically, except for switching on math mode in \texttt{array}. +} % END FOOTNOTE + To put only +branch labels (not leaves) in math mode, define the following hook: +\begin{verbatim} +\def\qlabelhook{\let\tabular=\array \let\endtabular=\endarray} +\end{verbatim} + + + +\subsection{Escaping the parser} + +\marginpost{!-escapes} +For fine control of the tree-building process, we must sneak certain +directives past the front end. If a +word begins with an exclamation mark, the entire word (i.e., up to the next +space) will be passed through unchanged, except for stripping off the ``!''. +Braces can be used to pass through larger groups. This is most often used +for the manual width-adjustment commands +\verb|\faketreewidth| and \verb|\qsetw| (see below), but can also be +used to override various \Qt\ settings for part of the tree. Note that +\verb|\qroof| is part of the tree syntax, and should {\it not\/} be +preceded by an exclamation mark. + +\subsection{Adjusting inter-node spacing} + +\DescribeMacro{\qsetw} +The command \cmd{\qsetw}\marg{length} (where \argplain{length} might be +\verb|0.5in|, \verb|36pt|, etc.) tells \Qt\ to override its default +calculation of the width of the {\it just-finished\/} node (that's the leaf +or branch ending just to the {\it left\/} of where the directive was +issued), and instead consider that width to be \argplain{length}. + +\DescribeMacro{\faketreewidth} +Similarly, +\cmd{\faketreewidth}\marg{text} sets the width of the last node to be +equal to +the width of \argplain{text} (which again can contain `\verb|\\|' commands +etc.) \argplain{text} is not actually typeset but is used just to compute the +fake width of the most recently completed leaf or subtree. + +% For example, the default placement rules produce the tree labeled (2b) above. +% By setting the width of the subtree headed by T to 1cm, we get the following: +% +% b. \Tree[ A [.T {B\\ \em note} cc ].T !\qsetw{1cm} D ].S + +For example, the default placement rules would +produce tree (a) below. By setting the width of the subtree headed by B to +\texttt{1cm}, we get tree (b). + +\begin{center} +\qtreecenterfalse +\leavevmode\llap{a. }\Tree [.A [ a b c d ].B C ] +\hfil +\llap{b. }\Tree [.A [ a b c d ].B !\qsetw{1cm} C ] + +\end{center} +\begin{verbatim} +\Tree [.A [ a b c d ].B !\qsetw{1cm} C ] +\end{verbatim} +When you use \verb|\qsetw| or \verb|\faketreewidth| you are on your own. They +can either shrink or enlarge the space taken by the node and may result in +trees with overlapping labels. + + +\subsection{``Balanced'' trees} + +\DescribeMacro{\qbalance} +Regular binary-branching trees often end up +with smaller and smaller branches as you descend into the tree; you can see +an example below. If you don't like this look, you can get +``balanced'' trees by adjusting the width of the last leaf node. For a +balanced tree, this should be exactly \emph{three} times as wide as the leaves on +its left;\footnote{% + The geometrical justification for this is left as an exercise to the reader. +} % END FOOTNOTE +For binary-branching trees, the command \verb|\qbalance| can be used. It sets the width of the node just before it to be three times +the width of the \emph{previous} node. If it does not do what you need, +you'll need to set the correct width manually. In the example below, the +width of the leaf \emph{``last''} is set to be three times the width of +\emph{leaf$_3$.} + +\begin{center}\small +\qtreecenterfalse +a. \Tree [.X leaf_1 [.Y leaf_2 [.Z leaf_3 last ] ] ] +\hfil +b. \Tree [.X leaf_1 [.Y leaf_2 [.Z leaf_3 last !{\qbalance} ] ] ] +\end{center} +\begin{verbatim} +\Tree [.X leaf_1 [.Y leaf_2 [.Z leaf_3 last !{\qbalance} ] ] ] +\end{verbatim} + + + + + +\vneed{1.5in} +\section{Using qtree} +\subsection{How to convert a tree to brackets} + +Reading or writing a complex tree in bracket notation is not terribly easy for +humans; it helps to have an editor that can show matching braces as they are +typed in. The procedure described here should allow you to easily convert a +tree to bracket notation. If you don't have any difficulty with this, just +skip this section and do it any way you want! + +\begin{enumerate} +\item Draw the tree you want to enter on a piece of paper, so you can look at +it. + +\item Imagine that the tree is a large peninsula, and your pencil is a boat +sailing around it. Starting just to the left of the root node, move +downwards, following the outline of the tree until you come back to the root +node (on the right side, having moved counterclockwise around the tree), +without crossing any of the tree's lines. + +\item \begin{enumerate} +\item +Every time you are at the left side of a non-terminal node, type a left +bracket, and the label for that node. +\item Every time you are +at a leaf node, type in the contents of that node. +\item +Finally, every time you are on the right of a non-terminal node, type a right +bracket (and the node name again, if you want to help keep them straight). +\end{enumerate} + +\end{enumerate} + +To see this in practice, consider the following tree; in the variant on the +right, the numbered subscripts show the order in which the brackets and +labels are written. + +\bigskip +\Tree [.A [.B [.C one ] [.D two ] ].B [.E three ] ].A +% +\Tree [.{[_1 A ]_{13}} + [.{[_2 B ]_9} [.{[_3 C ]_5} one_4 ] [.{[_6 D ]_8} two_7 ] ] + [.{[_{10} E ]_{12}} three_{11} ] ] +\par +\medskip +Accordingly, we would generate the tree by typing the following: + +{\center +\verb|\Tree [.A [.B [.C one ] [.D two ] ].B [.E three ] ].A| \par} + + +\subsection{Placing trees on the page} + +\paragraph*{Numbered examples etc.} +A tree generated with \Qt\ can be placed in a numbered example environment, +in footnotes or \verb|\parbox|es, inside math formulas, tables, pictures, +etc. The tree nodes can themselves contain arbitrarily complex +material---although, unfortunately, it is not possible to embed a recursive +call to \Qt. If you need to do this, save the intermediate tree +in a \verb|\box|. An example is shown in section \ref{s:embed}. + +Trees are centered horizontally on the line by default, but this feature can +be turned off with \verb|\qtreecenterfalse| (see section \ref{s:params}). +If you are not satisfied with the horizontal placement of the +tree, you can adjust it by judicial use of \verb|\hskip|.\footnote{% + Earlier versions of \Qt\ inserted stray spaces in front of trees, + requiring frequent use of \texttt{\bslash hskip}. This problem has now been + fixed. +} % END FOOTNOTE + +\QT\ attempts to align the topmost label of the tree with the baseline of +the text, similarly to the effect of the [t] option for \verb|\parbox| +alignment. To center trees vertically on the baseline, enclose the entire +tree in a \texttt{tabular} environment. +%% \footnote{% +%% You may also want to suppress the padding that \texttt{tabular} normally +%% inserts, as follows: + +%% \centerline{...} (Covered in the FAQ section) +%% } % END FOOTNOTE + +% Here is an example +% using the {\tt enumerate} environment, and the code to generate it. + +% \begin{enumerate} \item[(1)] a. \hskip-0.75in +% \Tree[.C [.Tns [.Neg [.Ind V [.Ind Ind Agr$_1$ ]] Neg ].Neg +% [.Tns Agr$_2$ Tns ] ].Tns [.C C Agr$_3$ ] ] +% \end{enumerate} +% \begin{verbatim} +% \begin{enumerate} \item[(1)] a. \hskip-0.75in +% \Tree[.C [.Tns [.Neg [.Ind V [.Ind Ind Agr_1 ]] Neg ].Neg +% [.Tns Agr_2 Tns ] ].Tns [.C C Agr_3 ] ] +% \end{enumerate} +% \end{verbatim} + + +\paragraph*{Side by side trees} +Multiple trees, or text and trees, can be arranged side by side. This can +generally be done by just arranging commands one after another; it usually +helps to turn off tree centering. If necessary the positioning can be +adjusted with \verb|\hskip|. +\begin{enumerate} +\qtreecenterfalse +\item[(2)] a. \Tree [.S [.NP \'el\\he ] + [.VP [.V hizo\\made ] [.V decir\\say ] + [.NP lo\\it ] [.NP a-mi\\me ] ].VP ] + \hskip 0.3in + b. \Tree[ A [.T {B\\ \em note} cc ].T D ].S +\end{enumerate} +\label{2b} +\begin{verbatim} +\begin{enumerate} +\qtreecenterfalse +\item[(2)] a. \Tree [.S [.NP \'el\\he ] + [.VP [.V hizo\\made ] [.V decir\\say ] + [.NP lo\\it ] [.NP a-mi\\me ] ].VP ] + \hskip 0.3in + b. \Tree[ A [.T {B\\ \em note} cc ].T D ].S +\end{enumerate} +\end{verbatim} + + + +% \paragraph*{\it Trivia note:\/} +% If you insist on placing trees in a \verb|\parbox|, here is how to do it. +% Note the \verb|~|, called a {\it tie,\/} before \verb|\Tree| inside the +% parbox; it keeps \LaTeX\ from breaking the line and placing the tree one +% line too low. +% \begin{enumerate} +% \item \parbox[t]{2.4in}{ (a)~\Tree +% [.VP [.NP (mud) ] [.V\1 [.V (get) ] [.PP {(on wall)} ]]] } +% % +% \parbox[t]{2in}{ (b)~\Tree +% [.VP [.NP (screen) ] \qroof{V\qquad AP\\ \hfil(clear)~}.V\1 ] } +% \end{enumerate} + +% \begin{verbatim} +% \begin{enumerate} +% \item \parbox[t]{2.4in}{ (a)~\Tree +% [.VP [.NP (mud) ] [.V\1 [.V (get) ] [.PP {(on wall)} ]]] } +% \parbox[t]{2in}{ (b)~\Tree +% [.VP [.NP (screen) ] \qroof{V\qquad AP\\ \hfil(clear)~}.V\1 ] } +% \end{enumerate} +% \end{verbatim} + +\section{Advanced features} + + + +\subsection{Putting a frame around part of a tree} + +\DescribeMacro{\qframesubtree} +The command \verb|\qframesubtree| will put a rectangular box +(``frame'') around part of a tree. It should be placed just \emph{after} the +closing bracket of the subtree that should be boxed. + +\Tree [.IP [.NP Roses ] [ [.I^0 are ] + [.VP t [ [.V^0 turning ] [.NP pink ] ] ].VP !{\qframesubtree} ]] +\begin{verbatim} +\Tree [.IP [.NP Roses ] [ [.I^0 are ] + [.VP t [ [.V^0 turning ] [.NP pink ] ] ].VP !{\qframesubtree} ]] +\end{verbatim} + +Only complete subtrees can be framed with this method. To enclose a single +label node in a box, use a frame command directly. To box all +labels or leaves, you can use the format customization hooks. For example, +the following will put a box around every label: +\begin{verbatim} + \renewcommand{\qlabelhook}[1]{\framebox{#1}} +\end{verbatim} + +\subsection{Embedding one tree in another} +\label{s:embed} + +The internal implementation of \Qt\ only supports one tree being built at +one time; hence it does not allow a complete tree to be recursively embedded +as part of another one. This is not actually needed very often (trees are +already recursive, after all); for most constructions that seem to require +it, there's a simpler way to get the same effect. But it might be +necessary, for example, if you need to put a subtree under a roof. + +Fortunately it's straightforward to embed one tree in another using \TeX's +facilities, without ever calling \Qt\ recursively. We can do this by saving +the first tree in a named box, and then using it as part of the larger tree. +Here's how: + +\vneed{6cm} +\begin{flushleft} +\footnotesize +\begin{verbatim} +\newsavebox{\partbox} % Declare this only once, in your preamble! + +%% Build the subtree and save it in the box +\setbox\partbox=\hbox{\Tree [.DP my pony ] } + +%% Use the subtree in the containing tree +\Tree [ how + \qroof{about \usebox{\partbox} ...}.PP +].S +\end{verbatim} + +\vspace{-3.1cm} +\newsavebox{\partbox} % Declare this only once, in your preamble! + +%% Build the subtree and save it in the box +\setbox\partbox=\hbox{\Tree [.DP my pony ] } + +\hfill +%% Use the subtree in the containing tree +\Tree [ how + \qroof{about \usebox{\partbox} ...}.PP +].S +\end{flushleft} + + +\subsection{Overriding branch drawing} +\label{s:bdraw} + +\QT\ is designed to produce nice trees automatically; it is not designed for +fine control over their appearance. Nevertheless, technically inclined users +could use the \verb|!| escape mechanism to temporarily redefine the +branch-drawing routine and draw the branches any way they want, specifying +wavy or dotted lines between selected nodes, arrows at line tips, etc. + +\DescribeMacro{\qdraw@branches} +The code that draws the lines from a tree node to its daughters +is encapsulated in the macro \cmd{\qdraw@branches}. +It takes one argument, the number of branches, and +uses graphics commands to draw a picture containing the branched +lines. The default drawing is very simple; the actual width of the picture +is controlled through the value of the +parameter \cmd{\unitlength} (see the documentation of the standard \LaTeX\ +environment \verb|{picture}|), which will be set to \emph{half} the +required distance between the branch tips before \cmd{\qdraw@branches} is +called. + +In the following simple example we override the macro (and later restore it), +to shorten the line that connects ``b'' to its parent and add an arrow at its +end (with \verb|\vector|). Since the custom macro will only be used once, it supports ternary +branching only and ignores its argument. +\begin{flushleft} +\makeatletter + \newcommand{\myLines}[1]{% Three-way only + \begin{picture}(4,1) + \put(0,0){\line(2,1){2}} + \put(2,0){\vector(0,1){0.7}} + \put(4,0){\line(-2,1){2}} + \end{picture}} + \let\qdrawReal=\qdraw@branches + \newcommand\brOverride{\let\qdraw@branches=\myLines} + \newcommand\brRestore{\let\qdraw@branches=\qdrawReal} +\small + +\hfill \Tree [.Top X [.Hub a b [.c left right ] + !{\brOverride} ].Hub !{\brRestore} ].Top + +\vspace{-3.8cm} +\begin{verbatim} +\makeatletter + \newcommand{\myLines}[1]{% Three-way only + \begin{picture}(4,1) + \put(0,0){\line(2,1){2}} + \put(2,0){\vector(0,1){0.7}} + \put(4,0){\line(-2,1){2}} + \end{picture}} +\let\qdrawReal=\qdraw@branches +\newcommand\brOverride{\let\qdraw@branches=\myLines} +\newcommand\brRestore{\let\qdraw@branches=\qdrawReal} +\makeatother + +\Tree [.Top X [.Hub a b [.c left right ] + !{\brOverride} ].Hub !{\brRestore} ].Top +\end{verbatim} +\end{flushleft} + +The branch-drawing code above is a simple modification of the commands +found in the style file, but it could be replaced with commands using a +drawing environment of your choice, and inserting arbitrary graphic elements. +Note, however, that the horizontal placement of child nodes on the page is +not affected by what the drawing routine does; drawing wider or narrower +branch lines will not cause the text to move with them. + + +\subsection{Visualising tree construction} + +If you're curious about how \Qt\ assembles leaves and labels into a tree, +you can try the command \verb|\qtreeshowframes|. It causes trees to +be drawn with boxes around their leaf nodes and labels; in the example +below we also add a frame around the entire tree, to show \TeX's idea of its +bounding box: + +\bigskip +\vneed{4cm} +\begin{flushleft} +\small +\begin{verbatim} +{ \qtreeshowframes + \frame{\Tree [.S This + [.VP [.V is ] + [.NP [.D a ] [ simple tree ] ] + ]] }} +\end{verbatim} + +\vspace{-2.5cm} +\leavevmode\hfill { \qtreeshowframes + \frame{\Tree [.S This + [.VP [.V is ] + [.NP [.D a ] [ simple tree ] ] + ]] }} +\hspace{\tabcolsep}\strut +\end{flushleft} + + +\subsection{The low-level interface} +The guts of \Qt\ are the tree macros written by Jeff Siskind, named +\emph{QobiTree.} Using the original interface (which is still accessible +with this package) the example tree shown on page \pageref{2b} would be +written like this: + +\begin{center} +\leaf{A} + \leaf{B\\ \em note} \leaf{cc} + \branch{2}{T} +\leaf{D} +\branch{3}{S} +\hskip 3in \qobitree +\end{center} +\vspace*{-1.5in} +\begin{verbatim} +\begin{center} +\leaf{A} + \leaf{B\\ \em note} \leaf{cc} + \branch{2}{T} +\leaf{D} +\branch{3}{S} +\qobitree +\end{center} +\end{verbatim} + +These macros operate like a stack machine. You push \TeX\ boxes onto the +stack of tree nodes, then you pop them off to make branching nodes which +get pushed back on the stack. The \Qt\ front end internally generates these +commands to build trees. + +The command\verb|\branch| requires you to specify the number of stack elements that will be made into children of the new node. The front end uses an internal counter, \verb|\nbranches|, to keep track of how many children a node has. + +It is possible, and in some cases even useful, to write your own commands that +add bits of tree structure to the qtree stack. The command \verb|\mylex| in the following example formats a singleton branch label in bold above lexical items (in italics), while leaving other branch labels in the default roman font. + +{\small +\begin{verbatim} +\newcommand\mylex[2]{\advance\nbranches by1 + \leaf{\emph{#2}}\branch{1}{\bf #1}} + +\Tree [.S !\mylex{N}{John} + [.VP !\mylex{V}{saw} !\mylex{N}{Jane} ]] +\end{verbatim}} +\vspace*{-2.7cm}\hfill +\newcommand\mylex[2]{\advance\nbranches by1 \leaf{\emph{#2}}\branch{1}{\bf #1}} +\Tree [.S !\mylex{N}{John} [.VP !\mylex{V}{saw} !\mylex{N}{Jane} ] ] + +\medskip + +We use \verb|!| to bypass the front end, in order to manipulate the tree stack directly. The macro pushes a leaf onto the stack and then includes it under a singleton branch with a bold label. It also increments the counter \verb|\nbranches| to let the front end know that the resulting node has been added to the stack. With some understanding of how qtree works, much more complicated commands are possible. (In extreme cases, you might consider bypassing the front end altogether and relying exclusively on the stack interface). + + +\section{How do I \ldots? (The qtree FAQ)} + +\paragraph{Make my tree fit in the page?} Try one or more of the following: +reduce the font size with \verb|\small| or another size command, +\emph{before} you begin the tree; reduce the amount of space between subtrees +with \verb|\qsetw| or \verb|\faketreewidth|; abbreviate unimportant parts of +your tree with \verb|\qroof|; consider placing your tree sideways in the page, +using one of the packages that provide rotation commands. + +\paragraph{Draw movement arrows from one node of a tree to another?} +Use Emma Pease's \pstyle{tree-dvips.sty}, or some other package for drawing +lines between locations on the page. Despite its name, \pstyle{tree-dvips} +is not narrowly tailored to creating trees; its many line- and arrow-drawing +commands can be used to decorate trees drawn with \Qt. + +\paragraph{Use \Qt\ with \textsl{pdflatex}?} +Earlier versions of \Qt\ did not have good pdflatex support. The current +version supports it through the package \pstyle{pict2e.sty.} If it is not +already available on your system, it is highly recommended that you install +it. See section 2 for details. + +\paragraph{Place a tree in a footnote, figure, or macro argument?} \QT\ does work in floats, but the \verb|\automath| feature is not available in such environments. If you're having problems, you're probably using sub- or superscripts without switching to math mode. See section~\ref{s:super}. + +\paragraph{Center my trees vertically on the baseline?} +Put them inside a trivial +\texttt{tabular} environment. (This can be automated with the hooks +\verb|\qtreeinithook|, \verb|\qtreefinalhook|). To avoid extra whitespace +around the tree, use the following column specification (see the documentation of \verb|{tabular}| for an explanation): + +\verb|\begin{tabular}[c]{@{}l@{}} \Tree ...| + +\paragraph{Line up the text from all the leaf nodes on one horizontal line?} +As far as I can tell, \Qt's design is incompatible with this style of +tree. I'd love it if there was an easy way to give \Qt\ this +capability, but if there is, I haven't figured it out. + +\paragraph{Draw dashed or dotted branches between certain nodes?} +This requires a bit of \LaTeX\ hacking skills, but it can be done. See +section \ref{s:bdraw} for details. + +\paragraph{Automatically select a particular font for branch or leaf labels?} +Redefine \verb|\qlabelhook| and/or \verb|\qleafhook|. See section +\ref{s:ftune}. + +\paragraph{Embed one call to \Qt\ inside another?} \QT\ cannot be called +recursively. If you do need to embed one tree in another (it's very rarely +necessary), save the smaller tree in a \verb|\savebox| and insert it into +the bigger one. See section \ref{s:embed} for the details. + + +\section{Troubleshooting} + +\paragraph*{Disclaimer:} +I welcome any comments, feature requests, or reports of other problems. +But as usual, no guarantees, promises, etc.\ can be made about the present or +future state of this code. + +\paragraph{The placement of trees on the page has changed} Version 3 of \Qt\ +has fixed some bugs in horizontal spacing (most visibly, extra spaces used +to be inserted before trees), and made countless small adjustments in +spacing. Trees are now centered exactly on the line, and they generate +\emph{no} white space around them.\footnote{% + If you put a tight box around a tree (using \texttt{\bslash frame}), it will + just touch the sides of the tree. +} % END FOOTNOTE + They are thus easy to position and integrate with other visual objects. + +Unfortunately, this creates a compatibility problem, as it was not practical +to provide a ``backwardly compatible'' spacing option. If you have used a +lot of \verb|\hspace| commands to adjust the placement of your trees, they +will no longer work properly. On the positive side, it should now be very +easy to arrange trees the way you want them. If you need to process files that have a lot of old trees with spacing adjustments, you can install the package +\pstyle{qtree221.sty}, which contains version 2.21 of qtree. The new commands +and formatting options of \Qt\ version 3 are not available in +\pstyle{qtree221.sty}.\footnote{\pstyle{qtree221.sty} is not available on CTAN. It can be downloaded from the Qtree home page, http://www.ling.upenn.edu/advice/latex/qtree/.} + +The change-over is a one-time incompatibility. Future revisions will +retain the spacing of version 3. + +\paragraph{LaTeX says that pict2e.sty ``will not be written soon''} +\pstyle{Pict2e.sty} \emph{has} finally been written. You need to update your \TeX\ distribution or just download the package. If you cannot do that for any reason, load \Qt\ with \verb|\usepackage[noload]{qtree}| to suppress loading of \pstyle{pict2e.sty}. + +\paragraph{Some very short lines are not drawn} +This problem is caused by the limited inventory of line shapes in +the original \LaTeX\ picture environment. For example, the tree fragment +\verb|[.X a b ]| will produce invisible branch lines from \verb|X| to +\verb|a| and~\verb|b|, +but the lines will reappear if the labels are made wider. If you use +\pstyle{pict2e}, the problem should go away. + +\paragraph{Some not-so-short lines are not drawn} My dvi previewer (yap) +sometimes fails to display some lines; but the lines are really there, +and can be seen at higher magnifications, or when the file is printed or +converted to PostScript. So it's only a problem with the previewer; +if it gets in your way, suppress loading of +\pstyle{pict2e} with the package option \texttt{[noload]}. + +\paragraph{\TeX\ is running out of registers} \QT\ is a real pig for +counter registers: it uses more than 60 of them. In combination with other +packages that use a lot (e.g., the \pstyle{memoir} class), this can go over +the limits of the original \TeX\ +engine. Fortunately most distributions have now quietly switched to using +e\TeX\ internally, which makes many more registers available (you still +invoke it simply as \verb|latex|, so you probably don't even know you're +using it). But you need to tell e\TeX\ that the extra +registers are there. If you run out of registers, try including the +package \pstyle{etex.sty} and see if it fixes the problem.\footnote{% + If you include \pstyle{etex.sty} and strange things +start happening, you probably aren't running the e\TeX\ engine; in that case, +\emph{don't} load \pstyle{etex.sty.} You'll have to install a newer \TeX\ +distribution first. +} % END FOOTNOTE + +\paragraph{There's too much space below my trees, but only when I use pdflatex} +Qtree should produce identical output for dvi and pdf. The problem is caused by a bug in older versions of \pstyle{color.sty}, which is loaded internally by many pdf-aware packages.\footnote{The bug is in the redefinition of \texttt{$\backslash$ usebox} in the file \pstyle{pdftex.def}.} +Update the package \pstyle{color} from CTAN (the entire directory) and the problem will go away. + + +\paragraph{\QT\ will not work with journal style X} + +Any number of things could be going wrong, of course, but start by checking if +the journal's style redefines the {\tt tabular\/} environment. \QT\ +makes internal calls to {\tt tabular\/}, so this is a frequent source of +problems. Usually the style's writer has saved the original definition of +\verb|\tabular| under a different name, so all you need to do is arrange for +the original definition to be restored during the calls to \verb|\Tree|. + +You can define +\verb|\qtreeinithook| to carry out the necessary redefinitions. It is +called at the beginning of each call to \verb|\Tree|, with +local scope (so that any redefinitions it makes are automatically canceled +at the end of the call to \verb|\Tree|). For example, the JNLE style +(\pstyle{nle.sty}) saves the standard commands to begin and end a table as +\verb|\oldtabular| and \verb|\endoldtabular|, respectively, and the +replacement macros result in {\it ~r e a l l y ~ w i d e~\/} trees. The +following will restore the original definitions for calls to \verb|\Tree| +only. +\begin{verbatim} +\def\qtreeinithook{\let\tabular=\oldtabular + \let\endtabular=\endoldtabular} +\end{verbatim} + +Kluwer's house style saves the original definitions as \verb|\klu@tabular| and \verb|\klu@endtabular|; they can be restored in the same way. (You'll need to use \verb|\makeatletter| since these names contain an \texttt{@}-sign). + +\end{document} + +% possibilities for the documentation: +% - expand tree-dvips discussion? +% - incorporate how-to-draw picture? + + +% I guess we don't need this in the printed manual anymore... + +\section{Inspiration} +Here is a last demo, illustrating some of the things you {\it can\/} do with +\Qt. +(This example, and parts of the above exposition, were adapted from the +original documentation for \texttt{QobiTree}). + +\def\CUP{{\bf cup}} +\def\Nspec{N$_{\mbox{\sc spec}}$} +\Tree [.{{\em The cup slid from John to Mary.}\\ + {GO(\CUP, $[_{\rm Path}$ FROM({\bf John}), TO({\bf Mary})])}\\IP} + [.\fbox{Fracture} +% + [.{{\em The cup}\\\CUP\\NP} + [ {{\em The}\\$\bot$\\\Nspec} {{\em cup}\\\CUP\\N} ].\fbox{Fracture} + ] + [.{{\em slid from John to Mary}\\ + {GO({\it x}, $[_{\rm Path}$ FROM({\bf John}), TO({\bf Mary})])}\\IP} + [ $\vdots$ $\vdots$ !\faketreewidth{WWW} ].\fbox{Fracture} + ] + ].\fbox{Fracture} % repeated label +] + +{\small +\begin{verbatim} +\def\CUP{{\bf cup}} +\def\Nspec{N$_{\mbox{\sc spec}}$} +\Tree [.{{\em The cup slid from John to Mary.}\\ + {GO(\CUP, $[_{\rm Path}$ FROM({\bf John}), TO({\bf Mary})])}\\IP} + [.\fbox{Fracture} + % + [.{{\em The cup}\\\CUP\\NP} + [ {{\em The}\\$\bot$\\\Nspec} {{\em cup}\\\CUP\\N} ].\fbox{Fracture} + ] + [.{{\em slid from John to Mary}\\ + {GO({\it x}, $[_{\rm Path}$ FROM({\bf John}), TO({\bf Mary})])}\\IP} + [ $\vdots$ $\vdots$ !\faketreewidth{WWW} ].\fbox{Fracture} + ] + ].\fbox{Fracture} % repeated label +] +\end{verbatim}} % end \small + + +\end{document} diff --git a/Master/texmf-dist/tex/latex/qtree/qtree.sty b/Master/texmf-dist/tex/latex/qtree/qtree.sty new file mode 100644 index 00000000000..f0f72543a47 --- /dev/null +++ b/Master/texmf-dist/tex/latex/qtree/qtree.sty @@ -0,0 +1,1007 @@ +% +% qtree.sty, a LaTeX macro package for drawing trees from descriptions +% given in bracket notation. +% + \def\qTreeVersion{3.1} + \def\qTreeDate{2006/07/10 } + +% QobiTree tree macros written by Jeffrey Mark Siskind (Qobi@cis.upenn.edu). +% Front end and extensions by Alexis Dimitriadis (alexis@ling.upenn.edu). +% +% Please direct questions/comments to alexis@ling.upenn.edu. +% + +% Most recent revisions: + +% 2006/03/08 -- Protected pict2e loading from possible redefinition of ^. +% Reported by Alan Munn. Extended documentation. + +% 2005/12/22 -- 3.0b Removed pgf mode, switched to pict2e.sty support for +% everything. Updated documentation. + +% 2005/05/22 -- Added customization hooks and `balanced' branch command, +% fixed final whitespace in \leaf. Many small tweaks. + +% 2005/05/13 -- Reorganized mode selection options, merged variant file +% forks. + +% 2005/04/07 -- Removed errant spaces, and arranged for trees to be truly +% left-aligned or centered. + +% 2005/02/13 -- Added pgf drawing mode, mode selection support. + +% 2004/07/05 -- Added a way to manipulate the height of single-child nodes. + +% 2002/11/05 -- Fixed display bug in first branch of 5-branching nodes. +% Reported by Paliath Narendran [dran@cs.albany.edu]. + +% 2002/04/17 -- Added provision for ``zero branching'' (empty non-terminals), +% as suggested by Ronald Greenberg [rig@cs.luc.edu]. + +% 2001/09/01 -- Finally made LaTeX2e aware; eepic inclusion is now +% controllable by a package option; massively revised +% documentation. + +% 2000/10/24 -- Fixed bug in last revision that broke parsing of \qroof. + +% 2000/9/28 -- Fixed handling of empty labels so that tree lines stay +% connected. +% -- Small spacing fixes: changed \0, \1 and \2 to \rlap their +% output so that it does not impact on centering. + +\typeout{Package: \qTreeDate v.\qTreeVersion Qtree: tree-drawing for + linguistics} + +% Attempt to preserve LaTeX 2.19 compatibility by not evaluating package +% option commands unless they are defined. Probably pointless... +% +\ifx\ProvidesPackage\undefined \else + \ProvidesPackage {qtree} [\qTreeDate v.\qTreeVersion Qtree: tree-drawing for + linguistics] + + \newif\ifqtreecenter \qtreecentertrue + \DeclareOption{nocenter}{\qtreecenterfalse} + \DeclareOption{center}{\qtreecentertrue} + + % Control automatic loading of graphics extensions + \newif\ifq@autoload \q@autoloadtrue + \DeclareOption{noload}{\q@autoloadfalse} + + % Compatibility options + \def\q@usage{Enhanced picture support for +both pdf and PostScript is now provided by the package pict2e.sty. +(If you need to suppress loading of pict2e.sty, use option [noload]).} + + \DeclareOption{pdf}{\typeout{WARNING: Option [pdf] is obsolete. \q@usage}} + + \DeclareOption{noeepic}{ + \typeout{WARNING: Option [(no)eepic] is obsolete. \q@usage}} + + \ProcessOptions + + % Autoload graphics extensions, unless [noload] was given. + \ifq@autoload + % Some linguistics styles like to redefine ^, which causes problems + % to pict2e.sty. We protect it by temporarily forcing the default + % catcode for ^. + \edef\svcatcode@up@{\the\catcode`\^} + \catcode`\^=7 + % DON'T COMMENT THIS OUT! If you don't want pict2e, + % just call qtree like this: \usepackage[noload]{qtree} + \RequirePackage{pict2e} + % restore the catcode of ^ to whatever value it had + \catcode`\^=\svcatcode@up@ \relax + \let\sv@up@catcode=\relax + \fi + +\fi % end of package options code + + +% Begin QobiTree code + +\newcounter{treecount} \setcounter{treecount}{0} +\newcounter{branchcount} +\newsavebox{\parentbox} +\newsavebox{\treebox} +\newsavebox{\treeboxone} +\newsavebox{\treeboxtwo} +\newsavebox{\treeboxthree} +\newsavebox{\treeboxfour} +\newsavebox{\treeboxfive} +\newsavebox{\treeboxsix} +\newsavebox{\treeboxseven} +\newsavebox{\treeboxeight} +\newsavebox{\treeboxnine} +\newsavebox{\treeboxten} +\newsavebox{\treeboxeleven} +\newsavebox{\treeboxtwelve} +\newsavebox{\treeboxthirteen} +\newsavebox{\treeboxfourteen} +\newsavebox{\treeboxfifteen} +\newsavebox{\treeboxsixteen} +\newsavebox{\treeboxseventeen} +\newsavebox{\treeboxeighteen} +\newsavebox{\treeboxnineteen} +\newsavebox{\treeboxtwenty} +\newlength{\treeoffsetone} +\newlength{\treeoffsettwo} +\newlength{\treeoffsetthree} +\newlength{\treeoffsetfour} +\newlength{\treeoffsetfive} +\newlength{\treeoffsetsix} +\newlength{\treeoffsetseven} +\newlength{\treeoffseteight} +\newlength{\treeoffsetnine} +\newlength{\treeoffsetten} +\newlength{\treeoffseteleven} +\newlength{\treeoffsettwelve} +\newlength{\treeoffsetthirteen} +\newlength{\treeoffsetfourteen} +\newlength{\treeoffsetfifteen} +\newlength{\treeoffsetsixteen} +\newlength{\treeoffsetseventeen} +\newlength{\treeoffseteighteen} +\newlength{\treeoffsetnineteen} +\newlength{\treeoffsettwenty} + +\newlength{\treeshiftone} +\newlength{\treeshifttwo} +\newlength{\treeshiftthree} +\newlength{\treeshiftfour} +\newlength{\treeshiftfive} +\newlength{\treeshiftsix} +\newlength{\treeshiftseven} +\newlength{\treeshifteight} +\newlength{\treeshiftnine} +\newlength{\treeshiftten} +\newlength{\treeshifteleven} +\newlength{\treeshifttwelve} +\newlength{\treeshiftthirteen} +\newlength{\treeshiftfourteen} +\newlength{\treeshiftfifteen} +\newlength{\treeshiftsixteen} +\newlength{\treeshiftseventeen} +\newlength{\treeshifteighteen} +\newlength{\treeshiftnineteen} +\newlength{\treeshifttwenty} +\newlength{\treewidthone} +\newlength{\treewidthtwo} +\newlength{\treewidththree} +\newlength{\treewidthfour} +\newlength{\treewidthfive} +\newlength{\treewidthsix} +\newlength{\treewidthseven} +\newlength{\treewidtheight} +\newlength{\treewidthnine} +\newlength{\treewidthten} +\newlength{\treewidtheleven} +\newlength{\treewidthtwelve} +\newlength{\treewidththirteen} +\newlength{\treewidthfourteen} +\newlength{\treewidthfifteen} +\newlength{\treewidthsixteen} +\newlength{\treewidthseventeen} +\newlength{\treewidtheighteen} +\newlength{\treewidthnineteen} +\newlength{\treewidthtwenty} +\newlength{\daughteroffsetone} +\newlength{\daughteroffsettwo} +\newlength{\daughteroffsetthree} +\newlength{\daughteroffsetfour} +\newlength{\branchwidthone} +\newlength{\branchwidthtwo} +\newlength{\branchwidththree} +\newlength{\branchwidthfour} +\newlength{\parentoffset} +\newlength{\treeoffset} +\newlength{\daughteroffset} +\newlength{\branchwidth} +\newlength{\parentwidth} +\newlength{\treewidth} +% + +% Fine-tuning of trees + +% The height of the line dominating 1-branching nodes. Can be redefined +% at any point to change behaviour (even in mid-tree). +\def\qtreeunaryht{2ex} + +% Amount of padding inserted around leaves and labels +\def\qtreepadding{\tabcolsep} + +% Amound of padding under the eaves of roofs. +\def\qroofpadding{0.4em} + +% Typeset a leaf or label, wrapping with padding. Multiple lines are +% centered, unless the optional argument [c] is overridden (i.e., by \qroof) +% The first non-optional argument (#2) is usually \qleafhook or \qlabelhook. +% This command used to be called \ontop (also it used to be a lot simpler!) +\newcommand{\qshow@text}[3][c]{{#2{\begin{tabular}[t] + {@{\hskip\qtreepadding}#1@{\hskip\qtreepadding}}#3\end{tabular}}}} + +% A ``leaf'' may actually be a roof; if so, we pad it normally but suppress +% the hook; leaf and label hooks are applied separately to the parts of the +% roof. +\def\qshow@leaf#1{\ifx\@qseenode\qroof \qshow@text{\relax}{#1}\else + \qshow@text{\qleafhook}{#1}\fi} + + +\let\qtreeinithook=\relax % global formatting/definitions hook +\let\qtreefinalhook=\relax % called just after the tree is output +\let\qleafhook=\relax % hook for leaf text +\let\qlabelhook=\relax % hook for non-terminal labels +\let\qbranch@hook=\relax % Called after completing a branch (undocumented) + +% Don't take up space for empty labels; as a result, branch segments will be +% attached to their parent branch when no label is given. +% (\rlap triggers space in {tabular}, so it's NON zero, and will be displayed). +\def\showparentbox{\ifdim\wd\parentbox>0pt + \hspace*{\parentoffset}\usebox{\parentbox}\\\fi} + + +% Adjust the bottom-most fork in a binary branching tree, so that branches +% will be of even size if the labels are. +% Use: +% Invoke just before closing the bottom-most (binary) fork; for example: +% \Tree [.X label_1 [.Y label_2 [.Z label_3 right !\qbalance{} ] +% This works by setting the width of ``right'' to triple the width of +% its sister, label_3. (A bit of geometry shows why :-) +\def\qbalance{\qsetw{3\wd\treeboxtwo}} + +% And a debugging/learning aid: +% Draw a (tight) frame around all parts of the tree. +% Note that these will override any content of the format hooks. +\def\qtreeshowframes{\let\qlabelhook=\frame \let\qleafhook=\frame} +% We can include this in \qtreeshowframes, but it's too much information +% \def\qbranch@hook{\setbox\treeboxone \hbox{\frame{\box\treeboxone}}} + +\def\qtreenoframes{\let\qlabelhook=\relax \let\qleafhook=\relax} +% \let \qbranch@hook=\relax} + + +% Put a frame around the just-completed node. +% +\def\qframesubtree{\setbox\treeboxone \hbox{\framebox{\box\treeboxone}}} + +% +\newcommand{\poptree}{% +\ifnum\value{treecount}=0\typeout{QobiTeX warning---Tree stack underflow}\fi +\addtocounter{treecount}{-1}% +\setlength{\treeoffsettwo}{\treeoffsetthree}% +\setlength{\treeoffsetthree}{\treeoffsetfour}% +\setlength{\treeoffsetfour}{\treeoffsetfive}% +\setlength{\treeoffsetfive}{\treeoffsetsix}% +\setlength{\treeoffsetsix}{\treeoffsetseven}% +\setlength{\treeoffsetseven}{\treeoffseteight}% +\setlength{\treeoffseteight}{\treeoffsetnine}% +\setlength{\treeoffsetnine}{\treeoffsetten}% +\setlength{\treeoffsetten}{\treeoffseteleven}% +\setlength{\treeoffseteleven}{\treeoffsettwelve}% +\setlength{\treeoffsettwelve}{\treeoffsetthirteen}% +\setlength{\treeoffsetthirteen}{\treeoffsetfourteen}% +\setlength{\treeoffsetfourteen}{\treeoffsetfifteen}% +\setlength{\treeoffsetfifteen}{\treeoffsetsixteen}% +\setlength{\treeoffsetsixteen}{\treeoffsetseventeen}% +\setlength{\treeoffsetseventeen}{\treeoffseteighteen}% +\setlength{\treeoffseteighteen}{\treeoffsetnineteen}% +\setlength{\treeoffsetnineteen}{\treeoffsettwenty}% +\setlength{\treeshifttwo}{\treeshiftthree}% +\setlength{\treeshiftthree}{\treeshiftfour}% +\setlength{\treeshiftfour}{\treeshiftfive}% +\setlength{\treeshiftfive}{\treeshiftsix}% +\setlength{\treeshiftsix}{\treeshiftseven}% +\setlength{\treeshiftseven}{\treeshifteight}% +\setlength{\treeshifteight}{\treeshiftnine}% +\setlength{\treeshiftnine}{\treeshiftten}% +\setlength{\treeshiftten}{\treeshifteleven}% +\setlength{\treeshifteleven}{\treeshifttwelve}% +\setlength{\treeshifttwelve}{\treeshiftthirteen}% +\setlength{\treeshiftthirteen}{\treeshiftfourteen}% +\setlength{\treeshiftfourteen}{\treeshiftfifteen}% +\setlength{\treeshiftfifteen}{\treeshiftsixteen}% +\setlength{\treeshiftsixteen}{\treeshiftseventeen}% +\setlength{\treeshiftseventeen}{\treeshifteighteen}% +\setlength{\treeshifteighteen}{\treeshiftnineteen}% +\setlength{\treeshiftnineteen}{\treeshifttwenty}% +\setlength{\treewidthtwo}{\treewidththree}% +\setlength{\treewidththree}{\treewidthfour}% +\setlength{\treewidthfour}{\treewidthfive}% +\setlength{\treewidthfive}{\treewidthsix}% +\setlength{\treewidthsix}{\treewidthseven}% +\setlength{\treewidthseven}{\treewidtheight}% +\setlength{\treewidtheight}{\treewidthnine}% +\setlength{\treewidthnine}{\treewidthten}% +\setlength{\treewidthten}{\treewidtheleven}% +\setlength{\treewidtheleven}{\treewidthtwelve}% +\setlength{\treewidthtwelve}{\treewidththirteen}% +\setlength{\treewidththirteen}{\treewidthfourteen}% +\setlength{\treewidthfourteen}{\treewidthfifteen}% +\setlength{\treewidthfifteen}{\treewidthsixteen}% +\setlength{\treewidthsixteen}{\treewidthseventeen}% +\setlength{\treewidthseventeen}{\treewidtheighteen}% +\setlength{\treewidtheighteen}{\treewidthnineteen}% +\setlength{\treewidthnineteen}{\treewidthtwenty}% +\setbox\treeboxtwo \box\treeboxthree +\setbox\treeboxthree \box\treeboxfour +\setbox\treeboxfour \box\treeboxfive +\setbox\treeboxfive \box\treeboxsix +\setbox\treeboxsix \box\treeboxseven +\setbox\treeboxseven \box\treeboxeight +\setbox\treeboxeight \box\treeboxnine +\setbox\treeboxnine \box\treeboxten +\setbox\treeboxten \box\treeboxeleven +\setbox\treeboxeleven \box\treeboxtwelve +\setbox\treeboxtwelve \box\treeboxthirteen +\setbox\treeboxthirteen \box\treeboxfourteen +\setbox\treeboxfourteen \box\treeboxfifteen +\setbox\treeboxfifteen \box\treeboxsixteen +\setbox\treeboxsixteen \box\treeboxseventeen +\setbox\treeboxseventeen \box\treeboxeighteen +\setbox\treeboxeighteen \box\treeboxnineteen +\setbox\treeboxnineteen \box\treeboxtwenty } +% +\newcommand{\leaf}[1]{% +\ifnum\value{treecount}=20\typeout{QobiTeX warning---Tree stack overflow}\fi% +\addtocounter{treecount}{1}% +\setbox\treeboxtwenty \box\treeboxnineteen +\setbox\treeboxnineteen \box\treeboxeighteen +\setbox\treeboxeighteen \box\treeboxseventeen +\setbox\treeboxseventeen \box\treeboxsixteen +\setbox\treeboxsixteen \box\treeboxfifteen +\setbox\treeboxfifteen \box\treeboxfourteen +\setbox\treeboxfourteen \box\treeboxthirteen +\setbox\treeboxthirteen \box\treeboxtwelve +\setbox\treeboxtwelve \box\treeboxeleven +\setbox\treeboxeleven \box\treeboxten +\setbox\treeboxten \box\treeboxnine +\setbox\treeboxnine \box\treeboxeight +\setbox\treeboxeight \box\treeboxseven +\setbox\treeboxseven \box\treeboxsix +\setbox\treeboxsix \box\treeboxfive +\setbox\treeboxfive \box\treeboxfour +\setbox\treeboxfour \box\treeboxthree +\setbox\treeboxthree \box\treeboxtwo +\setbox\treeboxtwo \box\treeboxone +\sbox{\treeboxone}{\qshow@leaf{#1}}% +\sbox{\treeboxone}{\raisebox{-\ht\treeboxone}{\usebox{\treeboxone}}}% +\setlength{\treeoffsettwenty}{\treeoffsetnineteen}% +\setlength{\treeoffsetnineteen}{\treeoffseteighteen}% +\setlength{\treeoffseteighteen}{\treeoffsetseventeen}% +\setlength{\treeoffsetseventeen}{\treeoffsetsixteen}% +\setlength{\treeoffsetsixteen}{\treeoffsetfifteen}% +\setlength{\treeoffsetfifteen}{\treeoffsetfourteen}% +\setlength{\treeoffsetfourteen}{\treeoffsetthirteen}% +\setlength{\treeoffsetthirteen}{\treeoffsettwelve}% +\setlength{\treeoffsettwelve}{\treeoffseteleven}% +\setlength{\treeoffseteleven}{\treeoffsetten}% +\setlength{\treeoffsetten}{\treeoffsetnine}% +\setlength{\treeoffsetnine}{\treeoffseteight}% +\setlength{\treeoffseteight}{\treeoffsetseven}% +\setlength{\treeoffsetseven}{\treeoffsetsix}% +\setlength{\treeoffsetsix}{\treeoffsetfive}% +\setlength{\treeoffsetfive}{\treeoffsetfour}% +\setlength{\treeoffsetfour}{\treeoffsetthree}% +\setlength{\treeoffsetthree}{\treeoffsettwo}% +\setlength{\treeoffsettwo}{\treeoffsetone}% +\setlength{\treeoffsetone}{0.5\wd\treeboxone}% +\setlength{\treeshifttwenty}{\treeshiftnineteen}% +\setlength{\treeshiftnineteen}{\treeshifteighteen}% +\setlength{\treeshifteighteen}{\treeshiftseventeen}% +\setlength{\treeshiftseventeen}{\treeshiftsixteen}% +\setlength{\treeshiftsixteen}{\treeshiftfifteen}% +\setlength{\treeshiftfifteen}{\treeshiftfourteen}% +\setlength{\treeshiftfourteen}{\treeshiftthirteen}% +\setlength{\treeshiftthirteen}{\treeshifttwelve}% +\setlength{\treeshifttwelve}{\treeshifteleven}% +\setlength{\treeshifteleven}{\treeshiftten}% +\setlength{\treeshiftten}{\treeshiftnine}% +\setlength{\treeshiftnine}{\treeshifteight}% +\setlength{\treeshifteight}{\treeshiftseven}% +\setlength{\treeshiftseven}{\treeshiftsix}% +\setlength{\treeshiftsix}{\treeshiftfive}% +\setlength{\treeshiftfive}{\treeshiftfour}% +\setlength{\treeshiftfour}{\treeshiftthree}% +\setlength{\treeshiftthree}{\treeshifttwo}% +\setlength{\treeshifttwo}{\treeshiftone}% +\setlength{\treeshiftone}{0pt}% +\setlength{\treewidthtwenty}{\treewidthnineteen}% +\setlength{\treewidthnineteen}{\treewidtheighteen}% +\setlength{\treewidtheighteen}{\treewidthseventeen}% +\setlength{\treewidthseventeen}{\treewidthsixteen}% +\setlength{\treewidthsixteen}{\treewidthfifteen}% +\setlength{\treewidthfifteen}{\treewidthfourteen}% +\setlength{\treewidthfourteen}{\treewidththirteen}% +\setlength{\treewidththirteen}{\treewidthtwelve}% +\setlength{\treewidthtwelve}{\treewidtheleven}% +\setlength{\treewidtheleven}{\treewidthten}% +\setlength{\treewidthten}{\treewidthnine}% +\setlength{\treewidthnine}{\treewidtheight}% +\setlength{\treewidtheight}{\treewidthseven}% +\setlength{\treewidthseven}{\treewidthsix}% +\setlength{\treewidthsix}{\treewidthfive}% +\setlength{\treewidthfive}{\treewidthfour}% +\setlength{\treewidthfour}{\treewidththree}% +\setlength{\treewidththree}{\treewidthtwo}% +\setlength{\treewidthtwo}{\treewidthone}% +\setlength{\treewidthone}{\wd\treeboxone}} +% +\newcommand{\branch}[2]{% +\setcounter{branchcount}{#1}% +% 0-branching +\ifnum\value{branchcount}=0\leaf{#2}\else% added 2002/04/19, RIG +% Branch label (all branch counts) +\sbox{\parentbox}{\qshow@text{\qlabelhook}{#2}}% +% 1-branching +\ifnum\value{branchcount}=1 +\setlength{\parentoffset}{\treeoffsetone}% +\addtolength{\parentoffset}{-0.5\wd\parentbox}% +\setlength{\daughteroffset}{0in}% +\ifdim\parentoffset<0in% +\setlength{\daughteroffset}{-\parentoffset}% +\setlength{\parentoffset}{0in}\fi% +\setlength{\parentwidth}{\parentoffset}% +\addtolength{\parentwidth}{\wd\parentbox}% +\setlength{\treeoffset}{\daughteroffset}% +\addtolength{\treeoffset}{\treeoffsetone}% +\setlength{\treewidth}{\wd\treeboxone}% +\addtolength{\treewidth}{\daughteroffset}% +\ifdim\treewidth<\parentwidth\setlength{\treewidth}{\parentwidth}\fi% +\sbox{\treebox}{\begin{minipage}{\treewidth}% +\begin{flushleft}% +\showparentbox +{\setlength{\unitlength}{\qtreeunaryht}% +\hspace*{\treeoffset}\qdraw@branches{1}}\\ +\vspace{-\baselineskip}% +\hspace*{\daughteroffset}% +\raisebox{-\ht\treeboxone}{\usebox{\treeboxone}}% +\end{flushleft}% +\end{minipage}}% +\setlength{\treeoffsetone}{\parentoffset}% +\addtolength{\treeoffsetone}{0.5\wd\parentbox}% +\setlength{\treeshiftone}{0pt}% +\setlength{\treewidthone}{\treewidth}% +\sbox{\treeboxone}{\usebox{\treebox}}% +% 2-branching +\else\ifnum\value{branchcount}=2 +\setlength{\branchwidthone}{\treewidthtwo}% +\addtolength{\branchwidthone}{\treeoffsetone}% +\addtolength{\branchwidthone}{-\treeshiftone}% +\addtolength{\branchwidthone}{-\treeoffsettwo}% +\setlength{\branchwidth}{\branchwidthone}% +\setlength{\daughteroffsetone}{\branchwidth}% +\addtolength{\daughteroffsetone}{-\branchwidthone}% +\addtolength{\daughteroffsetone}{-\treeshiftone}% +\setlength{\parentoffset}{-0.5\wd\parentbox}% +\addtolength{\parentoffset}{\treeoffsettwo}% +\addtolength{\parentoffset}{0.5\branchwidth}% +\setlength{\daughteroffset}{0in}% +\ifdim\parentoffset<0in% +\setlength{\daughteroffset}{-\parentoffset}% +\setlength{\parentoffset}{0in}\fi% +\setlength{\parentwidth}{\parentoffset}% +\addtolength{\parentwidth}{\wd\parentbox}% +\setlength{\treeoffset}{\daughteroffset}% +\addtolength{\treeoffset}{\treeoffsettwo}% +\setlength{\treewidth}{\wd\treeboxone}% +\addtolength{\treewidth}{\daughteroffsetone}% +\addtolength{\treewidth}{\treewidthtwo}% +\addtolength{\treewidth}{\daughteroffset}% +\ifdim\treewidth<\parentwidth\setlength{\treewidth}{\parentwidth}\fi% +\sbox{\treebox}{\begin{minipage}{\treewidth}% +\begin{flushleft}% +\showparentbox %\frame +{\setlength{\unitlength}{0.5\branchwidth}% +\hspace*{\treeoffset}\qdraw@branches{2}}\\ +\vspace{-\baselineskip}% +\hspace*{\daughteroffset}% +\makebox[\treewidthtwo][l]% +{\raisebox{-\ht\treeboxtwo}{\usebox{\treeboxtwo}}}% +\hspace*{\daughteroffsetone}% +\raisebox{-\ht\treeboxone}{\usebox{\treeboxone}}% +\end{flushleft}% +\end{minipage}}% +\setlength{\treeoffsetone}{\parentoffset}% +\addtolength{\treeoffsetone}{0.5\wd\parentbox}% +\setlength{\treeshiftone}{0pt}% +\setlength{\treewidthone}{\treewidth}% +\sbox{\treeboxone}{\usebox{\treebox}}\poptree% +% 3-branching +\else\ifnum\value{branchcount}=3 +\setlength{\branchwidthone}{\treewidthtwo}% +\addtolength{\branchwidthone}{\treeoffsetone}% +\addtolength{\branchwidthone}{-\treeshiftone}% +\addtolength{\branchwidthone}{-\treeoffsettwo}% +\setlength{\branchwidthtwo}{\treewidththree}% +\addtolength{\branchwidthtwo}{\treeoffsettwo}% +\addtolength{\branchwidthtwo}{-\treeshifttwo}% +\addtolength{\branchwidthtwo}{-\treeoffsetthree}% +\setlength{\branchwidth}{\branchwidthone}% +\ifdim\branchwidthtwo>\branchwidth% +\setlength{\branchwidth}{\branchwidthtwo}\fi% +\setlength{\daughteroffsetone}{\branchwidth}% +\addtolength{\daughteroffsetone}{-\branchwidthone}% +\addtolength{\daughteroffsetone}{-\treeshiftone}% +\setlength{\daughteroffsettwo}{\branchwidth}% +\addtolength{\daughteroffsettwo}{-\branchwidthtwo}% +\addtolength{\daughteroffsettwo}{-\treeshifttwo}% +\setlength{\parentoffset}{-0.5\wd\parentbox}% +\addtolength{\parentoffset}{\treeoffsetthree}% +\addtolength{\parentoffset}{\branchwidth}% +\setlength{\daughteroffset}{0in}% +\ifdim\parentoffset<0in% +\setlength{\daughteroffset}{-\parentoffset}% +\setlength{\parentoffset}{0in}\fi% +\setlength{\parentwidth}{\parentoffset}% +\addtolength{\parentwidth}{\wd\parentbox}% +\setlength{\treeoffset}{\daughteroffset}% +\addtolength{\treeoffset}{\treeoffsetthree}% +\setlength{\treewidth}{\wd\treeboxone}% +\addtolength{\treewidth}{\daughteroffsetone}% +\addtolength{\treewidth}{\treewidthtwo}% +\addtolength{\treewidth}{\daughteroffsettwo}% +\addtolength{\treewidth}{\treewidththree}% +\addtolength{\treewidth}{\daughteroffset}% +\ifdim\treewidth<\parentwidth\setlength{\treewidth}{\parentwidth}\fi% +\sbox{\treebox}{\begin{minipage}{\treewidth}% +\begin{flushleft}% +\showparentbox +{\setlength{\unitlength}{0.5\branchwidth}% +\hspace*{\treeoffset}\qdraw@branches{3}}\\ +\vspace{-\baselineskip}% +\hspace*{\daughteroffset}% +\makebox[\treewidththree][l]% +{\raisebox{-\ht\treeboxthree}{\usebox{\treeboxthree}}}% +\hspace*{\daughteroffsettwo}% +\makebox[\treewidthtwo][l]% +{\raisebox{-\ht\treeboxtwo}{\usebox{\treeboxtwo}}}% +\hspace*{\daughteroffsetone}% +\raisebox{-\ht\treeboxone}{\usebox{\treeboxone}}% +\end{flushleft}% +\end{minipage}}% +\setlength{\treeoffsetone}{\parentoffset}% +\addtolength{\treeoffsetone}{0.5\wd\parentbox}% +\setlength{\treeshiftone}{0pt}% +\setlength{\treewidthone}{\treewidth}% +\sbox{\treeboxone}{\usebox{\treebox}}\poptree\poptree% +% 4-branching +\else\ifnum\value{branchcount}=4 +\setlength{\branchwidthone}{\treewidthtwo}% +\addtolength{\branchwidthone}{\treeoffsetone}% +\addtolength{\branchwidthone}{-\treeshiftone}% +\addtolength{\branchwidthone}{-\treeoffsettwo}% +\setlength{\branchwidthtwo}{\treewidththree}% +\addtolength{\branchwidthtwo}{\treeoffsettwo}% +\addtolength{\branchwidthtwo}{-\treeshifttwo}% +\addtolength{\branchwidthtwo}{-\treeoffsetthree}% +\setlength{\branchwidththree}{\treewidthfour}% +\addtolength{\branchwidththree}{\treeoffsetthree}% +\addtolength{\branchwidththree}{-\treeshiftthree}% +\addtolength{\branchwidththree}{-\treeoffsetfour}% +\setlength{\branchwidth}{\branchwidthone}% +\ifdim\branchwidthtwo>\branchwidth% +\setlength{\branchwidth}{\branchwidthtwo}\fi% +\ifdim\branchwidththree>\branchwidth% +\setlength{\branchwidth}{\branchwidththree}\fi% +\setlength{\daughteroffsetone}{\branchwidth}% +\addtolength{\daughteroffsetone}{-\branchwidthone}% +\addtolength{\daughteroffsetone}{-\treeshiftone}% +\setlength{\daughteroffsettwo}{\branchwidth}% +\addtolength{\daughteroffsettwo}{-\branchwidthtwo}% +\addtolength{\daughteroffsettwo}{-\treeshifttwo}% +\setlength{\daughteroffsetthree}{\branchwidth}% +\addtolength{\daughteroffsetthree}{-\branchwidththree}% +\addtolength{\daughteroffsetthree}{-\treeshiftthree}% +\setlength{\parentoffset}{-0.5\wd\parentbox}% +\addtolength{\parentoffset}{\treeoffsetfour}% +\addtolength{\parentoffset}{1.5\branchwidth}% +\setlength{\daughteroffset}{0in}% +\ifdim\parentoffset<0in% +\setlength{\daughteroffset}{-\parentoffset}% +\setlength{\parentoffset}{0in}\fi% +\setlength{\parentwidth}{\parentoffset}% +\addtolength{\parentwidth}{\wd\parentbox}% +\setlength{\treeoffset}{\daughteroffset}% +\addtolength{\treeoffset}{\treeoffsetfour}% +\setlength{\treewidth}{\wd\treeboxone}% +\addtolength{\treewidth}{\daughteroffsetone}% +\addtolength{\treewidth}{\treewidthtwo}% +\addtolength{\treewidth}{\daughteroffsettwo}% +\addtolength{\treewidth}{\treewidththree}% +\addtolength{\treewidth}{\daughteroffsetthree}% +\addtolength{\treewidth}{\treewidthfour}% +\addtolength{\treewidth}{\daughteroffset}% +\ifdim\treewidth<\parentwidth\setlength{\treewidth}{\parentwidth}\fi% +\sbox{\treebox}{\begin{minipage}{\treewidth}% +\begin{flushleft}% +\showparentbox +{\setlength{\unitlength}{0.5\branchwidth}% +\hspace*{\treeoffset}\qdraw@branches{4}}\\ +\vspace{-\baselineskip}% +\hspace*{\daughteroffset}% +\makebox[\treewidthfour][l]% +{\raisebox{-\ht\treeboxfour}{\usebox{\treeboxfour}}}% +\hspace*{\daughteroffsetthree}% +\makebox[\treewidththree][l]% +{\raisebox{-\ht\treeboxthree}{\usebox{\treeboxthree}}}% +\hspace*{\daughteroffsettwo}% +\makebox[\treewidthtwo][l]% +{\raisebox{-\ht\treeboxtwo}{\usebox{\treeboxtwo}}}% +\hspace*{\daughteroffsetone}% +\raisebox{-\ht\treeboxone}{\usebox{\treeboxone}}% +\end{flushleft}% +\end{minipage}}% +\setlength{\treeoffsetone}{\parentoffset}% +\addtolength{\treeoffsetone}{0.5\wd\parentbox}% +\setlength{\treeshiftone}{0pt}% +\setlength{\treewidthone}{\treewidth}% +\sbox{\treeboxone}{\usebox{\treebox}}\poptree\poptree\poptree% +% 5-branching +\else\ifnum\value{branchcount}=5 +\setlength{\branchwidthone}{\treewidthtwo}% +\addtolength{\branchwidthone}{\treeoffsetone}% +\addtolength{\branchwidthone}{-\treeshiftone}% +\addtolength{\branchwidthone}{-\treeoffsettwo}% +\setlength{\branchwidthtwo}{\treewidththree}% +\addtolength{\branchwidthtwo}{\treeoffsettwo}% +\addtolength{\branchwidthtwo}{-\treeshifttwo}% +\addtolength{\branchwidthtwo}{-\treeoffsetthree}% +\setlength{\branchwidththree}{\treewidthfour}% +\addtolength{\branchwidththree}{\treeoffsetthree}% +\addtolength{\branchwidththree}{-\treeshiftthree}% +\addtolength{\branchwidththree}{-\treeoffsetfour}% +\setlength{\branchwidthfour}{\treewidthfive}% +\addtolength{\branchwidthfour}{\treeoffsetfour}% +\addtolength{\branchwidthfour}{-\treeshiftfour}% +\addtolength{\branchwidthfour}{-\treeoffsetfive}% +\setlength{\branchwidth}{\branchwidthone}% +\ifdim\branchwidthtwo>\branchwidth% +\setlength{\branchwidth}{\branchwidthtwo}\fi% +\ifdim\branchwidththree>\branchwidth% +\setlength{\branchwidth}{\branchwidththree}\fi% +\ifdim\branchwidthfour>\branchwidth% +\setlength{\branchwidth}{\branchwidthfour}\fi% +\setlength{\daughteroffsetone}{\branchwidth}% +\addtolength{\daughteroffsetone}{-\branchwidthone}% +\addtolength{\daughteroffsetone}{-\treeshiftone}% +\setlength{\daughteroffsettwo}{\branchwidth}% +\addtolength{\daughteroffsettwo}{-\branchwidthtwo}% +\addtolength{\daughteroffsettwo}{-\treeshifttwo}% +\setlength{\daughteroffsetthree}{\branchwidth}% +\addtolength{\daughteroffsetthree}{-\branchwidththree}% +\addtolength{\daughteroffsetthree}{-\treeshiftthree}% +\setlength{\daughteroffsetfour}{\branchwidth}% +\addtolength{\daughteroffsetfour}{-\branchwidthfour}% +\addtolength{\daughteroffsetfour}{-\treeshiftfour}% +\setlength{\parentoffset}{-0.5\wd\parentbox}% +\addtolength{\parentoffset}{\treeoffsetfive}% +\addtolength{\parentoffset}{2\branchwidth}% +\setlength{\daughteroffset}{0in}% +\ifdim\parentoffset<0in% +\setlength{\daughteroffset}{-\parentoffset}% +\setlength{\parentoffset}{0in}\fi% +\setlength{\parentwidth}{\parentoffset}% +\addtolength{\parentwidth}{\wd\parentbox}% +\setlength{\treeoffset}{\daughteroffset}% +\addtolength{\treeoffset}{\treeoffsetfive}% +\setlength{\treewidth}{\wd\treeboxone}% +\addtolength{\treewidth}{\daughteroffsetone}% +\addtolength{\treewidth}{\treewidthtwo}% +\addtolength{\treewidth}{\daughteroffsettwo}% +\addtolength{\treewidth}{\treewidththree}% +\addtolength{\treewidth}{\daughteroffsetthree}% +\addtolength{\treewidth}{\treewidthfour}% +\addtolength{\treewidth}{\daughteroffsetfour}% +\addtolength{\treewidth}{\treewidthfive}% +\addtolength{\treewidth}{\daughteroffset}% +\ifdim\treewidth<\parentwidth\setlength{\treewidth}{\parentwidth}\fi% +\sbox{\treebox}{\begin{minipage}{\treewidth}% +\begin{flushleft}% +\showparentbox +{\setlength{\unitlength}{0.5\branchwidth}% +\hspace*{\treeoffset}\qdraw@branches{5}}\\ +\vspace{-\baselineskip}% +\hspace*{\daughteroffset}% +\makebox[\treewidthfive][l]% +{\raisebox{-\ht\treeboxfive}{\usebox{\treeboxfive}}}% +\hspace*{\daughteroffsetfour}% +\makebox[\treewidthfour][l]% +{\raisebox{-\ht\treeboxfour}{\usebox{\treeboxfour}}}% +\hspace*{\daughteroffsetthree}% +\makebox[\treewidththree][l]% +{\raisebox{-\ht\treeboxthree}{\usebox{\treeboxthree}}}% +\hspace*{\daughteroffsettwo}% +\makebox[\treewidthtwo][l]% +{\raisebox{-\ht\treeboxtwo}{\usebox{\treeboxtwo}}}% +\hspace*{\daughteroffsetone}% +\raisebox{-\ht\treeboxone}{\usebox{\treeboxone}}% +\end{flushleft}% +\end{minipage}}% +\setlength{\treeoffsetone}{\parentoffset}% +\addtolength{\treeoffsetone}{0.5\wd\parentbox}% +\setlength{\treeshiftone}{0pt}% +\setlength{\treewidthone}{\treewidth}% +\sbox{\treeboxone}{\usebox{\treebox}}\poptree\poptree\poptree\poptree% +\else\typeout{QobiTeX warning--- Can't handle #1 branching}\fi\fi\fi\fi\fi\fi} +% +\newcommand{\faketreewidth}[1]{% + \sbox{\parentbox}{\qshow@text{\relax}{#1}}% + \setlength{\treewidthone}{0.5\wd\parentbox}% + \addtolength{\treewidthone}{\treeoffsetone}% + \setlength{\treeshiftone}{\treeoffsetone}% + \addtolength{\treeshiftone}{-0.5\wd\parentbox}} +% + +% set-tree-width: like \faketreewidth, but takes a dimension argument +% Use: \qsetw{1in} etc. +\newcommand{\qsetw}[1]{% + \treewidthone = #1 + \treewidthone = 0.5\treewidthone + \treeshiftone = -\treewidthone + \advance\treewidthone by \treeoffsetone + \advance\treeshiftone by \treeoffsetone} + +% Fix up alignment of the tree and print out. +% \Tree has already taken care of centering, etc. +% +\newcommand{\qobitree}{% + % Cancel padding inserted by \qshow@text + \setbox\treeboxone \hbox{% + \hskip-\qtreepadding \box\treeboxone \hskip-\qtreepadding}% + % Lower box, to top-align with baseline + \@tempdima=\ht\treeboxone + \advance\@tempdima by -\ht\strutbox + \leavevmode \raise-\@tempdima \box\treeboxone + % Now clean up + \setlength{\treeoffsetone}{\treeoffsettwo}% + \setbox\treeboxone \box\treeboxtwo + \poptree } + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Front end for qobitree. Reads a tree in bracketed notation and +% generates commands to build the specified tree. +% Tokens are space-delimited; brackets {} may be used to alter grouping. +% +% Alexis Dimitriadis (alexis@babel.ling.upenn.edu), Dec 6, 1993. +% +% Sample input: +% \Tree [ [ John ].NP [ has [ [ seen ].V [ {the book} ].NP ].T ].IP ].S +% To insert extra material, precede token with an exclamation mark, e.g. +% ... ].V !\faketreewidth{VPP} ... + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Very messy stack macros, to make up for lack of nested environments in +% qobitree. +% +% \Spush\Stack{X} Push X on stack \Stack. +% \Spop\Stack Pop top element off \Stack, leave in the input stream. +% \Spopd\Stack\to\v Define \v to be the top element of \Stack, pop it. +% + +% This will trigger a LaTeX diagnostic if we pop too far. +\def\qbstack{<Stack Underflow>} +\def\qnstack{<Stack Underflow>} + + +\newtoks\qta \newtoks\qtb +% Expand #2 and push on stack #1. Things already pushed are not +% reexpanded. +\long\def\Spush#1#2{\qta=\expandafter{#1}% + \edef#1{{#2}\noexpand\@@STP{\the\qta}}} + +% Push #2 on stack #1 unexpanded. +% +\long\def\SpushU#1#2{\qta=\expandafter{#1}\qtb={#2}% + \edef#1{{\the\qtb}\noexpand\@@STP{\the\qta}}} + +\def\@@STP{\def\@@StpV} + +% Pop the top element of stack #1, leaving in the input stream. +% +\def\Spop#1{#1\let#1=\@@StpV} + +% Pop the top element of stack #1, expand it, and define #2 to it. +% +\def\SpopD#1#2{\expandafter\qta#1\let#1=\@@StpV\edef#2{\the\qta}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This is the front end proper. Everything else is just sugar. +% (the stack macros are necessary). +% +\newcount\nbranches + +\def\Tree{\bgroup + \@ifundefined{qtreebugfixhook}{}\qtreebugfixhook % retained for compatibility + \automath \qtreeprimes@internal + \qtreeinithook + \ifqtreecenter\hskip 0pt plus 1fil\else\leavevmode\fi + \nbranches=0\relax \q@recurse } + +\def\endTree{\qobitree \qtreefinalhook \egroup} + +\def\q@recurse[{\@ifnextchar.{\qq@recurse}{\qq@recurse. }} +\def\qq@recurse.#1 {\SpushU\qnstack{#1}% + \Spush\qbstack{\number\nbranches}\nbranches=0\relax \q@lookfornodes } + +% \doanode should more properly be called \doaleaf. +% \@qseenode is the first token of our argument: handle specially if a roof. +% The space in \leaf is for terminating the argument of \qroof +\def\doanode#1 {\advance\nbranches by1 + \ifx\@qseenode\qroof \leaf{#1 }% + \else \leaf{#1}\fi \q@lookfornodes} + +\def\q@lookfornodes{\@ifnextchar]{\closeoff}{% + \@ifnextchar[{\advance\nbranches by1\relax \q@recurse}{% + \@ifnextchar!{\pushliteral}{\futurelet\@qseenode\doanode}}}} + +\def\pushliteral!#1 {#1\relax \q@lookfornodes} + +\def\closeoff]{\@ifnextchar.{\expandafter\@closeoff}{\expandafter\@closeoff. }} +% If either label is missing, use the other. +% Otherwise, disallow mismatched labels +% Push and pop right argument to make sure the tokens are in same state... +\def\@closeoff.#1 {% + \def\rarg{#1}% + \SpopD\qnstack\larg + \ifx\larg\@empty \let\larg=\rarg + \else \ifx\rarg\@empty \let\rarg=\larg \fi\fi + \ifx\larg\rarg \else + \errmessage{MISMATCHED LABELS, [.\larg\ ... ].\rarg}% + \fi + \@@closeoff\larg } + +\def\@@closeoff#1{\branch{\number\nbranches}{#1}% + \SpopD\qbstack\x\nbranches=\x \relax +% \showthe\nbranches + \qbranch@hook + \ifnum\nbranches>0 \expandafter\q@lookfornodes + \else \expandafter\endTree \fi} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% and another odd convenience: +% +% Make _, ^ go into math mode automatically in the scope of \automath +% +{ % Temporarily change catcodes + \catcode`\_=\active + \catcode`\^=\active + + \global\def\automath{% + \catcode`\_=\active + \catcode`\^=\active + \def_##1{\@ifnextchar^{\automath@two_{##1}}{\ensuremath{\sb{##1}}}}% + \def^##1{\@ifnextchar_{\automath@two^{##1}}{\ensuremath{\sp{##1}}}}} +} +\def\automath@two#1#2#3#4{\ensuremath{#1{#2}\relax #3{#4}}} +% Restore default catcodes for ^, _ +\def\noautomath{\catcode`\_=8 \catcode`\^=7 } + + +% Let \0, \1, \2 produce ^0, $'$, $''$ +% The \rlap results in better centering of the label (ignoring the +% superscript) +\def\qtreeprimes@internal{% + \def\0{\ifmmode ^0\else \rlap{$^0$}\fi}% + \def\1{\ifmmode '\else \rlap{$'$}\fi}% + \def\2{\ifmmode ''\else \rlap{$''$}\fi}% +} + +% Same commands, but without the \rlap feature +\def\qtreeprimes{% + \def\0{\ensuremath{^0}}% + \def\1{\ensuremath{'}}% + \def\2{\ensuremath{''}}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% qroof: Build a triangular ``roof'' with label #2 and contents (under the +% roof) #1. The width of the roof is computed automatically. The contents +% may contain line breaks (\\). +% + +% The slope of the roof built by qroof (may be changed anywhere). +\newcount\qroofx +\newcount\qroofy +\qroofx=3 \qroofy=1 + +\newbox\@qrscratchbox + +% User command for requesting a roof +% +\def\qroof#1.#2 {{% + % padding under the ``eaves'' of the roof + \setbox\@qrscratchbox = \hbox{\let\qtreepadding=\qroofpadding + \qshow@text[l]{\qleafhook}{#1}}% + % we don't pad here, since the entire roof gets padded as a leaf. + \def\qtreepadding{0pt}% + \begin{tabular}{@{}c@{}} + \qshow@text{\qlabelhook}{#2}\\ + \unitlength=\wd\@qrscratchbox \qdraw@roof \\[-0.6ex] + \box\@qrscratchbox +\end{tabular}}} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DRAWING UTILITIES + +% The drawing routines may be redefined. The new drawing configuration +% must provide the commands: +% +% \qdraw@branches{N} Draw N branches, each \unitlength wide +% \qdraw@roof Draw a roof, \unitlength wide +% +% (\unitlength is set to the proper value before these are called) + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The original, ``picture'' driver: Uses the native {picture} environment. +% It is expected that it will be augmented (originally with eepic, but now +% with pict2e.sty) + +% Draws a roof with slope \qroofy/\qroofx, and width equal to the current +% width of \unitlength (which, during the actual drawing, is set to a +% suitable value +% Because we must use integer arithmetic, we divide \unitlength into +% 2\qroofx units for calculations + +\def\qdraw@roof{{% + \def\wwd{\count1}% + \wwd=\qroofx\relax + \multiply\wwd by 2 + \divide\unitlength by \wwd + \begin{picture}(\wwd,\qroofy) + \put(0, 0){\line(1,0){\wwd}} + \put(0, 0){\line(\qroofx, \qroofy){\qroofx}} + \put(\wwd, 0){\line(-\qroofx, \qroofy){\qroofx}} + \end{picture}}} + +% Draw one of the branching structures we need, using the standard {picture} +% environment (with or without eepic extensions). +% The parameter \unitlength is already set appropriately +% +\def\qdraw@branches#1{\ifcase#1\relax % Zero case is unused + \or % One-branching + \begin{picture}(0,1) + \put(0,0){\line(0,1){1}} + \end{picture}% + \or % Two-branching + \begin{picture}(2,0.5) + \put(0,0){\line(2,1){1}} + \put(2,0){\line(-2,1){1}} + \end{picture}% + \or % Three-branching + \begin{picture}(4,1) + \put(0,0){\line(2,1){2}} + \put(2,0){\line(0,1){1}} + \put(4,0){\line(-2,1){2}} + \end{picture}% + \or % Four-branching + \begin{picture}(6,1) + \put(0,0){\line(3,1){3}} + \put(2,0){\line(1,1){1}} + \put(4,0){\line(-1,1){1}} + \put(6,0){\line(-3,1){3}} + \end{picture}% + \or % Five-branching + \begin{picture}(8,1) + \put(0,0){\line(4,1){4}} + \put(2,0){\line(2,1){2}} + \put(4,0){\line(0,1){1}} + \put(6,0){\line(-2,1){2}} + \put(8,0){\line(-4,1){4}} + \end{picture}% + \else\typeout{Qtree error--- Can't handle #1-way branching} + \fi} + +% END OF PICTURE driver definitions + diff --git a/Master/texmf-dist/tpm/qtree.tpm b/Master/texmf-dist/tpm/qtree.tpm new file mode 100644 index 00000000000..575cad0dcf5 --- /dev/null +++ b/Master/texmf-dist/tpm/qtree.tpm @@ -0,0 +1,28 @@ +<!DOCTYPE rdf:RDF SYSTEM "../../support/tpm.dtd"> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:TPM="http://texlive.dante.de/"> + <rdf:Description about="http://texlive.dante.de/texlive/Package/qtree.zip"> + <TPM:Name>qtree</TPM:Name> + <TPM:Type>Package</TPM:Type> + <TPM:Date>2006/07/12 00:24:14</TPM:Date> + <TPM:Version></TPM:Version> + <TPM:Creator>karl</TPM:Creator> + <TPM:Title>The qtree package.</TPM:Title> + <TPM:Description></TPM:Description> + <TPM:Author></TPM:Author> + <TPM:Size>333029</TPM:Size> + <TPM:Build/> + <TPM:RunFiles size="38590"> +texmf-dist/tex/latex/qtree/qtree.sty +texmf-dist/tpm/qtree.tpm + </TPM:RunFiles> + <TPM:DocFiles size="295421"> +texmf-dist/doc/latex/qtree/README +texmf-dist/doc/latex/qtree/qarrows.pdf +texmf-dist/doc/latex/qtree/qarrows.tex +texmf-dist/doc/latex/qtree/qtreenotes.pdf +texmf-dist/doc/latex/qtree/qtreenotes.tex + </TPM:DocFiles> + <TPM:Provides>Package/qtree</TPM:Provides> + </rdf:Description> +</rdf:RDF> + diff --git a/Master/texmf/lists/qtree b/Master/texmf/lists/qtree new file mode 100644 index 00000000000..a6bc9009bc9 --- /dev/null +++ b/Master/texmf/lists/qtree @@ -0,0 +1,10 @@ +texmf-dist/doc/latex/qtree/README +texmf-dist/doc/latex/qtree/qarrows.pdf +texmf-dist/doc/latex/qtree/qarrows.tex +texmf-dist/doc/latex/qtree/qtreenotes.pdf +texmf-dist/doc/latex/qtree/qtreenotes.tex + +texmf-dist/tex/latex/qtree/qtree.sty +texmf-dist/tpm/qtree.tpm + +texmf/lists/qtree diff --git a/Master/texmf/tpm/collection-latexextra.tpm b/Master/texmf/tpm/collection-latexextra.tpm index 64a60451ca5..de3353848be 100644 --- a/Master/texmf/tpm/collection-latexextra.tpm +++ b/Master/texmf/tpm/collection-latexextra.tpm @@ -368,6 +368,7 @@ A large collection of add-on packages for LaTeX. <TPM:Package name="qcm"/> <TPM:Package name="qobitree"/> <TPM:Package name="qsymbols"/> + <TPM:Package name="qtree"/> <TPM:Package name="quotchap"/> <TPM:Package name="ragged2e"/> <TPM:Package name="rccol"/> |