summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-qtree/tikz-qtree-compat.sty
blob: f60ae32838b705c90a73d5909db346ed813efd4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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{''}}}