[Tex/LaTex] Typsetting big matrix (but keeping A4 size)

diagramsfontsizemath-modematrices

This question is a slight variation of Compiling a BIG matrix, but I need to write a matrix in a A4 or letter size paper; it is a block 48×48 matrix but I can put lot of $0_2$ and $0_4$'s in order to keep a small number of entries, which, however, exceed the usual dimensions. How could I make the font smaller or the spaces between the entries (most of them 0) narrower in order for this matrix to fit in the page? For instance, the first rows are

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{pmatrix}
0 & 0 & B & 0 & 0 & 0& 0& 0 & A & 0& 0& 0 & 0 & 0& 0& 0 \\
0 & 0 & 0 & C & 0 & 0& 0& 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0 \\
D & 0 & 0 & 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0 \\
0 & E & 0 & 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0  
\end{pmatrix}
\]
\end{document}

Best Answer

The following example uses three different methods:

  • The distance between the entries can be set by \arraycolsep.

  • The font size can be decreased by switching to text mode, setting the smaller font size and going back to math.

  • And finally the whole equation can be scaled to fit the line width using the package resizegather if amsmath is used.

The whole example:

\documentclass[12pt]{article}
\usepackage[a6paper]{geometry}
\usepackage{amsmath}
\setcounter{MaxMatrixCols}{48}
\usepackage{resizegather}
\begin{document}
\hrule
\begin{gather*}
  \setlength{\arraycolsep}{.75\arraycolsep}
  \text{\footnotesize$\displaystyle
    \begin{pmatrix}
      0 & 0 & B & 0 & 0 & 0& 0& 0 & A & 0& 0& 0 & 0 & 0& 0& 0 \\
      0 & 0 & 0 & C & 0 & 0& 0& 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0 \\
      D & 0 & 0 & 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0 \\
      0 & E & 0 & 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0 & 0 & 0& 0& 0
    \end{pmatrix}
  $}
\end{gather*}
\hrule
\end{document}

Result