texlive[41928] Master/texmf-dist: drawmatrix (25aug16)

commits+karl at tug.org commits+karl at tug.org
Fri Aug 26 01:02:19 CEST 2016


Revision: 41928
          http://tug.org/svn/texlive?view=revision&revision=41928
Author:   karl
Date:     2016-08-26 01:02:19 +0200 (Fri, 26 Aug 2016)
Log Message:
-----------
drawmatrix (25aug16)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf
    trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx
    trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins
    trunk/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty

Modified: trunk/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx	2016-08-25 23:02:05 UTC (rev 41927)
+++ trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx	2016-08-25 23:02:19 UTC (rev 41928)
@@ -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 at externalize,
-%   \ifmmode, \ifx, \let, \newcommand, \newif, \node, \path, \pgfkeys,
-%   \pgfkeysalso, \pgfkeyscurrentname, \pgfkeyscurrentvalue, \pgfkeysnovalue,
-%   \pgflinewidth, \pgfmathsetmacro, \pgfqkeys, \tikz at library@external at loaded,
-%   \tikzset, \undefined,
+%   \dm at bboxheight, \dm at bboxwidth, \dm at currname, \dm at currval, \dm at height,
+%   \dm at labeltext, \dm at lowerbandwidth, \dm at minsize, \dm at offsetheight,
+%   \dm at offsetwidth, \dm at upperbandwidth, \dm at width, \dm at zero, \RequirePackage,
+%   \begin, \def, \edef, \else, \end, \expandafter, \fi, \filldraw,
+%   \ifdrawmatrix at externalize, \ifmmode, \ifx, \let, \newcommand, \newif, \node,
+%   \path, \pgfkeys, \pgfkeysalso, \pgfkeyscurrentname, \pgfkeyscurrentvalue,
+%   \pgfkeysnovalue, \pgflinewidth, \pgfgetlastxy, \pgfmathsetlengthmacro,
+%   \pgfresetboundingbox, \pgfqkeys, \tikz at library@external at 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 at currname\pgfkeyscurrentname%
+        \let\dm at currval\pgfkeyscurrentvalue%
         \ifx#1\pgfkeysnovalue\pgfkeysalso{
-            drawmatrix/.append style/.expand once={\@currname}
+            drawmatrix/.append style/.expand once={\dm at currname}
         }\else\pgfkeysalso{
             drawmatrix/.append style/.expand twice={%
-                \expandafter\@currname\expandafter=\@currval%
+                \expandafter\dm at currname\expandafter=\dm at 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,17 +559,30 @@
 %    \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 at height,
+        width/.get=\dm at width,
+        lower bandwidth/.get=\dm at lowerbandwidth,
+        upper bandwidth/.get=\dm at upperbandwidth,
+        offset height/.get=\dm at offsetheight,
+        offset width/.get=\dm at offsetwidth,
+        bbox height/.get=\dm at bboxheight,
+        bbox width/.get=\dm at bboxwidth,
+    }%
 %    \end{macrocode}
 %
-% Disable externalization if |externalize=false|.
+% Prepare the label text (keep math mode).
+%    \begin{macrocode}
+    \ifmmode\def\dm at labeltext{$#2$}\else\def\dm at labeltext{#2}\fi%
+%    \end{macrocode}
 %
+% Disable externalization if |externalize=false|.  Start the picture.
 %    \begin{macrocode}
     \ifdrawmatrix at externalize\else%
         \ifx\tikz at library@external at loaded\undefined\else%
@@ -545,116 +589,130 @@
             \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 at width, \dm at height);
+        \pgfgetlastxy\dm at width\dm at height
+        \path[/drawmatrix/path] (\dm at offsetwidth, \dm at offsetheight);
+        \pgfgetlastxy\dm at offsetwidth\dm at offsetheight
+        \pgfmathsetlengthmacro\dm at minsize{min(\dm at width, \dm at height)}
+        \pgfmathsetlengthmacro\dm at 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 at lowerbandwidth\pgfkeysnovalue
+            \edef\dm at lowerbandwidth{\dm at minsize}
+        \else
+            \path[/drawmatrix/path] (\dm at lowerbandwidth, 0);
+            \pgfgetlastxy\dm at lowerbandwidth\dm at zero
+        \fi
+        \expandafter\ifx\dm at upperbandwidth\pgfkeysnovalue
+            \edef\dm at upperbandwidth{\dm at minsize}
+        \else
+            \path[/drawmatrix/path] (0, \dm at upperbandwidth);
+            \pgfgetlastxy\dm at zero\dm at upperbandwidth
+        \fi
+        \pgfmathsetlengthmacro\dm at lowerbandwidth{
+            min(\dm at minsize, \dm at lowerbandwidth)
+        }
+        \pgfmathsetlengthmacro\dm at upperbandwidth{
+            min(\dm at minsize, \dm at 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 at bboxheight\pgfkeysnovalue
+            \pgfmathsetlengthmacro\dm at bboxheight{
+                \dm at height + \dm at offsetheight
+            }
+        \else
+            \path[/drawmatrix/path] (0, \dm at bboxheight);
+            \pgfgetlastxy\dm at zero\dm at bboxheight
+        \fi
+        \expandafter\ifx\dm at bboxwidth\pgfkeysnovalue
+            \pgfmathsetlengthmacro\dm at bboxwidth{
+                \dm at width + \dm at offsetwidth
+            }
+        \else
+            \path[/drawmatrix/path] (\dm at bboxwidth, 0);
+            \pgfgetlastxy\dm at bboxwidth\dm at 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 at bboxheight,
+            minimum width=\dm at bboxwidth] {};
 %    \end{macrocode}
 %
 % Whether needed or not, declare all matrix corners.
 %    \begin{macrocode}
         \path (drawmatrix bbox.north west)
-            ++(\@offsetwidth, -\@offsetheight)
+            ++(\dm at offsetwidth, -\dm at offsetheight)
             ++(.5\pgflinewidth, -.5\pgflinewidth)
             coordinate (drawmatrix north west)
-            ++(\@width, 0)
-            +(-\@minsize + \@upperbandwidth, 0)
+            ++(\dm at width, 0)
+            +(-\dm at minsize + \dm at upperbandwidth, 0)
             coordinate (drawmatrix north)
-            +(0, -\@minsize + \@upperbandwidth) 
+            +(0, -\dm at minsize + \dm at upperbandwidth)
             coordinate (drawmatrix east)
-            ++(0, -\@height) 
+            ++(0, -\dm at height)
             coordinate (drawmatrix south east)
-            ++(-\@width, 0)
-            +(\@minsize - \@lowerbandwidth, 0) 
+            ++(-\dm at width, 0)
+            +(\dm at minsize - \dm at lowerbandwidth, 0)
             coordinate (drawmatrix south)
-            +(0, \@minsize - \@lowerbandwidth) 
+            +(0, \dm at minsize - \dm at lowerbandwidth)
             coordinate (drawmatrix west);
 %    \end{macrocode}
 %
+% Add an invisible node the size of the matrix.
+%    \begin{macrocode}
+        \node[/drawmatrix/every node,
+            minimum height=\dm at height,
+            minimum width=\dm at 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 at upperbandwidth\dm at zero
+                \ifx\dm at width\dm at minsize\else -- (drawmatrix north) \fi
+                \ifx\dm at height\dm at minsize\else -- (drawmatrix east) \fi
             \else
                 -- (drawmatrix north)
-                \ifx\@upperbandwidth\@minsize\else -- (drawmatrix east) \fi
+                \ifx\dm at upperbandwidth\dm at 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 at lowerbandwidth\dm at zero
+                \ifx\dm at width\dm at minsize\else -- (drawmatrix south) \fi
+                \ifx\dm at height\dm at minsize\else -- (drawmatrix west) \fi
             \else
                 -- (drawmatrix south)
-                \ifx\@lowerbandwidth\@minsize\else -- (drawmatrix west) \fi
+                \ifx\dm at lowerbandwidth\dm at 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 at labeltext};
     \end{tikzpicture}%
 }}
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins	2016-08-25 23:02:05 UTC (rev 41927)
+++ trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.ins	2016-08-25 23:02:19 UTC (rev 41928)
@@ -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.
 

Modified: trunk/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty	2016-08-25 23:02:05 UTC (rev 41927)
+++ trunk/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty	2016-08-25 23:02:19 UTC (rev 41928)
@@ -8,12 +8,12 @@
 %% 
 %% 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 at externalize
 \pgfkeys{
@@ -20,7 +20,11 @@
     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 at currname\pgfkeyscurrentname%
+        \let\dm at currval\pgfkeyscurrentvalue%
         \ifx#1\pgfkeysnovalue\pgfkeysalso{
-            drawmatrix/.append style/.expand once={\@currname}
+            drawmatrix/.append style/.expand once={\dm at currname}
         }\else\pgfkeysalso{
             drawmatrix/.append style/.expand twice={%
-                \expandafter\@currname\expandafter=\@currval%
+                \expandafter\dm at currname\expandafter=\dm at 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 at height,
+        width/.get=\dm at width,
+        lower bandwidth/.get=\dm at lowerbandwidth,
+        upper bandwidth/.get=\dm at upperbandwidth,
+        offset height/.get=\dm at offsetheight,
+        offset width/.get=\dm at offsetwidth,
+        bbox height/.get=\dm at bboxheight,
+        bbox width/.get=\dm at bboxwidth,
+    }%
+    \ifmmode\def\dm at labeltext{$#2$}\else\def\dm at labeltext{#2}\fi%
     \ifdrawmatrix at externalize\else%
         \ifx\tikz at library@external at 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 at width, \dm at height);
+        \pgfgetlastxy\dm at width\dm at height
+        \path[/drawmatrix/path] (\dm at offsetwidth, \dm at offsetheight);
+        \pgfgetlastxy\dm at offsetwidth\dm at offsetheight
+        \pgfmathsetlengthmacro\dm at minsize{min(\dm at width, \dm at height)}
+        \pgfmathsetlengthmacro\dm at zero{0.0}
+        \expandafter\ifx\dm at lowerbandwidth\pgfkeysnovalue
+            \edef\dm at lowerbandwidth{\dm at minsize}
+        \else
+            \path[/drawmatrix/path] (\dm at lowerbandwidth, 0);
+            \pgfgetlastxy\dm at lowerbandwidth\dm at zero
+        \fi
+        \expandafter\ifx\dm at upperbandwidth\pgfkeysnovalue
+            \edef\dm at upperbandwidth{\dm at minsize}
+        \else
+            \path[/drawmatrix/path] (0, \dm at upperbandwidth);
+            \pgfgetlastxy\dm at zero\dm at upperbandwidth
+        \fi
+        \pgfmathsetlengthmacro\dm at lowerbandwidth{
+            min(\dm at minsize, \dm at lowerbandwidth)
+        }
+        \pgfmathsetlengthmacro\dm at upperbandwidth{
+            min(\dm at minsize, \dm at upperbandwidth)
+        }
+        \expandafter\ifx\dm at bboxheight\pgfkeysnovalue
+            \pgfmathsetlengthmacro\dm at bboxheight{
+                \dm at height + \dm at offsetheight
+            }
+        \else
+            \path[/drawmatrix/path] (0, \dm at bboxheight);
+            \pgfgetlastxy\dm at zero\dm at bboxheight
+        \fi
+        \expandafter\ifx\dm at bboxwidth\pgfkeysnovalue
+            \pgfmathsetlengthmacro\dm at bboxwidth{
+                \dm at width + \dm at offsetwidth
+            }
+        \else
+            \path[/drawmatrix/path] (\dm at bboxwidth, 0);
+            \pgfgetlastxy\dm at bboxwidth\dm at zero
+        \fi
+        \pgfresetboundingbox
         \node[/drawmatrix/every bbox, /drawmatrix/bbox,
-            minimum height=\@bboxheight cm,
-            minimum width=\@bboxwidth cm] {};
+            minimum height=\dm at bboxheight,
+            minimum width=\dm at bboxwidth] {};
         \path (drawmatrix bbox.north west)
-            ++(\@offsetwidth, -\@offsetheight)
+            ++(\dm at offsetwidth, -\dm at offsetheight)
             ++(.5\pgflinewidth, -.5\pgflinewidth)
             coordinate (drawmatrix north west)
-            ++(\@width, 0)
-            +(-\@minsize + \@upperbandwidth, 0)
+            ++(\dm at width, 0)
+            +(-\dm at minsize + \dm at upperbandwidth, 0)
             coordinate (drawmatrix north)
-            +(0, -\@minsize + \@upperbandwidth)
+            +(0, -\dm at minsize + \dm at upperbandwidth)
             coordinate (drawmatrix east)
-            ++(0, -\@height)
+            ++(0, -\dm at height)
             coordinate (drawmatrix south east)
-            ++(-\@width, 0)
-            +(\@minsize - \@lowerbandwidth, 0)
+            ++(-\dm at width, 0)
+            +(\dm at minsize - \dm at lowerbandwidth, 0)
             coordinate (drawmatrix south)
-            +(0, \@minsize - \@lowerbandwidth)
+            +(0, \dm at minsize - \dm at lowerbandwidth)
             coordinate (drawmatrix west);
+        \node[/drawmatrix/every node,
+            minimum height=\dm at height,
+            minimum width=\dm at 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 at upperbandwidth\dm at zero
+                \ifx\dm at width\dm at minsize\else -- (drawmatrix north) \fi
+                \ifx\dm at height\dm at minsize\else -- (drawmatrix east) \fi
             \else
                 -- (drawmatrix north)
-                \ifx\@upperbandwidth\@minsize\else -- (drawmatrix east) \fi
+                \ifx\dm at upperbandwidth\dm at 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 at lowerbandwidth\dm at zero
+                \ifx\dm at width\dm at minsize\else -- (drawmatrix south) \fi
+                \ifx\dm at height\dm at minsize\else -- (drawmatrix west) \fi
             \else
                 -- (drawmatrix south)
-                \ifx\@lowerbandwidth\@minsize\else -- (drawmatrix west) \fi
+                \ifx\dm at lowerbandwidth\dm at 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 at labeltext};
     \end{tikzpicture}%
 }}
 \endinput



More information about the tex-live-commits mailing list