sawine@0
|
1 |
% tikz-qtree-compat.tex
|
sawine@0
|
2 |
% Version 1.1, 25 Dec 2009
|
sawine@0
|
3 |
|
sawine@0
|
4 |
\RequirePackage{tikz-qtree}
|
sawine@0
|
5 |
|
sawine@0
|
6 |
\let\orig@Tree\Tree
|
sawine@0
|
7 |
\def\Tree{\automath \qtreeprimes@internal \orig@Tree}
|
sawine@0
|
8 |
|
sawine@0
|
9 |
\def\qsetw#1{\message{\noexpand\qsetw is not supported, sorry!}}
|
sawine@0
|
10 |
\def\faketreewidth#1{\message{\noexpand\faketreewidth is not supported, sorry!}}
|
sawine@0
|
11 |
\def\qbalance{\message{\noexpand\qbalance is not supported, sorry!}}
|
sawine@0
|
12 |
\def\qframesubtree{\message{\noexpand\qframesubtree is not supported, sorry!}}
|
sawine@0
|
13 |
|
sawine@0
|
14 |
% Implement \qroof as a fancy leaf node
|
sawine@0
|
15 |
\newtoks\@qrooflabel
|
sawine@0
|
16 |
|
sawine@0
|
17 |
\def\qroof#1.{%
|
sawine@0
|
18 |
\begin{tikzpicture}[baseline]
|
sawine@0
|
19 |
{\pgftransformshift{\pgftree@levelshift}%
|
sawine@0
|
20 |
\node(qroofbot){#1};}
|
sawine@0
|
21 |
\@qroof
|
sawine@0
|
22 |
}
|
sawine@0
|
23 |
\def\@qroof{\@ifnextchar\egroup{%
|
sawine@0
|
24 |
% since we are putting the qroof inside a node, we already have an inner sep
|
sawine@0
|
25 |
% so for the purposes of defining our bounding box, we must eliminate inner sep
|
sawine@0
|
26 |
\begin{pgfsubpicture}
|
sawine@0
|
27 |
\node [inner sep=0pt] {\the\@qrooflabel};%
|
sawine@0
|
28 |
\end{pgfsubpicture}
|
sawine@0
|
29 |
\pgfpathrectanglecorners{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}{\pgfpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}%
|
sawine@0
|
30 |
\pgfusepath{use as bounding box}%
|
sawine@0
|
31 |
\node (qrooftop) {\the\@qrooflabel};
|
sawine@0
|
32 |
\draw \roof@edge{qrooftop}{qroofbot};%
|
sawine@0
|
33 |
\end{tikzpicture}}
|
sawine@0
|
34 |
{\@@qroof}}
|
sawine@0
|
35 |
\def\@@qroof#1{\expandafter\@qrooflabel\expandafter{\the\@qrooflabel #1}\@qroof}
|
sawine@0
|
36 |
|
sawine@0
|
37 |
%%% This is lifted straight from qtree.sty
|
sawine@0
|
38 |
|
sawine@0
|
39 |
% and another odd convenience:
|
sawine@0
|
40 |
%
|
sawine@0
|
41 |
% Make _, ^ go into math mode automatically in the scope of \automath
|
sawine@0
|
42 |
%
|
sawine@0
|
43 |
{ % Temporarily change catcodes
|
sawine@0
|
44 |
\catcode`\_=\active
|
sawine@0
|
45 |
\catcode`\^=\active
|
sawine@0
|
46 |
|
sawine@0
|
47 |
\global\def\automath{%
|
sawine@0
|
48 |
\catcode`\_=\active
|
sawine@0
|
49 |
\catcode`\^=\active
|
sawine@0
|
50 |
\def_##1{\@ifnextchar^{\automath@two_{##1}}{\ensuremath{\sb{##1}}}}%
|
sawine@0
|
51 |
\def^##1{\@ifnextchar_{\automath@two^{##1}}{\ensuremath{\sp{##1}}}}}
|
sawine@0
|
52 |
}
|
sawine@0
|
53 |
\def\automath@two#1#2#3#4{\ensuremath{#1{#2}\relax #3{#4}}}
|
sawine@0
|
54 |
% Restore default catcodes for ^, _
|
sawine@0
|
55 |
\def\noautomath{\catcode`\_=8 \catcode`\^=7 }
|
sawine@0
|
56 |
|
sawine@0
|
57 |
|
sawine@0
|
58 |
% Let \0, \1, \2 produce ^0, $'$, $''$
|
sawine@0
|
59 |
% The \rlap results in better centering of the label (ignoring the
|
sawine@0
|
60 |
% superscript)
|
sawine@0
|
61 |
\def\qtreeprimes@internal{%
|
sawine@0
|
62 |
\def\0{\ifmmode ^0\else \rlap{$^0$}\fi}%
|
sawine@0
|
63 |
\def\1{\ifmmode '\else \rlap{$'$}\fi}%
|
sawine@0
|
64 |
\def\2{\ifmmode ''\else \rlap{$''$}\fi}%
|
sawine@0
|
65 |
}
|
sawine@0
|
66 |
|
sawine@0
|
67 |
% Same commands, but without the \rlap feature
|
sawine@0
|
68 |
\def\qtreeprimes{%
|
sawine@0
|
69 |
\def\0{\ensuremath{^0}}%
|
sawine@0
|
70 |
\def\1{\ensuremath{'}}%
|
sawine@0
|
71 |
\def\2{\ensuremath{''}}}
|
sawine@0
|
72 |
|