summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex')
-rw-r--r--Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex117
1 files changed, 115 insertions, 2 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex
index 8288a0797f6..19adb8db0fd 100644
--- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex
+++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex
@@ -1,4 +1,4 @@
-% Copyright 2006 by Till Tantau
+% Copyright 2019 by Till Tantau
%
% This file may be distributed and/or modified
%
@@ -413,7 +413,7 @@ The next set of styles can be used to change the appearance of certain rows,
columns, or cells. If more than one of these styles is defined, they are
executed in the below order (the |every cell| style is executed before all of
the below).
- %
+%
\begin{stylekey}{/tikz/column \meta{number}}
This style is used for every cell in column \meta{number}.
\end{stylekey}
@@ -475,6 +475,119 @@ different columns.
\end{tikzpicture}
\end{codeexample}
+In some cases, it is desirable to include some automation in each column/row
+separately. A typical example is to apply stripe-pattern to almost all columns
+with exceptions. For these type of use-cases, nesting these keys can open up
+a lot of possibilities; in the following example a ``feature comparison'' table
+is demonstrated. It is intentionally made rather verbose and a bit redundant
+to show how the column and row settings can be progressively overwritten to
+create certain effects.
+
+\begin{codeexample}[preamble={\usetikzlibrary{matrix,fit}}]
+\begin{tikzpicture}[
+ font=\sffamily,
+ striped col/.style={column #1/.append style={
+ every even row/.style={nodes={fill=olive!50}}}},
+ head color/.style args={#1/#2}{column #1/.append style={
+ row 1/.append style={nodes={fill=#2}}}}
+]
+
+\matrix [
+ matrix of nodes, nodes in empty cells,
+ nodes={text width=2cm, align=center,
+ minimum height=1.5em, anchor=center},
+ striped col/.list={1,...,5}, % add striped col style to all cols
+ column 1/.style={ % Override stripes and modify the feature column
+ row 1 column 1/.style={nodes={fill=none, draw=none}},
+ nodes={fill=olive, inner ysep=0},
+ },
+ % modify headers first via common styles and then specific colors
+ row 1/.style={nodes={text depth=0.2ex, text width=2cm, text=white}},
+ head color/.list={2/orange,3/teal,4/cyan,5/magenta}
+ ] (m)
+ {
+ & Basic & Standard & Professional & Enterprise \\
+ Feature A & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
+ Feature B & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ \\
+ Feature C & & & & $\bullet$ \\
+ Feature D & & $\bullet$ & $\bullet$ & $\bullet$ \\
+ Feature E & & & $\bullet$ & $\bullet$ \\
+ };
+% Add emphasis on selection by the use of "fit" library
+\node[fit={(m-1-4.north west) (m-6-4.south east)},
+ ultra thick, inner sep=0, rounded corners=1mm,
+ draw=cyan, label={[cyan,align=center]270:Popular\\Choice!}]{};
+\end{tikzpicture}
+\end{codeexample}
+
+The order in which these styles are applied is configurable. You can also
+install your own styles. The following styles (in fact, internally they are
+|/.code| keys) wrap the styles introduced in the previous paragraph passing the
+correct argument and ensuring that they are only called for even or odd rows.
+However, it is not recommended to override these.
+
+\begin{stylekey}{/tikz/matrix/inner style/every cell}
+ Wraps |/tikz/every cell|.
+\end{stylekey}
+\begin{stylekey}{/tikz/matrix/inner style/column}
+ Wraps |/tikz/column |\meta{number}.
+\end{stylekey}
+\begin{stylekey}{/tikz/matrix/inner style/even odd column}
+ Wraps |/tikz/every even column| and |/tikz/every odd column|.
+\end{stylekey}
+\begin{stylekey}{/tikz/matrix/inner style/row}
+ Wraps |/tikz/row |\meta{number}.
+\end{stylekey}
+\begin{stylekey}{/tikz/matrix/inner style/even odd row}
+ Wraps |/tikz/every even row| and |/tikz/every odd row|.
+\end{stylekey}
+\begin{stylekey}{/tikz/matrix/inner style/cell}
+ Wraps |/tikz/row |\meta{number}| column |\meta{number}.
+\end{stylekey}
+
+\begin{stylekey}{/tikz/matrix/inner style order}
+ The order in which these styles are applied to the matrix cells is
+ specified by this key. By default it is
+ %
+\begin{codeexample}[code only]
+\tikzset{
+ matrix/inner style order={
+ every cell,
+ column,
+ even odd column,
+ row,
+ even odd row,
+ cell
+ }
+}
+\end{codeexample}
+ %
+ You can use this to install your own styles here, but only \emph{names} of
+ styles are permitted here. The style specification has to be placed
+ outside of |matrix/inner style order| and unless it is installed inside
+ |/tikz/matrix/inner style/|, it has to be fully qualified.
+ %
+\begin{codeexample}[code only]
+\tikzset{
+ my style/.code={%
+ \ifnum\pgfmatrixcurrentcolumn=2
+ \tikzset{font=\itshape}%
+ \fi
+ },
+ matrix/inner style order={
+ every cell,
+ even odd column,
+ even odd row,
+ column,
+ row,
+ cell,
+ /tikz/my style
+ }
+}
+\end{codeexample}
+ %
+\end{stylekey}
+
In many matrices all cell pictures have nearly the same code. For example,
cells typically start with |\node{| and end |};|. The following options allow
you to execute such code in all cells: