Skip to content

Commit

Permalink
docs: simplify the stripe-pattern matrix example
Browse files Browse the repository at this point in the history
Signed-off-by: muzimuzhi <[email protected]>
  • Loading branch information
muzimuzhi committed Sep 22, 2023
1 parent 6e5fd71 commit 52ecf8c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions doc/generic/pgf/pgfmanual-en-tikz-matrices.tex
Original file line number Diff line number Diff line change
Expand Up @@ -486,24 +486,28 @@ \subsubsection{Cell Styles and Options}
\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}}}}
head color/.style args={#1/#2}{
row 1 column #1/.append style={nodes={fill=#2}}},
% swap order of row and column styles
matrix/inner style order={
every cell,
row, even odd row,
column, even odd column,
cell
}
]

\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}
% add striped row style
every even row/.style={nodes={fill=olive!50}},
% modify the feature column and header row
column 1/.style= {nodes={fill=olive, inner ysep=0}},
row 1/.style= {nodes={text depth=0.2ex, text=white}},
row 1 column 1/.style={nodes={fill=none, draw=none}},
head color/.list={2/orange,3/teal,4/cyan,5/magenta} % specify header colors
] (m)
{
& Basic & Standard & Professional & Enterprise \\
Expand All @@ -515,7 +519,7 @@ \subsubsection{Cell Styles and Options}
};
% 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,
ultra thick, inner sep=0pt, rounded corners=1mm,
draw=cyan, label={[cyan,align=center]270:Popular\\Choice!}]{};
\end{tikzpicture}
\end{codeexample}
Expand Down

0 comments on commit 52ecf8c

Please sign in to comment.