diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/generic/pmat |
Initial commit
Diffstat (limited to 'macros/generic/pmat')
-rw-r--r-- | macros/generic/pmat/pmat.pdf | bin | 0 -> 69023 bytes | |||
-rw-r--r-- | macros/generic/pmat/pmat.sty | 180 | ||||
-rw-r--r-- | macros/generic/pmat/pmat.tex | 156 | ||||
-rw-r--r-- | macros/generic/pmat/readme | 11 |
4 files changed, 347 insertions, 0 deletions
diff --git a/macros/generic/pmat/pmat.pdf b/macros/generic/pmat/pmat.pdf Binary files differnew file mode 100644 index 0000000000..521a36f935 --- /dev/null +++ b/macros/generic/pmat/pmat.pdf diff --git a/macros/generic/pmat/pmat.sty b/macros/generic/pmat/pmat.sty new file mode 100644 index 0000000000..7fab07ab56 --- /dev/null +++ b/macros/generic/pmat/pmat.sty @@ -0,0 +1,180 @@ +%% +%% pmat.sty, version 0.1 +%% +%% Tom\'as Oliveira e Silva, January 1996 +%% +%% Partitioned matrix code. Works under TeX and LaTeX (all versions) +%% Unfortunately, the syntax of pmat is much closer to that of TeX +%% than to that of LaTeX. +%% +% +% Avoid loading this file more than once +% +\expandafter\ifx\csname pmat@iter\endcsname\relax\else\endinput\fi +% +% Make @ a letter +% +\expandafter\edef\csname pmat@catcode\endcsname + {\catcode`\string @=\the\catcode`\@} +\catcode`\@=11 +% +% How to select the dash shape +% cross (A): horizontal and vertical dash lines cross each other +% nocross (B): horizontal and vertical dash lines do not cross each other +% +\def\pmatcross{\def\pmat@hdash{\pmat@hdashA}\def\pmat@vdash{\pmat@vdashA}} +\def\pmatnocross{\def\pmat@hdash{\pmat@hdashB}\def\pmat@vdash{\pmat@vdashB}} +\pmatcross %The default +% +% Debug flag +% +\newif\ifpmat@debug\pmat@debugfalse +% +% Extra facilities are provided under LaTeX2e +% +\ifx\ProvidesPackage\undefined\else + \ProvidesPackage{pmat}[1996/01/01 v0.1] + \DeclareOption{debug}{\pmat@debugtrue}%Undocumented feature + \DeclareOption{cross}{\pmatcross} + \DeclareOption{nocross}{\pmatnocross} + \ProcessOptions +\fi +% +% Debug code. If enabled it draws a bounding box around each matrix entry. +% +\ifpmat@debug + \def\pmat@hidehrule#1#2{\kern-#1% + \hrule height#1 depth#2 \kern-#2} + \def\pmat@hidevrule#1#2{\kern-#1{\dimen0=#1% + \advance\dimen0 by#2\vrule width\dimen0}\kern-#2} + \def\pmat@makeblankbox#1#2{\hbox{\lower\dp0\vbox{\pmat@hidehrule{#1}{#2}% + \kern-#1 \hbox to \wd0{\pmat@hidevrule{#1}{#2}% + \raise\ht0\vbox to #1{}% + \lower\dp0\vtop to #1{}% + \hfil\pmat@hidevrule{#2}{#1}}% + \kern-#1\pmat@hidehrule{#2}{#1}}}} +\fi +% +% All pmat internal parameters can be accessed/changed externaly through +% the macros \pmatget and \pmatset (to hide the names of the parameters). +% Currently there are 7 parameters defined: +% +% 0 pmat@dashwidth ------- length of one dash ``unit'' +% 1 pmat@dashheight ------ thickness of the dash lines +% 2 pmat@minlinegap ------ the minimum gap between lines +% 3 pmat@mincolumngap ---- the minimum gap between columns +% 4 pmat@minentrywidth --- minimum width of each entry of the matrix +% 5 pmat@minentryheight -- minimum height of each entry of the matrix +% 6 pmat@minentrydepth --- minimum depth of each entry of the matrix +% +\newdimen\pmat@dashwidth\pmat@dashwidth=2.88pt +\newdimen\pmat@dashheight\pmat@dashheight=.36pt +\newdimen\pmat@minlinegap\pmat@minlinegap=2pt +\newdimen\pmat@mincolumngap\pmat@mincolumngap=8pt +\newdimen\pmat@minentrywidth\pmat@minentrywidth=0pt +\newdimen\pmat@minentryheight\pmat@minentryheight=6pt +\newdimen\pmat@minentrydepth\pmat@minentrydepth=1.5pt +%% 2.88 and .36pt correspond to an integral number of pixels at +%% 400dpi and 600 dpi. +%% minentrydepth+0.5(minlinegap+dashheight) should be smaller than dashwidth +\def\pmatget#1{\ifcase#1\pmat@dashwidth\or\pmat@dashheight\or + \pmat@minlinegap\or\pmat@mincolumngap\or\pmat@minentrywidth\or + \pmat@minentryheight\or\pmat@minentrydepth\fi} +\def\pmatset#1#2{\ifcase#1\pmat@dashwidth=#2\or\pmat@dashheight=#2\or + \pmat@minlinegap=#2\or\pmat@mincolumngap=#2\or\pmat@minentrywidth=#2\or + \pmat@minentryheight=#2\or\pmat@minentrydepth=#2\fi} +% +% Some useful macros +% +\def\pmat@roundup#1{\advance\dimen#1 by \pmat@dashwidth + \advance\dimen#1 by -1sp + \divide\dimen#1 by \pmat@dashwidth + \multiply\dimen#1 by \pmat@dashwidth} +\def\pmat@normalizebox#1{\setbox0=\hbox{#1}% + \ifdim\wd0>\pmat@minentrywidth + \dimen0=\wd0\else\dimen0=\pmat@minentrywidth\fi + \ifdim\ht0>\pmat@minentryheight + \dimen2=\ht0\else\dimen2=\pmat@minentryheight\fi + \ifdim\dp0>\pmat@minentrydepth + \dimen4=\dp0\else\dimen4=\pmat@minentrydepth\fi + \advance\dimen0 by.5\pmat@mincolumngap\advance\dimen0 by\pmat@dashheight + \advance\dimen2 by.5\pmat@minlinegap\advance\dimen2 by.5\pmat@dashheight + \advance\dimen4 by.5\pmat@minlinegap\advance\dimen4 by.5\pmat@dashheight + \pmat@roundup0\advance\dimen0 by-\wd0\pmat@roundup2\pmat@roundup4% + \hbox{\vrule width 0pt height\dimen2 depth\dimen4% + \kern.5\dimen0% + \ifpmat@debug + \copy0\kern-\wd0\pmat@makeblankbox{0pt}{0.1pt}% + \else + \box0% + \fi + \kern.5\dimen0}} +\def\pmat@hdashA{\cleaders\hbox to \pmat@dashwidth{\hss\vrule + width .5\pmat@dashwidth height .5\pmat@dashheight depth .5\pmat@dashheight + \hss}\hfill} +\def\pmat@hdashB{\cleaders\hbox to \pmat@dashwidth{\vrule + width .25\pmat@dashwidth height .5\pmat@dashheight depth .5\pmat@dashheight + \hss\vrule + width .25\pmat@dashwidth height .5\pmat@dashheight depth .5\pmat@dashheight + }\hfill} +\def\pmat@vdashA{\cleaders\vbox to \pmat@dashwidth{\vss\hrule + width \pmat@dashheight height .5\pmat@dashwidth depth 0pt\vss}\vfill} +\def\pmat@vdashB{\cleaders\vbox to \pmat@dashwidth{\hrule + width \pmat@dashheight height .25\pmat@dashwidth depth 0pt\vss\hrule + width \pmat@dashheight height .25\pmat@dashwidth depth 0pt}\vfill} +\def\pmat@iter#1{\ifx#1\end\let\next=\relax\else + \let\next=\pmat@iter\edef\pmat@arg{#1\pmat@arg}% + \edef\pmat@omit{\omit\hfil&\pmat@omit}\fi\next} +\def\pmat@build#1{\let\pmat@arg=\empty\def\pmat@omit{\omit\hfil\cr}% + \pmat@iter#1\end} +\def\pmat@nextitem#1#2\end{\def\pmat@arg{#2}%\message{(#1)} + \global\setbox3=\hbox{\kern\wd0\if#1|\kern-.5\pmat@dashheight + \copy2\kern-.5\pmat@dashheight\fi\unhbox3}} +% +% The main pmat macros +% +\def\pmat#1#2#3{\def\pmat@delimL{#1}\pmat@build{#2}\def\pmat@delimR{#3}% + \setbox0=\hbox{$\left#1 TEST \right#3$}%To test delimiters + \setbox0=\vbox\bgroup\offinterlineskip\tabskip=0pt% + \everycr{}\def\-{\noalign{\penalty 1}}% + \halign\bgroup&\hfil\pmat@normalizebox{$##$}\hfil\cr} +\def\endpmat{\pmat@omit + \egroup\egroup + \dimen0=\ht0\advance\dimen0 by\dp0% + \setbox2=\vbox to \dimen0{\kern.5\pmat@dashwidth + \pmat@vdash\kern.5\pmat@dashwidth}% + \ht2=\ht0\dp2=\dp0% + \setbox4=\hbox to \wd0{\kern.5\pmat@dashwidth + \pmat@hdash\kern.5\pmat@dashwidth}% + \ht4=0pt\dp4=0pt% + \setbox0=\vbox{\offinterlineskip\unvbox0% + \global\setbox1=\vbox{}% + \setbox0=\lastbox +%% Unpack and process last hbox of alignment (generated by \pmat@omit) + \setbox0=\hbox{\unhbox0\unskip + \setbox0=\lastbox + \global\setbox3=\hbox{\kern\wd0}% + \loop + \unskip\setbox0=\lastbox + \ifhbox0\expandafter\pmat@nextitem\pmat@arg-\end\repeat}% +%% Place dashed lines where requested between the lines of the alignment + \loop + \skip0=\lastskip\unskip + \ifnum\lastpenalty>0\unpenalty\global\setbox1=\vbox{\copy4\unvbox1}\fi + \setbox0=\lastbox + \ifhbox0\global\setbox1=\vbox{\box0\unvbox1}\repeat}% +% \delimmiterfactor=975 +% \delimitershortfall=2pt + \left\pmat@delimL + \dimen0=\wd3\vcenter{\hbox{\kern-.4\pmat@dashwidth + \raise-\dp1\box3\kern-\dimen0\box1\kern-.4\pmat@dashwidth}}% + \right\pmat@delimR +} +% +% restore catcode of @ +% +\pmat@catcode +% +% That's all, folks! +% +\endinput diff --git a/macros/generic/pmat/pmat.tex b/macros/generic/pmat/pmat.tex new file mode 100644 index 0000000000..63a97d2b30 --- /dev/null +++ b/macros/generic/pmat/pmat.tex @@ -0,0 +1,156 @@ +\documentclass[a4paper]{article} +\usepackage{pmat} + +\begin{document} + +\title{The \texttt{pmat} package to typeset partitioned matrices} +\author{Tom\'as Oliveira e Silva \\[4pt] Universidade de Aveiro \\ + Aveiro, Portugal \\[8pt] email: \texttt{tos@inesca.pt}} +\date{January 1, 1996} +\maketitle + +This document is a very short description of the \texttt{pmat} package, +version $0.1$. The \texttt{pmat} package provides the macros \verb+\pmat+ +and \verb+\endpmat+ to typeset partitioned matrices, and it works under +\TeX\ and under \LaTeX\ (any version). Under \LaTeX\ it is possible to replace +\verb+\pmat+ and \verb+\endpmat+ by \verb+\begin{pmat}+ and \verb+\end{pmat}+, +respectively. + +The \verb+\pmat+ macro takes three arguments. The first one is a left +delimiter (the thing you put immediately after a \verb+\left+ command). +The last one is a right delimiter (the thing you put immediately after a +\verb+\right+ command). As usual, a delimiter may be omitted by using a dot +(.). The middle argument specifies the dashed vertical lines that are to be +placed between columns of the matrix. This argument must contain exactly $n-1$ +characters, where $n$ is the number of columns of the matrix. If a character +is a \verb+|+ then a dashed vertical line will be placed between the +appropriate columns. Otherwise, no dashed line will be placed between those +columns (we recommend the use of the character dot (.) in these cases) . The +format of the entries of the partitioned matrix follows the conventions of +plain \TeX, i.e., entries are separated by a \verb+&+ (just like in \LaTeX), +but lines are separated by a \verb+\cr+ (instead of the \verb+\\+ used in +\LaTeX). All entries are typeset in math mode (in \verb+\textstyle+). For +technical reasons, a \verb+\cr+ must also be placed at the end of the last +line. The placement of horizontal dashed lines is done with the command +\verb+\-+, which must be placed immediately after the command \verb+\cr+. For +example, the code +\begin{verbatim} +\[ + \begin{pmat}[{.|}] + a_{11} & a_{12} & b_{11} \cr + a_{21} & a_{22} & b_{21} \cr\- + c_{11} & c_{12} & d_{11} \cr + \end{pmat} +\] +\end{verbatim} +produces the matrix +\[ + \begin{pmat}[{.|}] + a_{11} & a_{12} & b_{11} \cr + a_{21} & a_{22} & b_{21} \cr\- + c_{11} & c_{12} & d_{11} \cr + \end{pmat} +\] + +There are two macros that can be used to modify the shape of the crossings +between horizontal and vertical dash lines. The first one, \verb+\pmatcross+, +makes horizontal and vertical dash lines to cross. (It is the default.) The +other, \verb+\pmatnocross+, makes the lines not to cross. Under \LaTeX2e, the +first one can be made the default (it already is) by passing the option +\verb+cross+ to the package, and the second one can be made the default by +passing the option \verb+nocross+ to the package. The difference between the +two forms can be examined in the following example (before the second +\verb+\begin{pmat}+ we have put a \verb+\pmatnocross+) +\[ + \begin{pmat}[{.|}] + a_{11} & a_{12} & b_{11} \cr + a_{21} & a_{22} & b_{21} \cr\- + c_{11} & c_{12} & d_{11} \cr + \end{pmat} + \qquad\qquad + \pmatnocross\begin{pmat}[{.|}] + a_{11} & a_{12} & b_{11} \cr + a_{21} & a_{22} & b_{21} \cr\- + c_{11} & c_{12} & d_{11} \cr + \end{pmat} +\] + +There are seven internal parameters that control the inner workings of the +\verb+pmat+ macros. To hide their names they can only be accessed or changed +through the macros \verb+\pmatget+ and \verb+\pmatset+. The \verb+\pmatget+ +macro takes one argument, the number of the parameter (from 0 to 6). It +``returns'' the current value of that parameter. The \verb+\pmatset+ macro +takes two arguments, the number of the parameter, and its new value. All +parameters are dimensions, so do not forget to put a unit of length (such as +\verb+mm+) after its numerical value. The seven parameters are the following: +\begin{description} + \item[0] This parameter controls the length of a dash ``unit''. All + horizontal and vertical dash lines have a length that is an integer + multiple of this parameter. Its default value is \verb+2.88pt+. + \item[1] This parameter controls the thickness of the dash lines. Its + default value is \verb+0.36pt+. + \item[2] This parameter controls the minimum distance between two lines. Its + default value is \verb+2pt+. + \item[3] This parameter controls the minimum distance between two columns. + Its default value is \verb+8pt+. + \item[4] This parameter controls the minimum width of each entry of the + matrix. Its default value is \verb+0pt+. + \item[5] This parameter controls the minimum height of each entry of the + matrix. Its default value is \verb+6pt+. + \item[6] This parameter controls the minimum depth of each entry of the + matrix. Its default value is \verb+1.5pt+. +\end{description} +Due to the way lengths are quantized, to avoid larger than strictly necessary +gaps between lines the values of $[5]+([1]+[2])/2$ and $[6]+([1]+[2])/2$ +should be smaller but close to a multiple of $[0]$. (A number inside square +brackets refers to the corresponding parameter.) For example, the code +\begin{verbatim} +\[ + \pmatset{1}{0.72pt} + \pmatset{0}{2\pmatget{1}} + \pmatset{5}{0pt} + \pmatset{6}{0pt} + \begin{pmat}[{||}] + A_{11} & A_{12} & A_{13} \cr\- + A_{21} & A_{22} & A_{23} \cr\- + A_{31} & A_{32} & A_{33} \cr + \end{pmat} +\] +\end{verbatim} +produces the matrix +\[ + \pmatset{1}{0.72pt} + \pmatset{0}{2\pmatget{1}} + \pmatset{5}{0pt} + \pmatset{6}{0pt} + \begin{pmat}[{||}] + A_{11} & A_{12} & A_{13} \cr\- + A_{21} & A_{22} & A_{23} \cr\- + A_{31} & A_{32} & A_{33} \cr + \end{pmat} +\] + +For a uniform look of the document all matrices, partitioned and not +partitioned, should be typeset using the \verb+pmat+ macros. + +\bigskip +{\bfseries Possible future improvements:} Instead of quantizing the height and +depth of each entry separately, maybe their sum should be quantized. Perhaps +the minimum height and depth of each entry should depend upon the current font +size. + +\bigskip +\hrule height 1pt +\[ + \begin{pmat}[{|}] + \mathbf{A} & \mathbf{B} \cr\- + \mathbf{C} & \mathbf{D} \cr + \end{pmat} = \begin{pmat}[{.|}] + -k_1 & -k_2\sqrt{1-k^2_1} & \sqrt{(1-k^2_1)(1-k^2_2)} \cr + \sqrt{1-k^2_1} & -k_1k_2 & k_1\sqrt{1-k^2_2} \cr\- + 0 & \sqrt{1-k^2_2} & k_2 \cr + \end{pmat} +\] + + +\end{document} diff --git a/macros/generic/pmat/readme b/macros/generic/pmat/readme new file mode 100644 index 0000000000..1e82e933a5 --- /dev/null +++ b/macros/generic/pmat/readme @@ -0,0 +1,11 @@ +The pmat package can be used to typeset partitioned matrices in +TeX, LaTeX, and LaTeX2e. I hope it will be useful to you. Please +let me know of any suggestions for improvement, general comments, +etc. My e-mail address is tos@inesca.pt + +The package is provided "as is". The files pmat.tex, pmat.sty and +readme (this file) should be copied together. These files are +freeware. You should not change them in any way, nor use them in +a commercial product without prior concent. + +Tom\'as Oliveira e Silva |