I am working with tabulars formatted in a consistent way. Sometimes the tables are 3X3, 3X4, 4X4 etc nXm in general. As it is I have a macro for each of these tables: \matrixIIIC
, \matrixIIID
etc. Is there a way to define a single macro that would cover all these cases such that as syntax it would look like: \matrix{3}{3}
, \matrix{3}{4}
etc?
Below is a MWE that shows what I so far have for one of the macros. Ideally, the column and row numbering would also be automatic.
\documentclass{article}
\usepackage{xparse}
\usepackage{multirow}
\usepackage{graphicx}
\DeclareDocumentCommand{\matrixIVD}{ O{RowName} O{ColumnName} }{%
\begin{tabular}{c|*{5}{c|}}
\multicolumn{2}{c}{} &\multicolumn{4}{c}{#2} \\\cline{3-6}
\multicolumn{1}{c}{}& & a&b&c&d\\\cline{2-6}
\multirow{8}{*}{\rotatebox[origin=c]{90}{#1}}
&1&&&&\\
&2&&&&\\
&3&&&&\\
&4&&&&\\\cline{2-6}
\end{tabular}%
}%
\begin{document}
\matrixIVD
\end{document}
which produces as output
Oh, and the rowname needs to be automatically centered too!
\cellIA
) and these I would appropriately redfine befoe the call of\matrix{}{}
. – Geoff Nov 11 '14 at 20:00