Skip to content

Commit

Permalink
Support styling of outer \pgfmatrix node #627
Browse files Browse the repository at this point in the history
This is a bit ugly because it uses a callback.  The proper way would
have been to separate \pgfmatrix into \pgfcollectmatrix and
\pgfplacematrix, but we cannot break the API because this command is so
old and widely used.
  • Loading branch information
hmenke committed Nov 5, 2019
1 parent 6fa03ff commit 3cf7276
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ \subsection{Matrices are Nodes}
\begin{stylekey}{/tikz/every matrix (initially \normalfont empty)}
This style is used in every matrix.
\end{stylekey}
%
\begin{stylekey}{/tikz/every outer matrix (initially \normalfont empty)}
While the |every matrix| key also applies to the matrix contents, this
only applies to the outer node which holds the matrix.
\end{stylekey}
\end{key}

Even more so than nodes, matrices will often be the only object on a path.
Expand Down
1 change: 1 addition & 0 deletions tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4029,6 +4029,7 @@
\def\tikz@matrix@shift{\pgfpointorigin}%
\fi%
\let\tikz@transform=\relax%
\pgfmatrixbeforeassemblenode{\tikzset{every outer matrix/.try}}%
\pgfmatrix%
{\tikz@shape}%
{\tikz@m@anchor}%
Expand Down
8 changes: 8 additions & 0 deletions tex/generic/pgf/modules/pgfmodulematrix.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
\let\pgf@matrix@cell=\pgfnodeparttextbox % alias
\let\pgf@matrix@box=\pgf@matrix@cell % alias

\long\def\pgfmatrixbeforeassemblenode#1{%
\long\def\pgf@matrix@before@assemnble@node{#1}}
\pgfmatrixbeforeassemblenode{}

% Sets the default row or column sep
%
Expand Down Expand Up @@ -211,6 +214,11 @@
\egroup\egroup%
\egroup%
%
% Inject custom tokens before assembling the node holding the matrix. Can
% be used to apply additional settings.
%
\pgf@matrix@before@assemnble@node
%
% If there are named nodes, we must adjust their coordinates.
%
\ifx\pgf@matrix@node@list\pgfutil@empty%
Expand Down

0 comments on commit 3cf7276

Please sign in to comment.