summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-qtree/tikz-qtree-compat.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/pgf/contrib/tikz-qtree/tikz-qtree-compat.sty
Initial commit
Diffstat (limited to 'graphics/pgf/contrib/tikz-qtree/tikz-qtree-compat.sty')
-rw-r--r--graphics/pgf/contrib/tikz-qtree/tikz-qtree-compat.sty72
1 files changed, 72 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/tikz-qtree/tikz-qtree-compat.sty b/graphics/pgf/contrib/tikz-qtree/tikz-qtree-compat.sty
new file mode 100644
index 0000000000..f60ae32838
--- /dev/null
+++ b/graphics/pgf/contrib/tikz-qtree/tikz-qtree-compat.sty
@@ -0,0 +1,72 @@
+% tikz-qtree-compat.tex
+% Version 1.1, 25 Dec 2009
+
+\RequirePackage{tikz-qtree}
+
+\let\orig@Tree\Tree
+\def\Tree{\automath \qtreeprimes@internal \orig@Tree}
+
+\def\qsetw#1{\message{\noexpand\qsetw is not supported, sorry!}}
+\def\faketreewidth#1{\message{\noexpand\faketreewidth is not supported, sorry!}}
+\def\qbalance{\message{\noexpand\qbalance is not supported, sorry!}}
+\def\qframesubtree{\message{\noexpand\qframesubtree is not supported, sorry!}}
+
+% Implement \qroof as a fancy leaf node
+\newtoks\@qrooflabel
+
+\def\qroof#1.{%
+\begin{tikzpicture}[baseline]
+{\pgftransformshift{\pgftree@levelshift}%
+\node(qroofbot){#1};}
+\@qroof
+}
+\def\@qroof{\@ifnextchar\egroup{%
+% since we are putting the qroof inside a node, we already have an inner sep
+% so for the purposes of defining our bounding box, we must eliminate inner sep
+\begin{pgfsubpicture}
+\node [inner sep=0pt] {\the\@qrooflabel};%
+\end{pgfsubpicture}
+\pgfpathrectanglecorners{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}{\pgfpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}%
+\pgfusepath{use as bounding box}%
+\node (qrooftop) {\the\@qrooflabel};
+\draw \roof@edge{qrooftop}{qroofbot};%
+\end{tikzpicture}}
+{\@@qroof}}
+\def\@@qroof#1{\expandafter\@qrooflabel\expandafter{\the\@qrooflabel #1}\@qroof}
+
+%%% This is lifted straight from qtree.sty
+
+% 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{''}}}
+