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