summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/libraries/pgflibrarytikzmatrix.code.tex
blob: afb1393dffe86de8e0d04354dd5343eff0821ada (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibrarytikzmatrix.code.tex,v 1.5 2007/01/08 10:42:19 tantau Exp $


% A matrix of nodes contains a node in each cell.

\tikzstyle{matrix of nodes}=[%
   matrix,%
   cells={anchor=base},%
   nodes={%
     execute at begin node=,%
     execute at end node=,
     name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn%
   },
   execute at begin cell=\tikz@lib@matrix@start@cell,%
   execute at end cell=\tikz@lib@matrix@end@cell,%
   execute at empty cell=\tikz@lib@matrix@empty@cell
]

\def\tikz@lib@matrix@empty@cell{\iftikz@lib@matrix@empty\node{};\fi}

\newif\iftikz@lib@matrix@plain

\def\tikz@lib@matrix@start@cell{%
  \pgfutil@ifnextchar|{\tikz@lib@matrix@with@options}{\tikz@lib@matrix@normal@start@cell}}

\def\tikz@lib@matrix@with@options|#1|{\tikz@lib@matrix@plainfalse\node#1\bgroup}


\def\tikz@lib@matrix@normal@start@cell{\pgfutil@ifnextchar\let{\tikz@lib@matrix@check}{\tikz@lib@matrix@plainfalse\node\bgroup}}%

\def\tikz@lib@matrix@check#1{% evil hackery to find out about start of path
  \pgfutil@ifnextchar\tikz@signal@path{\tikz@lib@matrix@plaintrue\let}{\tikz@lib@matrix@plainfalse\node\bgroup\let}%
}
  
\def\tikz@lib@matrix@end@cell{%
  \iftikz@lib@matrix@plain%
  \else%
    \expandafter\egroup\expandafter;%
  \fi%    
}

% Fill empty nodes in a matrix of nodes

\newif\iftikz@lib@matrix@empty

\tikzoption{nodes in empty cells}[true]{\csname tikz@lib@matrix@empty#1\endcsname}


% Same as a matrix of nodes, but switch on math mode in each cell
\tikzstyle{matrix of math nodes}=[%
  matrix of nodes,
  nodes={%
   execute at begin node=$,%
   execute at end node=$%
  }%
]



% Provide a delimiter

\tikzoption{left delimiter}{\tikz@add@after@node@path{\tikz@delimiter%
    {south east}%
    {south west}%
    {every delimiter,every left delimiter}%
    {south}%
    {north}%
    {#1}%
    {.}%
    {\pgf@y}}}

\tikzoption{right delimiter}{\tikz@add@after@node@path{\tikz@delimiter%
    {south west}%
    {south east}%
    {every delimiter,every right delimiter}%
    {south}%
    {north}%
    {.}%
    {#1}%
    {\pgf@y}}}

\tikzoption{above delimiter}{\tikz@add@after@node@path{\tikz@delimiter%
    {south east}%
    {north west}%
    {every delimiter,every above delimiter,rotate=-90}%
    {west}%
    {east}%
    {#1}%
    {.}%
    {\pgf@x}}}

\tikzoption{below delimiter}{\tikz@add@after@node@path{\tikz@delimiter%
    {south west}%
    {south west}%
    {every delimiter,every below delimiter,rotate=-90}%
    {west}%
    {east}%
    {.}%
    {#1}%
    {\pgf@x}}}

\def\tikz@delimiter#1#2#3#4#5#6#7#8{%
  \bgroup
    \pgfextra{\let\tikz@save@last@fig@name=\tikz@last@fig@name}%
    node[outer sep=0pt,inner sep=0pt,draw=none,fill=none,anchor=#1,at=(\tikz@last@fig@name.#2),#3]
    {%
      {\nullfont\pgf@process{\pgfpointdiff{\pgfpointanchor{\tikz@last@fig@name}{#4}}{\pgfpointanchor{\tikz@last@fig@name}{#5}}}}%
      $\left#6\vcenter{\hrule height .5#8 depth .5#8 width0pt}\right#7$%
    }
    \pgfextra{\global\let\tikz@last@fig@name=\tikz@save@last@fig@name}%
  \egroup%
}

\tikzstyle{every delimiter}=[]
\tikzstyle{every left delimiter}=[]
\tikzstyle{every right delimiter}=[]
\tikzstyle{every above delimiter}=[]
\tikzstyle{every below delimiter}=[]

\endinput