sawine@9: % tikz-qtree-compat.tex sawine@9: % Version 1.1, 25 Dec 2009 sawine@9: sawine@9: \RequirePackage{tikz-qtree} sawine@9: sawine@9: \let\orig@Tree\Tree sawine@9: \def\Tree{\automath \qtreeprimes@internal \orig@Tree} sawine@9: sawine@9: \def\qsetw#1{\message{\noexpand\qsetw is not supported, sorry!}} sawine@9: \def\faketreewidth#1{\message{\noexpand\faketreewidth is not supported, sorry!}} sawine@9: \def\qbalance{\message{\noexpand\qbalance is not supported, sorry!}} sawine@9: \def\qframesubtree{\message{\noexpand\qframesubtree is not supported, sorry!}} sawine@9: sawine@9: % Implement \qroof as a fancy leaf node sawine@9: \newtoks\@qrooflabel sawine@9: sawine@9: \def\qroof#1.{% sawine@9: \begin{tikzpicture}[baseline] sawine@9: {\pgftransformshift{\pgftree@levelshift}% sawine@9: \node(qroofbot){#1};} sawine@9: \@qroof sawine@9: } sawine@9: \def\@qroof{\@ifnextchar\egroup{% sawine@9: % since we are putting the qroof inside a node, we already have an inner sep sawine@9: % so for the purposes of defining our bounding box, we must eliminate inner sep sawine@9: \begin{pgfsubpicture} sawine@9: \node [inner sep=0pt] {\the\@qrooflabel};% sawine@9: \end{pgfsubpicture} sawine@9: \pgfpathrectanglecorners{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}{\pgfpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}% sawine@9: \pgfusepath{use as bounding box}% sawine@9: \node (qrooftop) {\the\@qrooflabel}; sawine@9: \draw \roof@edge{qrooftop}{qroofbot};% sawine@9: \end{tikzpicture}} sawine@9: {\@@qroof}} sawine@9: \def\@@qroof#1{\expandafter\@qrooflabel\expandafter{\the\@qrooflabel #1}\@qroof} sawine@9: sawine@9: %%% This is lifted straight from qtree.sty sawine@9: sawine@9: % and another odd convenience: sawine@9: % sawine@9: % Make _, ^ go into math mode automatically in the scope of \automath sawine@9: % sawine@9: { % Temporarily change catcodes sawine@9: \catcode`\_=\active sawine@9: \catcode`\^=\active sawine@9: sawine@9: \global\def\automath{% sawine@9: \catcode`\_=\active sawine@9: \catcode`\^=\active sawine@9: \def_##1{\@ifnextchar^{\automath@two_{##1}}{\ensuremath{\sb{##1}}}}% sawine@9: \def^##1{\@ifnextchar_{\automath@two^{##1}}{\ensuremath{\sp{##1}}}}} sawine@9: } sawine@9: \def\automath@two#1#2#3#4{\ensuremath{#1{#2}\relax #3{#4}}} sawine@9: % Restore default catcodes for ^, _ sawine@9: \def\noautomath{\catcode`\_=8 \catcode`\^=7 } sawine@9: sawine@9: sawine@9: % Let \0, \1, \2 produce ^0, $'$, $''$ sawine@9: % The \rlap results in better centering of the label (ignoring the sawine@9: % superscript) sawine@9: \def\qtreeprimes@internal{% sawine@9: \def\0{\ifmmode ^0\else \rlap{$^0$}\fi}% sawine@9: \def\1{\ifmmode '\else \rlap{$'$}\fi}% sawine@9: \def\2{\ifmmode ''\else \rlap{$''$}\fi}% sawine@9: } sawine@9: sawine@9: % Same commands, but without the \rlap feature sawine@9: \def\qtreeprimes{% sawine@9: \def\0{\ensuremath{^0}}% sawine@9: \def\1{\ensuremath{'}}% sawine@9: \def\2{\ensuremath{''}}} sawine@9: