summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-08-25 23:02:19 +0000
committerKarl Berry <karl@freefriends.org>2016-08-25 23:02:19 +0000
commitd685e6e33e852028b8bf79788ef8d7f47257849e (patch)
tree2833de4c70498c650a65ab36e7622a06d1a5f0b4 /Master
parentb4ca047b96a502350b025c4541bc5d479b2f86f3 (diff)
drawmatrix (25aug16)
git-svn-id: svn://tug.org/texlive/trunk@41928 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdfbin278598 -> 282790 bytes
-rw-r--r--Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx262
-rw-r--r--Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins4
-rw-r--r--Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty155
4 files changed, 259 insertions, 162 deletions
diff --git a/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf b/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf
index a672724f8c7..95c19832407 100644
--- a/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf
+++ b/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx b/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx
index eaa0ef2dd42..857bc15ac4c 100644
--- a/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx
+++ b/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2015 by Elmar Peise
+% Copyright (C) 2016 by Elmar Peise
% -----------------------------------------
%
% This package is distributed under the MIT license.
@@ -9,7 +9,7 @@
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
-%<package>\ProvidesPackage{drawmatrix}[2015/11/26 v1.1.0 drawmatrix package]
+%<package>\ProvidesPackage{drawmatrix}[2016/08/25 v1.2.0 drawmatrix package]
%
%<*driver>
\documentclass{ltxdoc}
@@ -52,6 +52,8 @@
% \changes{v1.1.0}{2015/11/26}{Separate lower and upper banding, externalization
% control, fixed matrix style collection, lots of simplifications, moved
% ``every'' keys to |/drawmatrix| path}
+% \changes{v1.1.1}{2016/01/29}{Bugfix: Remove extra space after vectors}
+% \changes{v1.2.0}{2016/01/29}{Add coordinate transformations}
%
%
% \GetFileInfo{drawmatrix.sty}
@@ -129,15 +131,16 @@
% \subsection{Size}
% By default, matrices are $1 \times 1$ large in terms of \TikZ units. The
% width and height of a matrix are set through, respectively,
-% \DescribeMacro{height} |width=|\meta{expr} and \DescribeMacro{width}
-% |height=|\meta{expr}. A width or height of 0 are useful to represent vectors:
+% \DescribeMacro{height} |width=|\meta{dimension} and \DescribeMacro{width}
+% |height=|\meta{dimension}. A width or height of 0 are useful to represent
+% vectors:
% \begin{example}
% |\drawmatrix[width=0]A|:
% \drawmatrix[width=0]A
% \end{example}
%
-% \DescribeMacro{size} |size=|\meta{expr} sets both the width and height to
-% \meta{expr}, resulting in a square matrix.
+% \DescribeMacro{size} |size=|\meta{dimension} sets both the width and height to
+% \meta{dimension}, resulting in a square matrix.
%
% \subsection{Shape}
% By default matrices are rectangular.
@@ -156,8 +159,8 @@
% \subsubsection{Banded Matrices}
% Matrices are drawn as banded through the key \DescribeMacro{banded} |banded|.
% The band width, i.e., the horizontal/vertical extent from the diagonal, is
-% specified through \DescribeMacro{bandwidth} |bandwidth=|\meta{expra (default:
-% 0.3)};
+% specified through \DescribeMacro{bandwidth} |bandwidth=|\meta{dimension}
+% (default: 0.3);
% \begin{example}
% |\drawmatrix[banded]B|:
% \drawmatrix[banded]B
@@ -169,8 +172,8 @@
% Banding for the lower and upper part of the matrices can be specified
% separately through \DescribeMacro{lower banded} |lower banded| and
% \DescribeMacro{upper banded} |upper banded|. Separate bandwidths are set
-% through \DescribeMacro{lower bandwidth} |lower bandwidth=|\meta{expr} and
-% \DescribeMacro{upper bandwidth} |upper bandwidth=|\meta{expr}:
+% through \DescribeMacro{lower bandwidth} |lower bandwidth=|\meta{dimension} and
+% \DescribeMacro{upper bandwidth} |upper bandwidth=|\meta{dimension}:
% \begin{example}
% |\drawmatrix[lower banded]B|:
% \drawmatrix[lower banded]B
@@ -226,12 +229,13 @@
% \end{example}
%
% By default, the bounding box is just large enough to contain the matrix. Its
-% size is changed through the keys \DescribeMacro{bbox height}
-% |bbox height=|\meta{expr} and \DescribeMacro{bbox width}
-% |bbox width=|\meta{expr} (or \DescribeMacro{bbox size} |bbox size=|\meta{expr}
-% to set them both). The label of the matrix (and thus the alignment with
-% respect to the surrounding text) are fixed at the center of the bounding box,
-% while the matrix is positioned at its top-left corner.
+% size is changed through the keys \DescribeMacro{bbox height}
+% |bbox height=|\meta{dimension} and \DescribeMacro{bbox width}
+% |bbox width=|\meta{dimension} (or \DescribeMacro{bbox size}
+% |bbox size=|\meta{dimension} to set them both). The label of the matrix (and
+% thus the alignment with respect to the surrounding text) are fixed at the
+% center of the bounding box, while the matrix is positioned at its top-left
+% corner.
% \begin{example}
% |\drawmatrixset{bbox style={fill=blue!10}}|
% \drawmatrixset{bbox style={fill=blue!10}}
@@ -241,9 +245,9 @@
% \end{example}
%
% \sloppy The matrix can be positioned within its bounding box through
-% \DescribeMacro{offset height} |offset height=|\meta{expr} and
-% \DescribeMacro{offset width} |offset width=|\meta{expr} (or just
-% \DescribeMacro{offset} |offset=|\meta{expr} to shift along the diagonal).
+% \DescribeMacro{offset height} |offset height=|\meta{dimension} and
+% \DescribeMacro{offset width} |offset width=|\meta{dimension} (or just
+% \DescribeMacro{offset} |offset=|\meta{dimension} to shift along the diagonal).
% \begin{example}
% |\drawmatrixset{bbox style={fill=blue!10}}|
% \drawmatrixset{bbox style={fill=blue!10}}
@@ -252,6 +256,22 @@
% \drawmatrix[bbox size=2, offset width=.5, offset height=.75]A
% \end{example}
%
+% \subsection{Coordinate system transformations}
+%
+% |scale=|\meta{factor} scales all dimensions passed to a matrix:
+% \begin{example}
+% |\drawmatrix[scale=.6]A \drawmatrix[scale=.6, width=.5]B|:
+% \drawmatrix[scale=.6]A \drawmatrix[scale=.6, width=.5]B
+% \end{example}
+%
+% |x=|\meta{value} and |y=|\meta{value} define the coordinate system for all
+% unit-less dimensions.
+% \begin{example}
+% |\drawmatrix[x=.6cm, y=.4cm]A \drawmatrix[x=.6cm, y=.4cm, width=1cm]B|:
+% \drawmatrix[x=.6cm, y=.4cm]A \drawmatrix[x=.6cm, y=.4cm, width=1cm]B
+% \end{example}
+%
+%
% \subsection{Position of the Label and Baseline}
% By default, the label's |mid| is positioned at the bounding box's |center| and
% its |base| is used as the whole drawing's baseline. This is controlled by the
@@ -318,14 +338,15 @@
% \section{Implementation}
%
% \DoNotIndex{
-% \@bboxheight, \@bboxwidth, \@currname, \@currval, \@height, \@labeltext,
-% \@lowerbandwidth, \@minsize, \@offsetheight, \@offsetwidth,
-% \@upperbandwidth, \@width, \@zero, \RequirePackage, \begin, \def, \edef,
-% \else, \end, \expandafter, \fi, \filldraw, \ifdrawmatrix@externalize,
-% \ifmmode, \ifx, \let, \newcommand, \newif, \node, \path, \pgfkeys,
-% \pgfkeysalso, \pgfkeyscurrentname, \pgfkeyscurrentvalue, \pgfkeysnovalue,
-% \pgflinewidth, \pgfmathsetmacro, \pgfqkeys, \tikz@library@external@loaded,
-% \tikzset, \undefined,
+% \dm@bboxheight, \dm@bboxwidth, \dm@currname, \dm@currval, \dm@height,
+% \dm@labeltext, \dm@lowerbandwidth, \dm@minsize, \dm@offsetheight,
+% \dm@offsetwidth, \dm@upperbandwidth, \dm@width, \dm@zero, \RequirePackage,
+% \begin, \def, \edef, \else, \end, \expandafter, \fi, \filldraw,
+% \ifdrawmatrix@externalize, \ifmmode, \ifx, \let, \newcommand, \newif, \node,
+% \path, \pgfkeys, \pgfkeysalso, \pgfkeyscurrentname, \pgfkeyscurrentvalue,
+% \pgfkeysnovalue, \pgflinewidth, \pgfgetlastxy, \pgfmathsetlengthmacro,
+% \pgfresetboundingbox, \pgfqkeys, \tikz@library@external@loaded, \tikzset,
+% \undefined
% }
%
% This section describes the implementation details of the \textsf{drawmatrix}
@@ -367,7 +388,11 @@
% matrix (default: base of the label).
% \begin{macrocode}
picture/.style={},
+ path/.style={},
baseline/.style={picture/.append style={baseline=(drawmatrix #1)}},
+ scale/.style={path/.append style={scale=#1}},
+ x/.style={path/.append style={x=#1}},
+ y/.style={path/.append style={y=#1}},
baseline=label.base,
% \end{macrocode}
% \end{macro}\end{macro}
@@ -465,12 +490,12 @@
% \begin{macro}{label pos}
% \begin{macro}{label anchor}
% |label| is the style for the label. |label pos| sets the label at a named
-% coordinate of the matrix (default: center of the bounding box).
+% coordinate of the matrix (default: center of the bounding box).
% |label anchor| sets the label's |anchor| (default: in the middle).
% \begin{macrocode}
label/.style={},
label pos/.style={label/.append style={at=(drawmatrix #1)}},
- label pos=bbox.center,
+ label pos=bbox.center,
label anchor/.style={label/.append style={anchor=#1}},
label anchor=mid,
% \end{macrocode}
@@ -480,13 +505,13 @@
% \begin{macrocode}
drawmatrix/.style={},
.unknown/.code={%
- \let\@currname\pgfkeyscurrentname%
- \let\@currval\pgfkeyscurrentvalue%
+ \let\dm@currname\pgfkeyscurrentname%
+ \let\dm@currval\pgfkeyscurrentvalue%
\ifx#1\pgfkeysnovalue\pgfkeysalso{
- drawmatrix/.append style/.expand once={\@currname}
+ drawmatrix/.append style/.expand once={\dm@currname}
}\else\pgfkeysalso{
drawmatrix/.append style/.expand twice={%
- \expandafter\@currname\expandafter=\@currval%
+ \expandafter\dm@currname\expandafter=\dm@currval%
}
}\fi%
},
@@ -514,6 +539,12 @@
name=drawmatrix label,
outer sep=0,
inner sep=0,
+ },
+ every node/.style={
+ name=drawmatrix matrix,
+ outer sep=0,
+ inner sep=0,
+ anchor=north west,
}
}
% \end{macrocode}
@@ -528,133 +559,160 @@
% \end{macrocode}
% \end{macro}
%
-% Here we go, the main thing: |\drawmatrix|. First, check if we are in math
-% mode and apply the options.
+% Here we go, the main thing: |\drawmatrix|. First, apply the options and
+% extract the sizes from the PGF keys.
% \begin{macro}{\drawmatrix}
% \begin{macrocode}
\newcommand\drawmatrix[2][]{{%
- \ifmmode\def\@labeltext{$#2$}\else\def\@labeltext{#2}\fi%
- \drawmatrixset{#1}%
+ \drawmatrixset{
+ #1,
+ height/.get=\dm@height,
+ width/.get=\dm@width,
+ lower bandwidth/.get=\dm@lowerbandwidth,
+ upper bandwidth/.get=\dm@upperbandwidth,
+ offset height/.get=\dm@offsetheight,
+ offset width/.get=\dm@offsetwidth,
+ bbox height/.get=\dm@bboxheight,
+ bbox width/.get=\dm@bboxwidth,
+ }%
% \end{macrocode}
%
-% Disable externalization if |externalize=false|.
+% Prepare the label text (keep math mode).
+% \begin{macrocode}
+ \ifmmode\def\dm@labeltext{$#2$}\else\def\dm@labeltext{#2}\fi%
+% \end{macrocode}
%
+% Disable externalization if |externalize=false|. Start the picture.
% \begin{macrocode}
\ifdrawmatrix@externalize\else%
\ifx\tikz@library@external@loaded\undefined\else%
\tikzset{external/export=false}%
\fi%
\fi%
+ \begin{tikzpicture}[/drawmatrix/every picture, /drawmatrix/picture]
% \end{macrocode}
%
-% Extract the sizes from the PGF keys and parse width, height, the minimum
-% dimension and zero for comparison purposes.
-%
+% Parse width, height, the minimum dimension and zero for comparison purposes.
% \begin{macrocode}
- \pgfqkeys{/drawmatrix}{
- height/.get=\@height,
- width/.get=\@width,
- lower bandwidth/.get=\@lowerbandwidth,
- upper bandwidth/.get=\@upperbandwidth,
- offset height/.get=\@offsetheight,
- offset width/.get=\@offsetwidth,
- bbox height/.get=\@bboxheight,
- bbox width/.get=\@bboxwidth,
- }%
- \pgfmathsetmacro\@height{\@height + 0.0}%
- \pgfmathsetmacro\@width{\@width + 0.0}%
- \pgfmathsetmacro\@minsize{min(\@width, \@height)}%
- \pgfmathsetmacro\@zero{0.0}%
+ \path[/drawmatrix/path] (\dm@width, \dm@height);
+ \pgfgetlastxy\dm@width\dm@height
+ \path[/drawmatrix/path] (\dm@offsetwidth, \dm@offsetheight);
+ \pgfgetlastxy\dm@offsetwidth\dm@offsetheight
+ \pgfmathsetlengthmacro\dm@minsize{min(\dm@width, \dm@height)}
+ \pgfmathsetlengthmacro\dm@zero{0.0}
% \end{macrocode}
%
% Prepare the band widths: First, if the matrix is not banded, the bandwidth is
% set to the smaller matrix dimension. Then, the band width is limited by this
% smaller dimension.
-%
% \begin{macrocode}
- \expandafter\ifx\@lowerbandwidth\pgfkeysnovalue%
- \edef\@lowerbandwidth{\@minsize}%
- \fi%
- \expandafter\ifx\@upperbandwidth\pgfkeysnovalue%
- \edef\@upperbandwidth{\@minsize}%
- \fi%
- \pgfmathsetmacro\@lowerbandwidth{min(\@minsize, \@lowerbandwidth)}%
- \pgfmathsetmacro\@upperbandwidth{min(\@minsize, \@upperbandwidth)}%
+ \expandafter\ifx\dm@lowerbandwidth\pgfkeysnovalue
+ \edef\dm@lowerbandwidth{\dm@minsize}
+ \else
+ \path[/drawmatrix/path] (\dm@lowerbandwidth, 0);
+ \pgfgetlastxy\dm@lowerbandwidth\dm@zero
+ \fi
+ \expandafter\ifx\dm@upperbandwidth\pgfkeysnovalue
+ \edef\dm@upperbandwidth{\dm@minsize}
+ \else
+ \path[/drawmatrix/path] (0, \dm@upperbandwidth);
+ \pgfgetlastxy\dm@zero\dm@upperbandwidth
+ \fi
+ \pgfmathsetlengthmacro\dm@lowerbandwidth{
+ min(\dm@minsize, \dm@lowerbandwidth)
+ }
+ \pgfmathsetlengthmacro\dm@upperbandwidth{
+ min(\dm@minsize, \dm@upperbandwidth)
+ }
% \end{macrocode}
%
% Set the default bounding box size.
-%
% \begin{macrocode}
- \expandafter\ifx\@bboxheight\pgfkeysnovalue%
- \pgfmathsetmacro\@bboxheight{\@height + \@offsetheight}%
- \fi%
- \expandafter\ifx\@bboxwidth\pgfkeysnovalue%
- \pgfmathsetmacro\@bboxwidth{\@width + \@offsetwidth}%
- \fi%
+ \expandafter\ifx\dm@bboxheight\pgfkeysnovalue
+ \pgfmathsetlengthmacro\dm@bboxheight{
+ \dm@height + \dm@offsetheight
+ }
+ \else
+ \path[/drawmatrix/path] (0, \dm@bboxheight);
+ \pgfgetlastxy\dm@zero\dm@bboxheight
+ \fi
+ \expandafter\ifx\dm@bboxwidth\pgfkeysnovalue
+ \pgfmathsetlengthmacro\dm@bboxwidth{
+ \dm@width + \dm@offsetwidth
+ }
+ \else
+ \path[/drawmatrix/path] (\dm@bboxwidth, 0);
+ \pgfgetlastxy\dm@bboxwidth\dm@zero
+ \fi
% \end{macrocode}
%
-% Begin with (drawing) the path for the bounding box.
-%
+% Reset the bounding box and begin with (drawing) the path for the bounding box.
% \begin{macrocode}
- \begin{tikzpicture}[/drawmatrix/every picture, /drawmatrix/picture]
+ \pgfresetboundingbox
\node[/drawmatrix/every bbox, /drawmatrix/bbox,
- minimum height=\@bboxheight cm,
- minimum width=\@bboxwidth cm] {};
+ minimum height=\dm@bboxheight,
+ minimum width=\dm@bboxwidth] {};
% \end{macrocode}
%
% Whether needed or not, declare all matrix corners.
% \begin{macrocode}
\path (drawmatrix bbox.north west)
- ++(\@offsetwidth, -\@offsetheight)
+ ++(\dm@offsetwidth, -\dm@offsetheight)
++(.5\pgflinewidth, -.5\pgflinewidth)
coordinate (drawmatrix north west)
- ++(\@width, 0)
- +(-\@minsize + \@upperbandwidth, 0)
+ ++(\dm@width, 0)
+ +(-\dm@minsize + \dm@upperbandwidth, 0)
coordinate (drawmatrix north)
- +(0, -\@minsize + \@upperbandwidth)
+ +(0, -\dm@minsize + \dm@upperbandwidth)
coordinate (drawmatrix east)
- ++(0, -\@height)
+ ++(0, -\dm@height)
coordinate (drawmatrix south east)
- ++(-\@width, 0)
- +(\@minsize - \@lowerbandwidth, 0)
+ ++(-\dm@width, 0)
+ +(\dm@minsize - \dm@lowerbandwidth, 0)
coordinate (drawmatrix south)
- +(0, \@minsize - \@lowerbandwidth)
+ +(0, \dm@minsize - \dm@lowerbandwidth)
coordinate (drawmatrix west);
% \end{macrocode}
%
+% Add an invisible node the size of the matrix.
+% \begin{macrocode}
+ \node[/drawmatrix/every node,
+ minimum height=\dm@height,
+ minimum width=\dm@width]
+ at (drawmatrix north west) {};
+% \end{macrocode}
+%
% Now, draw only what is needed of the matrix. Otherwise path modifications
-% (e.g.,such as rounded corners) might not work.
+% (e.g., such as rounded corners) might not work.
% \begin{macrocode}
\filldraw[/drawmatrix/every drawmatrix, /drawmatrix/drawmatrix]
- (drawmatrix north west)
- \ifx\@upperbandwidth\@zero
- \ifx\@width\@minsize\else -- (drawmatrix north) \fi
- \ifx\@height\@minsize\else -- (drawmatrix east) \fi
+ (drawmatrix north west)
+ \ifx\dm@upperbandwidth\dm@zero
+ \ifx\dm@width\dm@minsize\else -- (drawmatrix north) \fi
+ \ifx\dm@height\dm@minsize\else -- (drawmatrix east) \fi
\else
-- (drawmatrix north)
- \ifx\@upperbandwidth\@minsize\else -- (drawmatrix east) \fi
+ \ifx\dm@upperbandwidth\dm@minsize\else
+ -- (drawmatrix east)
+ \fi
\fi
-- (drawmatrix south east)
- \ifx\@lowerbandwidth\@zero
- \ifx\@width\@minsize\else -- (drawmatrix south) \fi
- \ifx\@height\@minsize\else -- (drawmatrix west) \fi
+ \ifx\dm@lowerbandwidth\dm@zero
+ \ifx\dm@width\dm@minsize\else -- (drawmatrix south) \fi
+ \ifx\dm@height\dm@minsize\else -- (drawmatrix west) \fi
\else
-- (drawmatrix south)
- \ifx\@lowerbandwidth\@minsize\else -- (drawmatrix west) \fi
+ \ifx\dm@lowerbandwidth\dm@minsize\else
+ -- (drawmatrix west)
+ \fi
\fi
-- cycle;
% \end{macrocode}
%
-% Add an invisible node the size of the matrix.
-% \begin{macrocode}
- \node[minimum height=\@height cm, minimum width=\@width cm,
- anchor=north west] at (drawmatrix north west)
- (drawmatrix matrix) {};
-% \end{macrocode}
-%
% The label.
% \begin{macrocode}
- \node[/drawmatrix/every label, /drawmatrix/label] {\@labeltext};
+ \node[/drawmatrix/every label, /drawmatrix/label]
+ {\dm@labeltext};
\end{tikzpicture}%
}}
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins b/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins
index f24c7ef9496..14162f3beb1 100644
--- a/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins
+++ b/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins
@@ -1,5 +1,5 @@
%%
-%% Copyright (C) 2015 by Elmar Peise
+%% Copyright (C) 2016 by Elmar Peise
%%
%% This package is distributed under the MIT license.
%%
@@ -12,7 +12,7 @@
This is a generated file.
-Copyright (C) 2015 by Elmar Peise
+Copyright (C) 2016 by Elmar Peise
This package is distributed under the MIT license.
diff --git a/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty b/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty
index 1fa5fc7afb3..a79f4c1a82e 100644
--- a/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty
+++ b/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty
@@ -8,19 +8,23 @@
%%
%% This is a generated file.
%%
-%% Copyright (C) 2015 by Elmar Peise
+%% Copyright (C) 2016 by Elmar Peise
%%
%% This package is distributed under the MIT license.
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesPackage{drawmatrix}[2015/11/26 v1.1.0 drawmatrix package]
+\ProvidesPackage{drawmatrix}[2016/08/25 v1.2.0 drawmatrix package]
\RequirePackage{tikz}
\newif\ifdrawmatrix@externalize
\pgfkeys{
drawmatrix/.is family,
drawmatrix/.cd,
picture/.style={},
+ path/.style={},
baseline/.style={picture/.append style={baseline=(drawmatrix #1)}},
+ scale/.style={path/.append style={scale=#1}},
+ x/.style={path/.append style={x=#1}},
+ y/.style={path/.append style={y=#1}},
baseline=label.base,
bbox/.style={},
bbox style/.style={bbox/.append style={#1}},
@@ -51,13 +55,13 @@
label anchor=mid,
drawmatrix/.style={},
.unknown/.code={%
- \let\@currname\pgfkeyscurrentname%
- \let\@currval\pgfkeyscurrentvalue%
+ \let\dm@currname\pgfkeyscurrentname%
+ \let\dm@currval\pgfkeyscurrentvalue%
\ifx#1\pgfkeysnovalue\pgfkeysalso{
- drawmatrix/.append style/.expand once={\@currname}
+ drawmatrix/.append style/.expand once={\dm@currname}
}\else\pgfkeysalso{
drawmatrix/.append style/.expand twice={%
- \expandafter\@currname\expandafter=\@currval%
+ \expandafter\dm@currname\expandafter=\dm@currval%
}
}\fi%
},
@@ -74,87 +78,122 @@
name=drawmatrix label,
outer sep=0,
inner sep=0,
+ },
+ every node/.style={
+ name=drawmatrix matrix,
+ outer sep=0,
+ inner sep=0,
+ anchor=north west,
}
}
\newcommand\drawmatrixset[1]{\pgfqkeys{/drawmatrix}{#1}}
\newcommand\drawmatrix[2][]{{%
- \ifmmode\def\@labeltext{$#2$}\else\def\@labeltext{#2}\fi%
- \drawmatrixset{#1}%
+ \drawmatrixset{
+ #1,
+ height/.get=\dm@height,
+ width/.get=\dm@width,
+ lower bandwidth/.get=\dm@lowerbandwidth,
+ upper bandwidth/.get=\dm@upperbandwidth,
+ offset height/.get=\dm@offsetheight,
+ offset width/.get=\dm@offsetwidth,
+ bbox height/.get=\dm@bboxheight,
+ bbox width/.get=\dm@bboxwidth,
+ }%
+ \ifmmode\def\dm@labeltext{$#2$}\else\def\dm@labeltext{#2}\fi%
\ifdrawmatrix@externalize\else%
\ifx\tikz@library@external@loaded\undefined\else%
\tikzset{external/export=false}%
\fi%
\fi%
- \pgfqkeys{/drawmatrix}{
- height/.get=\@height,
- width/.get=\@width,
- lower bandwidth/.get=\@lowerbandwidth,
- upper bandwidth/.get=\@upperbandwidth,
- offset height/.get=\@offsetheight,
- offset width/.get=\@offsetwidth,
- bbox height/.get=\@bboxheight,
- bbox width/.get=\@bboxwidth,
- }%
- \pgfmathsetmacro\@height{\@height + 0.0}%
- \pgfmathsetmacro\@width{\@width + 0.0}%
- \pgfmathsetmacro\@minsize{min(\@width, \@height)}%
- \pgfmathsetmacro\@zero{0.0}%
- \expandafter\ifx\@lowerbandwidth\pgfkeysnovalue%
- \edef\@lowerbandwidth{\@minsize}%
- \fi%
- \expandafter\ifx\@upperbandwidth\pgfkeysnovalue%
- \edef\@upperbandwidth{\@minsize}%
- \fi%
- \pgfmathsetmacro\@lowerbandwidth{min(\@minsize, \@lowerbandwidth)}%
- \pgfmathsetmacro\@upperbandwidth{min(\@minsize, \@upperbandwidth)}%
- \expandafter\ifx\@bboxheight\pgfkeysnovalue%
- \pgfmathsetmacro\@bboxheight{\@height + \@offsetheight}%
- \fi%
- \expandafter\ifx\@bboxwidth\pgfkeysnovalue%
- \pgfmathsetmacro\@bboxwidth{\@width + \@offsetwidth}%
- \fi%
\begin{tikzpicture}[/drawmatrix/every picture, /drawmatrix/picture]
+ \path[/drawmatrix/path] (\dm@width, \dm@height);
+ \pgfgetlastxy\dm@width\dm@height
+ \path[/drawmatrix/path] (\dm@offsetwidth, \dm@offsetheight);
+ \pgfgetlastxy\dm@offsetwidth\dm@offsetheight
+ \pgfmathsetlengthmacro\dm@minsize{min(\dm@width, \dm@height)}
+ \pgfmathsetlengthmacro\dm@zero{0.0}
+ \expandafter\ifx\dm@lowerbandwidth\pgfkeysnovalue
+ \edef\dm@lowerbandwidth{\dm@minsize}
+ \else
+ \path[/drawmatrix/path] (\dm@lowerbandwidth, 0);
+ \pgfgetlastxy\dm@lowerbandwidth\dm@zero
+ \fi
+ \expandafter\ifx\dm@upperbandwidth\pgfkeysnovalue
+ \edef\dm@upperbandwidth{\dm@minsize}
+ \else
+ \path[/drawmatrix/path] (0, \dm@upperbandwidth);
+ \pgfgetlastxy\dm@zero\dm@upperbandwidth
+ \fi
+ \pgfmathsetlengthmacro\dm@lowerbandwidth{
+ min(\dm@minsize, \dm@lowerbandwidth)
+ }
+ \pgfmathsetlengthmacro\dm@upperbandwidth{
+ min(\dm@minsize, \dm@upperbandwidth)
+ }
+ \expandafter\ifx\dm@bboxheight\pgfkeysnovalue
+ \pgfmathsetlengthmacro\dm@bboxheight{
+ \dm@height + \dm@offsetheight
+ }
+ \else
+ \path[/drawmatrix/path] (0, \dm@bboxheight);
+ \pgfgetlastxy\dm@zero\dm@bboxheight
+ \fi
+ \expandafter\ifx\dm@bboxwidth\pgfkeysnovalue
+ \pgfmathsetlengthmacro\dm@bboxwidth{
+ \dm@width + \dm@offsetwidth
+ }
+ \else
+ \path[/drawmatrix/path] (\dm@bboxwidth, 0);
+ \pgfgetlastxy\dm@bboxwidth\dm@zero
+ \fi
+ \pgfresetboundingbox
\node[/drawmatrix/every bbox, /drawmatrix/bbox,
- minimum height=\@bboxheight cm,
- minimum width=\@bboxwidth cm] {};
+ minimum height=\dm@bboxheight,
+ minimum width=\dm@bboxwidth] {};
\path (drawmatrix bbox.north west)
- ++(\@offsetwidth, -\@offsetheight)
+ ++(\dm@offsetwidth, -\dm@offsetheight)
++(.5\pgflinewidth, -.5\pgflinewidth)
coordinate (drawmatrix north west)
- ++(\@width, 0)
- +(-\@minsize + \@upperbandwidth, 0)
+ ++(\dm@width, 0)
+ +(-\dm@minsize + \dm@upperbandwidth, 0)
coordinate (drawmatrix north)
- +(0, -\@minsize + \@upperbandwidth)
+ +(0, -\dm@minsize + \dm@upperbandwidth)
coordinate (drawmatrix east)
- ++(0, -\@height)
+ ++(0, -\dm@height)
coordinate (drawmatrix south east)
- ++(-\@width, 0)
- +(\@minsize - \@lowerbandwidth, 0)
+ ++(-\dm@width, 0)
+ +(\dm@minsize - \dm@lowerbandwidth, 0)
coordinate (drawmatrix south)
- +(0, \@minsize - \@lowerbandwidth)
+ +(0, \dm@minsize - \dm@lowerbandwidth)
coordinate (drawmatrix west);
+ \node[/drawmatrix/every node,
+ minimum height=\dm@height,
+ minimum width=\dm@width]
+ at (drawmatrix north west) {};
\filldraw[/drawmatrix/every drawmatrix, /drawmatrix/drawmatrix]
(drawmatrix north west)
- \ifx\@upperbandwidth\@zero
- \ifx\@width\@minsize\else -- (drawmatrix north) \fi
- \ifx\@height\@minsize\else -- (drawmatrix east) \fi
+ \ifx\dm@upperbandwidth\dm@zero
+ \ifx\dm@width\dm@minsize\else -- (drawmatrix north) \fi
+ \ifx\dm@height\dm@minsize\else -- (drawmatrix east) \fi
\else
-- (drawmatrix north)
- \ifx\@upperbandwidth\@minsize\else -- (drawmatrix east) \fi
+ \ifx\dm@upperbandwidth\dm@minsize\else
+ -- (drawmatrix east)
+ \fi
\fi
-- (drawmatrix south east)
- \ifx\@lowerbandwidth\@zero
- \ifx\@width\@minsize\else -- (drawmatrix south) \fi
- \ifx\@height\@minsize\else -- (drawmatrix west) \fi
+ \ifx\dm@lowerbandwidth\dm@zero
+ \ifx\dm@width\dm@minsize\else -- (drawmatrix south) \fi
+ \ifx\dm@height\dm@minsize\else -- (drawmatrix west) \fi
\else
-- (drawmatrix south)
- \ifx\@lowerbandwidth\@minsize\else -- (drawmatrix west) \fi
+ \ifx\dm@lowerbandwidth\dm@minsize\else
+ -- (drawmatrix west)
+ \fi
\fi
-- cycle;
- \node[minimum height=\@height cm, minimum width=\@width cm,
- anchor=north west] at (drawmatrix north west)
- (drawmatrix matrix) {};
- \node[/drawmatrix/every label, /drawmatrix/label] {\@labeltext};
+ \node[/drawmatrix/every label, /drawmatrix/label]
+ {\dm@labeltext};
\end{tikzpicture}%
}}
\endinput