summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-03-01 22:30:18 +0000
committerKarl Berry <karl@freefriends.org>2017-03-01 22:30:18 +0000
commita27782c0a2594f4f1c8f2c7b3c2b78d19fd760cd (patch)
treef831a4c440b8c38f292e573156a7627ba574581d /Master
parent800462d19ac70da2bba3efcc39db662187751891 (diff)
drawmatrix (1mar17)
git-svn-id: svn://tug.org/texlive/trunk@43372 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdfbin282790 -> 302267 bytes
-rw-r--r--Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx159
-rw-r--r--Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty49
3 files changed, 154 insertions, 54 deletions
diff --git a/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf b/Master/texmf-dist/doc/latex/drawmatrix/drawmatrix.pdf
index 95c19832407..2e37a97db05 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 857bc15ac4c..30fbedc0715 100644
--- a/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx
+++ b/Master/texmf-dist/source/latex/drawmatrix/drawmatrix.dtx
@@ -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@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
+% \dm@labelbase, \dm@labeltextouter, \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,
+% \phantom, \tikz@library@external@loaded, \tikzset, \undefined,
% }
%
% This section describes the implementation details of the \textsf{drawmatrix}
@@ -478,28 +511,47 @@
% \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@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,
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}
@@ -529,27 +581,36 @@
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,
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@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@labeltext,
height/.get=\dm@height,
width/.get=\dm@width,
lower bandwidth/.get=\dm@lowerbandwidth,
@@ -574,12 +637,21 @@
offset width/.get=\dm@offsetwidth,
bbox height/.get=\dm@bboxheight,
bbox width/.get=\dm@bboxwidth,
+ label base/.get=\dm@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@labeltext{$#2$}\else\def\dm@labeltext{#2}\fi%
+ \ifmmode\edef\dm@labeltext{$\dm@labeltext$}\fi%
+ \expandafter\ifx\dm@labelbase\pgfkeysnovalue\else%
+ \let\dm@labeltextouter\dm@labeltext%
+ \edef\dm@labelbase{%
+ \ifmmode$\dm@labelbase$\else\dm@labelbase\fi%
+ }%
+ \def\dm@labeltext{\phantom{\dm@labelbase}}%
+ \fi%
% \end{macrocode}
%
% Disable externalization if |externalize=false|. Start the picture.
@@ -607,13 +679,13 @@
% smaller dimension.
% \begin{macrocode}
\expandafter\ifx\dm@lowerbandwidth\pgfkeysnovalue
- \edef\dm@lowerbandwidth{\dm@minsize}
+ \def\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}
+ \def\dm@upperbandwidth{\dm@minsize}
\else
\path[/drawmatrix/path] (0, \dm@upperbandwidth);
\pgfgetlastxy\dm@zero\dm@upperbandwidth
@@ -678,8 +750,7 @@
% \begin{macrocode}
\node[/drawmatrix/every node,
minimum height=\dm@height,
- minimum width=\dm@width]
- at (drawmatrix north west) {};
+ minimum width=\dm@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@labeltext};
+ \expandafter\ifx\dm@labelbase\pgfkeysnovalue\else
+ \node[/drawmatrix/every label, /drawmatrix/label,
+ /drawmatrix/label outer] {\dm@labeltextouter};
+ \fi
\end{tikzpicture}%
}}
% \end{macrocode}
diff --git a/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty b/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty
index a79f4c1a82e..bdadb90799f 100644
--- a/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty
+++ b/Master/texmf-dist/tex/latex/drawmatrix/drawmatrix.sty
@@ -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@externalize
\pgfkeys{
@@ -46,13 +46,22 @@
lower/.style={upper bandwidth=0},
upper/.style={lower bandwidth=0},
diag/.style={lower, upper},
- externalize/.is if=drawmatrix@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@currname\pgfkeyscurrentname%
@@ -68,28 +77,33 @@
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,
outer sep=0,
inner sep=0,
anchor=north west,
- }
+ at=(drawmatrix north west)
+ },
+ externalize/.is if=drawmatrix@externalize,
+ externalize=true
}
\newcommand\drawmatrixset[1]{\pgfqkeys{/drawmatrix}{#1}}
\newcommand\drawmatrix[2][]{{%
\drawmatrixset{
+ label text={#2},
#1,
+ label text/.get=\dm@labeltext,
height/.get=\dm@height,
width/.get=\dm@width,
lower bandwidth/.get=\dm@lowerbandwidth,
@@ -98,8 +112,16 @@
offset width/.get=\dm@offsetwidth,
bbox height/.get=\dm@bboxheight,
bbox width/.get=\dm@bboxwidth,
+ label base/.get=\dm@labelbase
}%
- \ifmmode\def\dm@labeltext{$#2$}\else\def\dm@labeltext{#2}\fi%
+ \ifmmode\edef\dm@labeltext{$\dm@labeltext$}\fi%
+ \expandafter\ifx\dm@labelbase\pgfkeysnovalue\else%
+ \let\dm@labeltextouter\dm@labeltext%
+ \edef\dm@labelbase{%
+ \ifmmode$\dm@labelbase$\else\dm@labelbase\fi%
+ }%
+ \def\dm@labeltext{\phantom{\dm@labelbase}}%
+ \fi%
\ifdrawmatrix@externalize\else%
\ifx\tikz@library@external@loaded\undefined\else%
\tikzset{external/export=false}%
@@ -113,13 +135,13 @@
\pgfmathsetlengthmacro\dm@minsize{min(\dm@width, \dm@height)}
\pgfmathsetlengthmacro\dm@zero{0.0}
\expandafter\ifx\dm@lowerbandwidth\pgfkeysnovalue
- \edef\dm@lowerbandwidth{\dm@minsize}
+ \def\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}
+ \def\dm@upperbandwidth{\dm@minsize}
\else
\path[/drawmatrix/path] (0, \dm@upperbandwidth);
\pgfgetlastxy\dm@zero\dm@upperbandwidth
@@ -168,8 +190,7 @@
coordinate (drawmatrix west);
\node[/drawmatrix/every node,
minimum height=\dm@height,
- minimum width=\dm@width]
- at (drawmatrix north west) {};
+ minimum width=\dm@width] {};
\filldraw[/drawmatrix/every drawmatrix, /drawmatrix/drawmatrix]
(drawmatrix north west)
\ifx\dm@upperbandwidth\dm@zero
@@ -194,6 +215,10 @@
-- cycle;
\node[/drawmatrix/every label, /drawmatrix/label]
{\dm@labeltext};
+ \expandafter\ifx\dm@labelbase\pgfkeysnovalue\else
+ \node[/drawmatrix/every label, /drawmatrix/label,
+ /drawmatrix/label outer] {\dm@labeltextouter};
+ \fi
\end{tikzpicture}%
}}
\endinput