\documentclass[a4paper]{article} \usepackage{easymat}% \let\package\texttt % so \package{foo} comes out in \tt \let\envname\textsf % so \envname{foo} comes out as \sf \title{The package \package{easymat}} \author{Enrico Bertolazzi\\\\ Laboratorio di Matematica Applicata\\ Dipartimento di Ingegneria Civile ed Ambientale\\ Universit\`a degli Studi di Trento\\ Mesiano, Trento, Italy\\\\ \texttt{bertolaz@ing.unitn.it}} \date{} \begin{document} \maketitle \begin{abstract} The \package{easymat} package is a macro package for writing block matrices, with various kinds of rules~(lines) between rows or columns, and uses an array/tabular-like syntax. \end{abstract} \section{Some examples with \package{easymat}} This package was inspired by the package \package{pmat}, version~0.1, of Tom\'as Oliveira~e~Silva. This beautiful package allows easy construction of partitioned matrices. Unfortunately, at least this version, the package is not reentrant, so you cannot build block matrices which contain more block matrices. I have solved this problem writing a similar package with different features (some things have been added and some others avoided), however, the algorithms are essentially the same as those of \package{pmat}. Load the package in the usual way: \begin{verbatim} \documentclass{article} . . \usepackage[thinlines,thiklines]{easymat} . . \end{verbatim} The options \texttt{thinlines}, and \texttt{thiklines} are self explanatory. \package{easymat} provides the \envname{MAT}~environment which is a simple re-implementation of the array/tabular environment, with some limitation and some additional features. The syntax is \begin{verbatim} \begin{MAT}`[3pt]'`{ccl:c}' a & b & ... & n \\`[2mm]'`;' . \end{MAT} \end{verbatim} where \verb+`[3pt]'+ is an optional spacing between row and columns, \verb+`{ccl:c}'+ is the definition of the column (like tabular or array), \verb+`[2mm]'+ is an optional spacing argument for the row, `;' is an optional definition of the row rule. The main feature of the \envname{MAT}~environment is that it is reentrant: \begin{verbatim} \[ \left[\begin{MAT}{cc} 1 & 2 \\ 3 & \left(\begin{MAT}{cc} a & b \\ c & d \end{MAT}\right) \end{MAT}\right] \] \end{verbatim} which produces \[ \left[\begin{MAT}{cc} 1 & 2 \\ 3 & \left(\begin{MAT}{cc} a & b \\ c & d \end{MAT}\right) \end{MAT}\right] \] As in \envname{tabular} or \envname{array} it is possible to define columns as rules or dashes: \begin{verbatim} \[ \begin{MAT}{|c:c;rl} 1 & b & c & f\\ 1 & 2 & 3 & h\\ 1 & b & csssss & \\ 1 & b & c & \frac{1}{2} \\ A & B & C & d \end{MAT} \] \end{verbatim} produces \[ \begin{MAT}{|c:c;rl} 1 & b & c & f\\ 1 & 2 & 3 & h\\ 1 & b & csssss & \\ 1 & b & c & \frac{1}{2} \\ A & B & C & d \end{MAT} \] \texttt r,~\texttt c,~\texttt l~mean ``right'', ``center'', and ``left'' alignment. The available rules for the columns are \begin{center} \begin{tabular}{|l|l|} \hline nothing & no rule \\ \verb+|+ & solid line \\ \verb+:+ & dash line \\ \verb+;+ & dot-dash line \\ \verb+,+ & dotted line \\ \hline \end{tabular} \end{center} The lines are ended by \verb+\\+ for which we can use \verb+[ ]+ as an optional argument for spacing and an optional character for the definition of a rule. The character codes are the following \begin{center} \begin{tabular}{|l|l|} \hline nothing & no rule \\ \verb+-+ & solid line \\ \verb+:+ & dash line \\ \verb+;+ & dot-dash line \\ \verb+,+ & dotted line \\ \hline \end{tabular} \end{center} In order to avoid bad alignment for the first (empty) and the last line is better to use the commands \verb+\first+ and \verb+\last+ instead of \verb+\\+. The following example shows some of the features \begin{verbatim} \[ A=\left(\begin{MAT}{|c;c;c|} \first: 1 & b & c \\; 1 & \begin{MAT}[0pt]{|l:l|} \first -11 & 12 \\: 13 \last- \end{MAT} & c \\- 1 & b & csssss \\: 1 & b & c \\; A & B & C \last- \end{MAT}\right) \] \end{verbatim} \[ A=\left(\begin{MAT}{|c;c;c|} \first: 1 & b & c \\; 1 & \begin{MAT}[0pt]{|l:l|} \first -11 & 12 \\: 13 \last- \end{MAT} & c \\- 1 & b & csssss \\: 1 & b & c \\; A & B & C \last- \end{MAT}\right) \] This final example shows a slightly more complex (reentrant) definition in which the \envname{MAT}~environment is used: \begin{verbatim} \def\recurse#1#2\end{% \if\noexpand#1-\def\next##1##2{}\else\let\next=\recursea\fi% \expandafter\next{#1}{#2}% }% \def\recursea#1#2{% \bgroup% \begin{MAT}{c;c|c}% \expandafter\recurse#2-\end & #1 &% \expandafter\recurse#2-\end \\-% #1 &% \expandafter\recurse#2-\end &% #1 \\;% \expandafter\recurse#2-\end &% #1 &% \expandafter\recurse#2-\end% \end{MAT}% \egroup% } \[ \recurse\clubsuit\diamondsuit\heartsuit\end \] \end{verbatim} \typeout{This example can take a while to compile on small machine, please wait...} It produces the following output: \def\recurse#1#2\end{% \if\noexpand#1-\def\next##1##2{}\else\let\next=\recursea\fi% \expandafter\next{#1}{#2}% }% \def\recursea#1#2{% \bgroup% \begin{MAT}{c;c|c}% \expandafter\recurse#2-\end & #1 &% \expandafter\recurse#2-\end \\-% #1 &% \expandafter\recurse#2-\end &% #1 \\;% \expandafter\recurse#2-\end &% #1 &% \expandafter\recurse#2-\end% \end{MAT}% \egroup% } \[ \recurse\clubsuit\diamondsuit\heartsuit\end \] \typeout{...thanks, I have done} \end{document}