texlive[43372] Master/texmf-dist: drawmatrix (1mar17)

commits+karl at tug.org commits+karl at tug.org
Wed Mar 1 23:30:18 CET 2017


Revision: 43372
          http://tug.org/svn/texlive?view=revision&revision=43372
Author:   karl
Date:     2017-03-01 23:30:18 +0100 (Wed, 01 Mar 2017)
Log Message:
-----------
drawmatrix (1mar17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf
    trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx
    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	2017-03-01 22:30:07 UTC (rev 43371)
+++ trunk/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx	2017-03-01 22:30:18 UTC (rev 43372)
@@ -9,7 +9,7 @@
 %
 % \iffalse
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
-%<package>\ProvidesPackage{drawmatrix}[2016/08/25 v1.2.0 drawmatrix package]
+%<package>\ProvidesPackage{drawmatrix}[2016/12/20 v1.4.0 drawmatrix package]
 %
 %<*driver>
 \documentclass{ltxdoc}
@@ -53,7 +53,9 @@
 % 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}
+% \changes{v1.2.0}{2016/08/25}{Added coordinate transformations}
+% \changes{v1.3.0}{2016/11/12}{Added label base (shifted exponents)}
+% \changes{v1.4.0}{2016/12/20}{Added exponenet shortcut}
 %
 %
 % \GetFileInfo{drawmatrix.sty}
@@ -85,22 +87,22 @@
 % understanding of linear algebra properties, relations, and operations
 % enormously.  This package provides simple tools to bring such representations
 % to \LaTeX.  For instance,
-% $$
+% \[
 %   \drawmatrix[upper]A \;
 %   \drawmatrix[width=.5]X +
 %   \drawmatrix[width=.5]X \;
 %   \drawmatrix[upper, size=.5, bbox height=1]B =
 %   \drawmatrix[width=.5]C
-% $$
+% \]
 % is typeset as follows:
 % \begin{verbatim}
-% $$
+% \[
 %   \drawmatrix[upper]A \;
 %   \drawmatrix[width=.5]X +
 %   \drawmatrix[width=.5]X \;
 %   \drawmatrix[upper, size=.5, bbox height=1]B =
 %   \drawmatrix[width=.5]C
-% $$
+% \]
 % \end{verbatim}
 %
 %
@@ -128,8 +130,15 @@
 % $\drawmatrix{A} \drawmatrix{B}$, a little space (|\;|) helps to yield a more
 % natural result: $\drawmatrix{A} \; \drawmatrix{B}$.
 %
+% Note that the \meta{label} is stored in \DescribeMacro{label text}
+% |label text|, which can also be set directly to overwrite \meta{label}.
+% \begin{example}
+%   |$\drawmatrix[label text=B]A$|:
+%    $\drawmatrix[label text=B]A$
+% \end{example}
+%
 % \subsection{Size}
-% By default, matrices are $1 \times 1$ large in terms of \TikZ units.  The
+% By default, matrices are of size $1 \times 1$ in terms of \TikZ units.  The
 % width and height of a matrix are set through, respectively,
 % \DescribeMacro{height} |width=|\meta{dimension} and \DescribeMacro{width}
 % |height=|\meta{dimension}.  A width or height of 0 are useful to represent
@@ -157,10 +166,9 @@
 % \end{example}
 %
 % \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{dimension}
-% (default: 0.3);
+% Matrices are drawn as banded with the key \DescribeMacro{banded} |banded|.
+% The bandwidth, i.e., the horizontal/vertical extent from the diagonal, is
+% set by \DescribeMacro{bandwidth} |bandwidth=|\meta{dimension} (default: 0.3);
 % \begin{example}
 %   |\drawmatrix[banded]B|:
 %    \drawmatrix[banded]B
@@ -205,6 +213,31 @@
 %    \drawmatrix[diag]D
 % \end{example}
 %
+% \subsubsection{Super- and subscripts}
+% \DescribeMacro{label base} |label base| defines the label to be centered in
+% the drawmatrix, the actual label will be aligned to this label at the.  The
+% default alignment is at the |base west| of the label, which can changed
+% through the \DescribeMacro{label base anchor} |label anchor| key.
+% This featur is useful to, e.g., draw centered labes with exponents:
+% \begin{example}
+%   |$\drawmatrix[size=.5]{A^T}$|:
+%    $\drawmatrix[size=.5]{A^T}$
+%
+%   |$\drawmatrix[size=.5, label base=A]{A^T}$|:
+%    $\drawmatrix[size=.5, label base=A]{A^T}$
+%
+%   |$\drawmatrix[size=.5, label base=A, label base anchor=base east]{^0_1A}$|:
+%    $\drawmatrix[size=.5, label base=A, label base anchor=base east]{^0_1A}$
+% \end{example}
+%
+% \DescribeMacro{exponent} |exponent| is a shortcut to add an exponent to matrix
+% without offsetting the labe.  Internally, it sets the |label base| to the
+% current |label text| and adds the |exponent| ot the |label text|.
+% \begin{example}
+%   |$\drawmatrix[size=.5, exponent=T]A$|:
+%    $\drawmatrix[size=.5, exponent=T]A$
+% \end{example}
+%
 % \subsection{Colors and Style}
 % By default, matrices are drawn in gray and filled white.  The \TikZ keys
 % |draw=|\meta{color} and |fill=|\meta{color} change these colors.  In fact, all
@@ -339,14 +372,14 @@
 %
 % \DoNotIndex{
 %   \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
+%   \dm at labelbase, \dm at labeltextouter, \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,
+%   \phantom, \tikz at library@external at loaded, \tikzset, \undefined,
 % }
 %
 % This section describes the implementation details of the \textsf{drawmatrix}
@@ -478,21 +511,16 @@
 %    \end{macrocode}
 % \end{macro}\end{macro}\end{macro}
 %
-% \begin{macro}{externalize}
-%   |externalize| sets a \TeX{} if (default: |true| = behave as all pictures).
-%    \begin{macrocode}
-    externalize/.is if=drawmatrix at externalize,
-    externalize=true,
-%    \end{macrocode}
-% \end{macro}
-%
+% \begin{macro}{label text}
 % \begin{macro}{label}
 % \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).
-%   |label anchor| sets the label's |anchor| (default: in the middle).
+%   |label| is the style for the label with the text |label text|. |label pos|
+%   sets the label at a named coordinate of the matrix (default: center of the
+%   bounding box).  |label anchor| sets the label's |anchor| (default: in the
+%   middle).
 %    \begin{macrocode}
+    label text/.initial,
     label/.style={},
     label pos/.style={label/.append style={at=(drawmatrix #1)}},
     label pos=bbox.center,
@@ -499,8 +527,32 @@
     label anchor/.style={label/.append style={anchor=#1}},
     label anchor=mid,
 %    \end{macrocode}
-% \end{macro}\end{macro}\end{macro}
+% \end{macro}\end{macro}\end{macro} \end{macro}
 %
+% \begin{macro}{label base}
+% \begin{macro}{label base anchor}
+%  |label base| and |label base anchor| allow to ofset labels with exponents.
+%    \begin{macrocode}
+    label base/.initial,
+    label outer/.style={},
+    label base anchor/.style={label outer/.append style={
+        anchor=#1, at=(drawmatrix label.#1)
+    }},
+    label base anchor=base west,
+%    \end{macrocode}
+% \end{macro}\end{macro}
+%
+% \begin{macro}{exponent}
+%   |exponent| is a shortcut to add an expontent to the label text without using
+%   the |label base|.
+%    \begin{macrocode}
+    exponent/.style={
+        label base/.expanded=\pgfkeysvalueof{/drawmatrix/label text},
+        label text/.append=^{#1}
+    },
+%    \end{macrocode}
+% \end{macro}
+%
 % Unknown keys are collected in |/drawmatrix/drawmatrix|.
 %    \begin{macrocode}
     drawmatrix/.style={},
@@ -529,16 +581,16 @@
     every picture/.style={},
     every bbox/.style={
         name=drawmatrix bbox,
-        inner sep=0,
+        inner sep=0
     },
     every drawmatrix/.style={
         fill=white,
-        draw=gray,
+        draw=gray
     },
     every label/.style={
         name=drawmatrix label,
         outer sep=0,
-        inner sep=0,
+        inner sep=0
     },
     every node/.style={
         name=drawmatrix matrix,
@@ -545,11 +597,20 @@
         outer sep=0,
         inner sep=0,
         anchor=north west,
-    }
-}
+        at=(drawmatrix north west)
+    },
 %    \end{macrocode}
 % \end{macro}\end{macro}\end{macro}\end{macro}
 %
+% \begin{macro}{externalize}
+%   |externalize| sets a \TeX{} if (default: |true| = behave as all pictures).
+%    \begin{macrocode}
+    externalize/.is if=drawmatrix at externalize,
+    externalize=true
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{User Macros}
 %
 % |\drawmatrixset| as a simple shortcut like |\tikzset|.
@@ -565,7 +626,9 @@
 %    \begin{macrocode}
 \newcommand\drawmatrix[2][]{{%
     \drawmatrixset{
+        label text={#2},
         #1,
+        label text/.get=\dm at labeltext,
         height/.get=\dm at height,
         width/.get=\dm at width,
         lower bandwidth/.get=\dm at lowerbandwidth,
@@ -574,12 +637,21 @@
         offset width/.get=\dm at offsetwidth,
         bbox height/.get=\dm at bboxheight,
         bbox width/.get=\dm at bboxwidth,
+        label base/.get=\dm at labelbase
     }%
 %    \end{macrocode}
 %
-% Prepare the label text (keep math mode).
+% Prepare the label text and, if needed label outer text (for alignment).  This
+% needs to be outside the tikzpicture to properly detect math mode.
 %    \begin{macrocode}
-    \ifmmode\def\dm at labeltext{$#2$}\else\def\dm at labeltext{#2}\fi%
+    \ifmmode\edef\dm at labeltext{$\dm at labeltext$}\fi%
+    \expandafter\ifx\dm at labelbase\pgfkeysnovalue\else%
+        \let\dm at labeltextouter\dm at labeltext%
+        \edef\dm at labelbase{%
+            \ifmmode$\dm at labelbase$\else\dm at labelbase\fi%
+        }%
+        \def\dm at labeltext{\phantom{\dm at labelbase}}%
+    \fi%
 %    \end{macrocode}
 %
 % Disable externalization if |externalize=false|.  Start the picture.
@@ -607,13 +679,13 @@
 % smaller dimension.
 %    \begin{macrocode}
         \expandafter\ifx\dm at lowerbandwidth\pgfkeysnovalue
-            \edef\dm at lowerbandwidth{\dm at minsize}
+            \def\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}
+            \def\dm at upperbandwidth{\dm at minsize}
         \else
             \path[/drawmatrix/path] (0, \dm at upperbandwidth);
             \pgfgetlastxy\dm at zero\dm at upperbandwidth
@@ -678,8 +750,7 @@
 %    \begin{macrocode}
         \node[/drawmatrix/every node,
             minimum height=\dm at height,
-            minimum width=\dm at width]
-            at (drawmatrix north west) {};
+            minimum width=\dm at width] {};
 %    \end{macrocode}
 %
 % Now, draw only what is needed of the matrix.  Otherwise path modifications
@@ -713,6 +784,10 @@
 %    \begin{macrocode}
         \node[/drawmatrix/every label, /drawmatrix/label]
             {\dm at labeltext};
+        \expandafter\ifx\dm at labelbase\pgfkeysnovalue\else
+            \node[/drawmatrix/every label, /drawmatrix/label,
+                  /drawmatrix/label outer] {\dm at labeltextouter};
+        \fi
     \end{tikzpicture}%
 }}
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty	2017-03-01 22:30:07 UTC (rev 43371)
+++ trunk/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty	2017-03-01 22:30:18 UTC (rev 43372)
@@ -13,7 +13,7 @@
 %% This package is distributed under the MIT license.
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesPackage{drawmatrix}[2016/08/25 v1.2.0 drawmatrix package]
+\ProvidesPackage{drawmatrix}[2016/12/20 v1.4.0 drawmatrix package]
 \RequirePackage{tikz}
 \newif\ifdrawmatrix at externalize
 \pgfkeys{
@@ -46,13 +46,22 @@
     lower/.style={upper bandwidth=0},
     upper/.style={lower bandwidth=0},
     diag/.style={lower, upper},
-    externalize/.is if=drawmatrix at externalize,
-    externalize=true,
+    label text/.initial,
     label/.style={},
     label pos/.style={label/.append style={at=(drawmatrix #1)}},
     label pos=bbox.center,
     label anchor/.style={label/.append style={anchor=#1}},
     label anchor=mid,
+    label base/.initial,
+    label outer/.style={},
+    label base anchor/.style={label outer/.append style={
+        anchor=#1, at=(drawmatrix label.#1)
+    }},
+    label base anchor=base west,
+    exponent/.style={
+        label base/.expanded=\pgfkeysvalueof{/drawmatrix/label text},
+        label text/.append=^{#1}
+    },
     drawmatrix/.style={},
     .unknown/.code={%
         \let\dm at currname\pgfkeyscurrentname%
@@ -68,16 +77,16 @@
     every picture/.style={},
     every bbox/.style={
         name=drawmatrix bbox,
-        inner sep=0,
+        inner sep=0
     },
     every drawmatrix/.style={
         fill=white,
-        draw=gray,
+        draw=gray
     },
     every label/.style={
         name=drawmatrix label,
         outer sep=0,
-        inner sep=0,
+        inner sep=0
     },
     every node/.style={
         name=drawmatrix matrix,
@@ -84,12 +93,17 @@
         outer sep=0,
         inner sep=0,
         anchor=north west,
-    }
+        at=(drawmatrix north west)
+    },
+    externalize/.is if=drawmatrix at externalize,
+    externalize=true
 }
 \newcommand\drawmatrixset[1]{\pgfqkeys{/drawmatrix}{#1}}
 \newcommand\drawmatrix[2][]{{%
     \drawmatrixset{
+        label text={#2},
         #1,
+        label text/.get=\dm at labeltext,
         height/.get=\dm at height,
         width/.get=\dm at width,
         lower bandwidth/.get=\dm at lowerbandwidth,
@@ -98,8 +112,16 @@
         offset width/.get=\dm at offsetwidth,
         bbox height/.get=\dm at bboxheight,
         bbox width/.get=\dm at bboxwidth,
+        label base/.get=\dm at labelbase
     }%
-    \ifmmode\def\dm at labeltext{$#2$}\else\def\dm at labeltext{#2}\fi%
+    \ifmmode\edef\dm at labeltext{$\dm at labeltext$}\fi%
+    \expandafter\ifx\dm at labelbase\pgfkeysnovalue\else%
+        \let\dm at labeltextouter\dm at labeltext%
+        \edef\dm at labelbase{%
+            \ifmmode$\dm at labelbase$\else\dm at labelbase\fi%
+        }%
+        \def\dm at labeltext{\phantom{\dm at labelbase}}%
+    \fi%
     \ifdrawmatrix at externalize\else%
         \ifx\tikz at library@external at loaded\undefined\else%
             \tikzset{external/export=false}%
@@ -113,13 +135,13 @@
         \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}
+            \def\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}
+            \def\dm at upperbandwidth{\dm at minsize}
         \else
             \path[/drawmatrix/path] (0, \dm at upperbandwidth);
             \pgfgetlastxy\dm at zero\dm at upperbandwidth
@@ -168,8 +190,7 @@
             coordinate (drawmatrix west);
         \node[/drawmatrix/every node,
             minimum height=\dm at height,
-            minimum width=\dm at width]
-            at (drawmatrix north west) {};
+            minimum width=\dm at width] {};
         \filldraw[/drawmatrix/every drawmatrix, /drawmatrix/drawmatrix]
             (drawmatrix north west)
             \ifx\dm at upperbandwidth\dm at zero
@@ -194,6 +215,10 @@
             -- cycle;
         \node[/drawmatrix/every label, /drawmatrix/label]
             {\dm at labeltext};
+        \expandafter\ifx\dm at labelbase\pgfkeysnovalue\else
+            \node[/drawmatrix/every label, /drawmatrix/label,
+                  /drawmatrix/label outer] {\dm at labeltextouter};
+        \fi
     \end{tikzpicture}%
 }}
 \endinput



More information about the tex-live-commits mailing list