# Shrinking or splitting some equations in a group of equations

I have a group of equations, such as

/begin{gather}
Eq1
// Eq2
// Eq3
// Eq4
/end{gather}


Unfortunately, some of the equations in the group are too long to fit on the page. For equations that are only slightly too long, is there a way to slightly decrease the font size of that equation only? For equations that are much too long, is there any automated way to split the equation (where the computer decides where and how to split it to fit the page width), or would this split need to be defined by the user?

Thank you, Kevin

P.S. Here is my code where the matrix is too wide and goes off the end of the page:

\documentclass{article}
\begin{document}
$\mathbf{L} = \left[ \begin{array}{*{6}{c}} {{L_S}}&{ - {L_{SS}}}&{ - {L_{SS}}}&{M\cos \theta }&{M\cos \left( {\theta + \frac{{2\pi }}{3}} \right)}&{M\cos \left( {\theta - \frac{{2\pi }}{3}} \right)}\\ { - {L_{SS}}}&{{L_S}}&{ - {L_{SS}}}&{M\cos \left( {\theta - \frac{{2\pi }}{3}} \right)}&{M\cos \theta }&{M\cos \left( {\theta + \frac{{2\pi }}{3}} \right)}\\ { - {L_{SS}}}&{ - {L_{SS}}}&{{L_S}}&{M\cos \left( {\theta + \frac{{2\pi }}{3}} \right)}&{M\cos \left( {\theta - \frac{{2\pi }}{3}} \right)}&{M\cos \theta }\\ {M\cos \theta }&{M\cos \left( {\theta - \frac{{2\pi }}{3}} \right)}&{M\cos \left( {\theta + \frac{{2\pi }}{3}} \right)}&{{L_R}}&{ - {L_{RR}}}&{ - {L_{RR}}}\\ {M\cos \left( {{\theta} + \frac{{2\pi }}{3}} \right)}&{M\cos \theta }&{M\cos \left( {\theta - \frac{{2\pi }}{3}} \right)}&{ - {L_{RR}}}&{{L_R}}&{ - {L_{RR}}}\\ {M\cos \left( {{\theta _2} - \frac{{2\pi }}{3}} \right)}&{M\cos \left( {{\theta _2} + \frac{{2\pi }}{3}} \right)}&{M\cos \theta }&{ - {L_{RR}}}&{ - {L_{RR}}}&{{L_R}} \end{array}\right]$
\end{document}

• Have you looked at the postings How can I split an equation over two lines and Breaking equations with breqn?
– Mico
Jul 27, 2015 at 18:58
• Seems like breqn and dmath don't work for splitting matrices as my equation is still too long to fit on the page (due to the long matrix). Is there any way to have Latex automatically split the matrix to fit on the page? Jul 27, 2015 at 22:53
• I edited my question and added the code. Since the matrix is too wide, I need to somehow split it. Jul 28, 2015 at 1:58
• I've taken the liberty of editing your code to make it a stand-alone, compilable LaTeX document. If you feel I've missed some important elements, such as an unusual document class, a special font or font size, or some package that affects the appearance of math-mode material, you should feel free to edit the code some more to supply the missing information.
– Mico
Jul 28, 2015 at 5:59

You have a large 6x6 matrix. I know of no fully automated method to make it fit into the available width of the text block, unless it entails reducing the font size to the point where it becomes necessary to supply a magnifying glass. I can suggest two "manual" adjustment methods, though:

• Assuming the textblock is fairly wide and the font size is not too large (ie., no 12pt or larger), reducing the amount of intercolumn whitespace and switching from an array to a bmatrix environment should suffice to get the job done.

• If the text block is not particularly wide and/or if you use a font size that's larger than about 10pt, it's necessary to break up the matrix into two sub-matrices.

The code below shows how both methods may be applied. The horizontal line at the top of the screenshot is there just to illustrate the width of the text block. Oh, and whichever method you choose in the end, please get rid of the massive number of entirely superfluous curly braces.

\documentclass{article}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{amsmath}
\renewcommand\arraystretch{1.25}

\begin{document}
\hrule

\medskip\noindent
Solution 1: Reduce inter-column whitespace; needs a wide text block to succeed.
\begin{equation*}
\setlength\arraycolsep{3pt} % default value: 5pt
\mathbf{L} =
\begin{bmatrix}
L_S& -L_{SS}& -L_{SS}&M\cos \theta &M\cos \bigl(\theta+\frac{2\pi}{3} \bigr)& M\cos \bigl(\theta- \frac{2\pi}{3}   \bigr)\\
- L_{SS}&L_S&- L_{SS}&M\cos \bigl(\theta- \frac{2\pi}{3} \bigr)&M\cos \theta &M\cos \bigl(\theta+ \frac{2\pi}{3} \bigr)\\
- L_{SS}&- L_{SS}&L_S&M\cos \bigl(\theta+ \frac{2\pi}{3} \bigr)&M\cos \bigl(\theta- \frac{2\pi}{3} \bigr)&M\cos \theta \\
M\cos \theta &M\cos \bigl(\theta- \frac{2\pi}{3} \bigr)&M\cos \bigl(\theta+ \frac{2\pi}{3} \bigr)&L_R& -L_{RR}&-L_{RR}\\
M\cos \bigl( \theta + \frac{2\pi}{3} \bigr)&M\cos \theta&M\cos \bigl(\theta- \frac{2\pi}{3} \bigr)&-L_{RR}&L_R&-L_{RR}\\
M\cos \bigl(\theta _2 - \frac{2\pi}{3} \bigr)&M\cos \bigl( \theta _2 + \frac{2\pi}{3} \bigr)&M\cos \theta&-L_{RR}&-L_{RR}&L_R\\
\end{bmatrix}
\end{equation*}

\bigskip\noindent
Solution 2: Break up the six-column matrix $\mathbf{L}$ into two three-column sub-matrices.

\medskip
Let $\mathbf{L}=\bigl[\, \mathbf{L}_1 \ \mathbf{L}_2 \,\bigr]$, where
\begin{align*}
\mathbf{L}_1 &=
\begin{bmatrix}
L_S& -L_{SS}& -L_{SS}\\
- L_{SS}&L_S&- L_{SS}\\
- L_{SS}&- L_{SS}&L_S\\
M\cos \theta &M\cos \bigl(\theta- \frac{2\pi}{3} \bigr)&M\cos \bigl(\theta+ \frac{2\pi}{3} \bigr)\\
M\cos \bigl( \theta + \frac{2\pi}{3} \bigr)&M\cos \theta&M\cos \bigl(\theta- \frac{2\pi}{3} \bigr)\\
M\cos \bigl(\theta _2 - \frac{2\pi}{3} \bigr)&M\cos \bigl( \theta _2 + \frac{2\pi}{3} \bigr)&M\cos \theta
\end{bmatrix}
\intertext{and}
\mathbf{L}_2 &=
\begin{bmatrix}
M\cos \theta &M\cos \bigl(\theta+\frac{2\pi}{3} \bigr)& M\cos \bigl(\theta- \frac{2\pi}{3}   \bigr)\\
M\cos \bigl(\theta- \frac{2\pi}{3} \bigr)&M\cos \theta &M\cos \bigl(\theta+ \frac{2\pi}{3} \bigr)\\
M\cos \bigl(\theta+ \frac{2\pi}{3} \bigr)&M\cos \bigl(\theta- \frac{2\pi}{3} \bigr)&M\cos \theta\\
L_R& -L_{RR}&-L_{RR}\\
-L_{RR}&L_R&-L_{RR}\\
-L_{RR}&-L_{RR}&L_R
\end{bmatrix}
\end{align*}

\end{document}


Addendum: As @percusse has pointed out in a comment, the 6x6 matrix L is block-symmetric. (Well, it's nearly symmetric; the two stray _2 subscripts are probably typos.) Rather than overwhelm your readers with a printout of the full 6x6 matrix, you may want to draw your readers' attention to this fact, possibly along something close to the following lines:

\documentclass{article}
\usepackage{mathtools}
\renewcommand\arraystretch{1.35}
\newcommand\x{\phantom{-}}
\begin{document}
Consider the block-symmetric matrix
$\mathbf{L}=\begin{bmatrix} \mathbf{L}_{11} & \mathbf{L}_{12}\\ \mathbf{L}_{21}& \mathbf{L}_{22} \\ \end{bmatrix}$
where $\mathbf{L}_{21}=\mathbf{L}'_{12}$ and
\begin{align*}
\mathbf{L}_{11} &=
\begin{bmatrix*}[l]
\x L_S  & -L_{SS}& -L_{SS}\\
- L_{SS}& \x L_S & - L_{SS}\\
- L_{SS}& -L_{SS}& \x L_S\\
\end{bmatrix*}\\
\mathbf{L}_{12} &= M
\begin{bmatrix}
\cos \theta &\cos \bigl(\theta+\frac{2\pi}{3} \bigr)& \cos \bigl(\theta-\frac{2\pi}{3}\bigr)\\
\cos \bigl(\theta-\frac{2\pi}{3} \bigr)&\cos \theta &\cos \bigl(\theta+\frac{2\pi}{3} \bigr)\\
\cos \bigl(\theta+\frac{2\pi}{3} \bigr)&\cos \bigl(\theta-\frac{2\pi}{3} \bigr)&\cos \theta\\
\end{bmatrix}\\
\mathbf{L}_{22} &=
\begin{bmatrix*}[l]
\x L_R& -L_{RR}& -L_{RR}\\
-L_{RR}& \x L_R& -L_{RR}\\
-L_{RR}&-L_{RR}& \x L_R\\
\end{bmatrix*}
\end{align*}
Observe that $\mathbf{L}_{11}$ and $\mathbf{L}_{22}$ are symmetric; hence, the full matrix $\mathbf{L}$ is symmetric as well. (Go on to elaborate what the consequences of this block-symmetry may be.)
\end{document}

• It is a symmetric matrix and structured on the diagonal. This matrix, in my opinion, should not be typeset at all because it is hiding the structure. Jul 28, 2015 at 11:19
• @percusse - On closer inspection, the (6,1) and (6,2) elements of the matrix feature _2, whereas none of the other cells do. This may be a typo in the OP's input, or it may really be there. In any case, the matrix -- at least as posted by the OP -- isn't fully symmetric. :-(
– Mico
Jul 28, 2015 at 11:41
• I think it is a typo but regardless the diagonal blocks are perfectly symmetric and off-diagonals have M as the common factor. There is a lot that can be salvaged. Jul 28, 2015 at 11:48
• @percusse -- Good points! I'll post an addendum to mention these issues.
– Mico
Jul 28, 2015 at 12:00
• Thanks for your very helpful response. Yes, the two stray subscripts were typos that I forgot to remove from a previous equation. The superfluous braces were caused by automatically converting MathType equations to Latex. (The superfluous braces are a drawback, but it's better than retyping all my equations from scratch.) Jul 29, 2015 at 2:52

For such a cases is intended multlined environment from mathools package:

\documentclass[12pt,border=1mm,preview]{standalone}
\usepackage{mathtools}
\begin{document}
\begin{gather}
Eq1     \\
Eq2     \\
% and long equation Eq3
a=\begin{multlined}[t]
\text{first part of very long equation}\\
\text{second part of long equation}\\
\text{and on the end last part}
\end{multlined}    \\
Eq4
\end{gather}
\end{document}


This probably look ugly, maybe will be better to have aligned equations to =, i.e.: use align instead gather.

Edit: Now, when the question is more clear to me, based on @Mico first part of his answer and following to use multline environment see, if the following solution is what you looking for:

\documentclass{article}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{mathtools}
\renewcommand\arraystretch{1.25}

\begin{document}
\hrule
$\begin{multlined} \mathbf{L} = \left[\begin{matrix} L_S & -L_{SS} & -L_{SS} \\ -L_{SS} & L_S & -L_{SS} \\ -L_{SS} & -L_{SS} & L_S \\ M\cos\theta & M\cos\bigl(\theta-\frac{2\pi}{3}\bigr) & M\cos\bigl(\theta+ \frac{2\pi}{3}\bigr) \\ M\cos\bigl(\theta+\frac{2\pi}{3}\bigr) & M\cos\theta & M\cos\bigl(\theta-\frac{2\pi}{3}\bigr) \\ M\cos\bigl(\theta_2-\frac{2\pi}{3}\bigr) & M\cos\bigl(\theta_2+\frac{2\pi}{3}\bigr) & M\cos\theta \\ \end{matrix}\right. \quad\dotsm \\ %second part of matrices ... \dotsm\quad\left.\begin{matrix} M \cos \theta & M\cos\bigl(\theta+\frac{2\pi}{3}\bigr) & M\cos\bigl(\theta-\frac{2\pi}{3}\bigr) \\ M\cos\bigl(\theta-\frac{2\pi}{3}\bigr) & M\cos\theta & M\cos\bigl(\theta+\frac{2\pi}{3}\bigr) \\ M\cos\bigl(\theta+\frac{2\pi}{3}\bigr) & M\cos\bigl(\theta-\frac{2\pi}{3}\bigr) & M\cos\theta \\ L_R & -L_{RR} & -L_{RR} \\ -L_{RR} & L_R & -L_{RR} \\ -L_{RR} & L_{RR} & -L_R \\ \end{matrix}\right] \end{multlined}$
\end{document}


It gives:

• How would this work though for an equation with a wide matrix? (I've edited my question to include the code for my matrix which is too wide to fit on the page.) Jul 28, 2015 at 2:03
• @KevinB, I can not compile your code. Please, add \documentclass{...} used \newcommands and packages. This will make my eventually help easier.I'm afraid that regarding matrix can not be done more than @ThomsWise show in his answer. Jul 28, 2015 at 2:35
• @KevinB, on the first sight, the only possible way to fit matrix with 20 columns into page is to wrote equation in landscape orientation, or split matrix in two (or more) parts and each part put in one multlined line. I will do this, when you will provide MWE (your code has some mismatch with} Jul 28, 2015 at 2:42
• @Zarko - Kevin's original code indeed indicated that the matrix had 20 [!] columns. I turns out that it had "only" six. :-) I've edited the OP's so as to give a more accurate impression of the formatting challenge.
– Mico
Jul 28, 2015 at 8:37

I may be able to offer a set of ugly abominations of dirty solutions here, for which I will probably get bashed from more advanced users ^_^. So take them only as last resort.

If too long means too wide and too wide means slightly too wide, then you may do something like

\documentclass{article}%
\usepackage{graphicx}
\begin{document}%
%
\resizebox{\columnwidth}{!}{\parbox{1.125\columnwidth}{%
$$% 1+2+3+4+5+5+6+7+8+9+9+0+4+5+2+2+4+5+6+7+8+8+5+3++2+1+3+5$$%
}}%
%
\end{document}%


For this, you need to experiment a bit to get the right width for the \parbox. Of course, this will also scale the equation number. If this does not look good for you, you may try instead

\documentclass{article}%
\usepackage{graphicx}
\begin{document}%
%
$$% \resizebox{0.6\columnwidth}{!}{\parbox{1.1\columnwidth}{\ensuremath{\displaystyle{% 1+2+3+4+5+5+6+7+8+9+9+0+4+5+2+2+4+5+6+7+8+8+5+3++2+1+3+5% }}}}%$$%
%
\end{document}%


which does not scale the equation number (but you now need to find two acceptable widths, for \resizebox and for \parbox).

If **too long* means too long vertically, then there seems to be a solution for automated page breaking if you use the align environment together with \allowdisplaybreaks, as outlined in LaTeX equation is always on one page.

Additionally, instead of splitting the equation, you may also put it into a \figure environment and let it float. This way, you can keep it together and you can still reference it from the text. Of course, this introduces a variety of other issues, e.g., it may float before the reference to it, so this might not be applicable. Anyway, here an example:

\documentclass{article}%
\usepackage{lipsum}
\begin{document}%
%
\lipsum[2-5]%
%
Here is where the equation~\ref{eq} should be.

\begin{figure}%
$$% A=\left\{\begin{array}{ll}% 1&\textrm{if }B=5\\% 2&\textrm{if }B=2\\% 3&\textrm{if }B=3\\% 4&\textrm{if }B=4\\% 5&\textrm{if }B=1\\% 6&\textrm{if }B=6\\% 7&\textrm{if }B=7\\% 8&\textrm{if }B=334\\% 9&\textrm{if }B=77\\% x&\textrm{if }B=64\\% y&\textrm{if }B=34\\% z&\textrm{if }B=45\\% a&\textrm{if }B=456\\% b&\textrm{if }B=774\\% c&\textrm{if }B=44\\% \end{array}\right.% \label{eq}%$$%
\end{figure}%
%
\lipsum%
%
\end{document}%


A similar effect might be achieved with the \afterpage package, which avoids the danger of equations floating before their reference but will always put them on the next page:

\documentclass{article}%
\usepackage{afterpage}%
\usepackage{lipsum}%
\begin{document}%
%
\lipsum[2-5]%
%
Here is where the equation~\ref{eq} should be.

\afterpage{%
$$% A=\left\{\begin{array}{ll}% 1&\textrm{if }B=5\\% 2&\textrm{if }B=2\\% 3&\textrm{if }B=3\\% 4&\textrm{if }B=4\\% 5&\textrm{if }B=1\\% 6&\textrm{if }B=6\\% 7&\textrm{if }B=7\\% 8&\textrm{if }B=334\\% 9&\textrm{if }B=77\\% x&\textrm{if }B=64\\% y&\textrm{if }B=34\\% z&\textrm{if }B=45\\% a&\textrm{if }B=456\\% b&\textrm{if }B=774\\% c&\textrm{if }B=44\\% \end{array}\right.% \label{eq}%$$%
}%
%
\lipsum%
%
\end{document}%


Finally, if you are in a two-column document and your equation is too wide for one column, you may also consider putting it into a figure* environment (which enables you to use the full page width). Alternatively, you may use the cuted package's strip environment to get the full page width - and you may again put it into \afterpage to move the equation to the top of the next page.