1

I've been struggling to fit a large matrix on a page, and have finally managed to fit it in, although I had to make the entries very small. Now I want label the rows and columns of the matrix. There is a good answer already on how to do this: Label rows of a matrix by characters.

However, I am using a different environment to the ones used in the answers to that topic. Since it took me a long time to get my large matrix to fit on the page, I don't want to have to start again from scratch. Is there some code that will allow me to add labelling around the edge whilst only requiring minor alterations to what I already have?

Here is what it looks like now:

Large matrix

Here is the code I have so far:

\documentclass[10pt,a4paper]{article}
\usepackage{amsmath} % for equation* and bmatrix environment
\usepackage{anyfontsize}

\setcounter{MaxMatrixCols}{20} % for the large matrices

\begin{document}

{\fontsize{4.9}{5.8}\selectfont % Fontsize may only come in 4pt and 5pt because there is a huge leap from 4.9 to 5
\noindent\hspace{-1.7in}\begin{minipage}{\dimexpr \textwidth+3.4in}
\begin{equation*}\setlength\arraycolsep{3pt}
\begin{pmatrix}
Lk(l_{1,1},l_{1,1}^{\#}) & Lk(l_{1,1},l_{1,2}^{\#}) & \cdots & \cdots & \cdots   & \cdots & \cdots & \cdots & \cdots & \cdots & Lk(l_{1,1},l_{\frac{n}{2}-1,\frac{m}{2}-1}^{\#}) \\
Lk(l_{1,2},l_{1,1}^{\#}) & Lk(l_{1,2},l_{1,2}^{\#}) & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots &\vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots  & \ddots & \vdots \\
\vdots & \ddots & \ddots & Lk(l_{1,\frac{m}{2}-1},l_{1,\frac{m}{2}-1}^{\#}) &   Lk(l_{1,\frac{m}{2}-1},l_{2,1}^{\#}) & \ddots & \ddots & \ddots & \ddots & \ddots & \vdots \\
\vdots & \ddots & \ddots  & Lk(l_{2,1},l_{1,\frac{m}{2}-1}^{\#}) & Lk(l_{2,1},l_{2,1}^{\#}) & \ddots & \ddots & \ddots & \ddots & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots & Lk(l_{2,\frac{m}{2}-1},l_{2,\frac{m}{2}-1}^{\#}) & Lk(l_{2,\frac{m}{2}-1},l_{2,2}^{\#}) & \ddots & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots & Lk(l_{2,2},l_{2,\frac{m}{2}-1}^{\#}) & Lk(l_{2,2},l_{2,2}^{\#}) & \ddots & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots  & Lk(l_{\frac{n}{2}-2,\frac{m}{2}-2},l_{\frac{n}{2}-2,\frac{m}{2}-2}^{\#}) & Lk(l_{\frac{n}{2}-1,\frac{m}{2}-1},l_{\frac{n}{2}-1,\frac{m}{2}-2}^{\#})  \\
Lk(l_{\frac{n}{2}-1,\frac{m}{2}-1},l_{1,1}^{\#}) & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots    & \cdots  & \cdots & Lk(l_{\frac{n}{2}-1,\frac{m}{2}-2},l_{\frac{n}{2}-1,\frac{m}{2}-1}^{\#}) & Lk(l_{\frac{n}{2}-1,\frac{m}{2}-1},l_{\frac{n}{2}-1,\frac{m}{2}-1}^{\#}) \\
\\
\end{pmatrix}
\end{equation*}
\end{minipage}\hspace{-1.7in}
}

\end{document}

Apologies in advance for all the horizontal scrolling you will have to do: I'm not sure how to prevent that.

  • You mean to label both rows and columns? – Steven B. Segletes Jul 10 '15 at 15:17
  • Yes, that's right. – IIM Jul 10 '15 at 15:20
2

submatrix representation

\documentclass[10pt,a4paper]{article}
\usepackage{amsmath} % for equation* and bmatrix environment
\usepackage{anyfontsize}

\setcounter{MaxMatrixCols}{20} % for the large matrices

\begin{document}

I'm trying to figure out the pattern here. 
You might consider a submatrix representation of the form
\begin{equation*}
\left( \begin{array}{c|c|c|c}
A(1,1) & A(1,2) & \cdots & A(1,m) \\
\hline
A(2,1) & A(2,2) & \cdots & A(2,m) \\
\hline
\vdots & \vdots & \ddots & \vdots \\
\hline
A(n,1) & A(n,2) & \cdots & A(n,m)
\end{array} \right)
\end{equation*}
where each $\frac{m}{2}-1\times \frac{m}{2}-1$ submatrix is given by 
\begin{equation*}
\def\arraystretchfactor{1.2}
A(i,j) = \begin{pmatrix}
Lk(l_{i,1},l_{j,1}^{\#}) & Lk(l_{i,1},l_{j,2}^{\#}) & \cdots & Lk(l_{i,1},l_{j,\frac{m}{2}-1}^{\#}) \\
Lk(l_{i,2},l_{j,1}^{\#}) & Lk(l_{i,2},l_{j,2}^{\#}) & \cdots & Lk(l_{i,2},l_{j,\frac{m}{2}-1}^{\#}) \\
\vdots & \vdots & \ddots & \vdots \\
Lk(l_{i,\frac{m}{2}-1},l_{j,1}^{\#}) & Lk(l_{i,\frac{m}{2}-1},l_{j,2}^{\#}) & \cdots & Lk(l_{i,\frac{m}{2}-1},l_{j,\frac{m}{2}-1}^{\#})
\end{pmatrix}
\quad.
\end{equation*}

\end{document}

BTW, it is possible (but difficult) to show row and column indexes on the outside of a matrix, but with a submatrix representation you shouldn't need it.

  • At first I wasn't sure if this would work, but looking closely I see it does - and also it fixes the problem of fitting the large matrix on the page. Really nice answer. – IIM Jul 12 '15 at 16:27
  • On second thought, it might look better to drop the division lines, or use the arydshln package. – John Kormylo Jul 12 '15 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.