2

I have a big matrix and each element of it has many stuff. The problem I'm facing is that the align mode is trying to make each equation to be fitted into one page. For example, in the following code I have a matrix in a separate align mode and its elements in another align equation as follows

\documentclass[12pt]{article}
\usepackage{amsmath}



\begin{document}

\begin{align*}
P = 
\left[
\begin{array}{ccccc}
P_{11} & P_{12} & P_{13} & P_{14} \\
P_{21} & P_{22} & P_{23} & P_{24} \\
P_{31} & P_{32} & P_{33} & P_{34} \\
\end{array}
\right]
\end{align*}

where 

\begin{align*}
P_{11} &= XXXXXXXXXXXXX \\
P_{12} &= XXXXXXXXXXXXX \\
P_{13} &= XXXXXXXXXXXXX \\
P_{14} &= XXXXXXXXXXXXX \\
%%%%%%%%%%%%%%%%%%%%%%%%%%
P_{21} &= XXXXXXXXXXXXX \\
P_{22} &= XXXXXXXXXXXXX \\
P_{23} &= XXXXXXXXXXXXX \\
P_{24} &= XXXXXXXXXXXXX \\
%%%%%%%%%%%%%%%%%%%%%%%%%%
P_{31} &= XXXXXXXXXXXXX \\
P_{32} &= XXXXXXXXXXXXX \\
P_{33} &= XXXXXXXXXXXXX \\
P_{34} &= XXXXXXXXXXXXX \\
\end{align*}

\end{document} 

From the below picture, the elements of the matrix are taking more than one page in my actual case, so the elements have been placed in a separate page. The previous page is having only the actual matrix (i.e. P) , therefore the page almost empty. How can I force the equation mode to be in the line text.

enter image description here

1

This is how to adjust things manually. You need to be able to identify the longest elements on the left-hand side (LHS) and right-hand side (RHS) of either set, and use that to prop out the shorter of the two:

enter image description here

\documentclass{article}
\usepackage{mathtools}% Loads amsmath

\begin{document}

\[
  \phantom{P_{333}}
  \mathllap{P} = \mathrlap{
  \left[\begin{array}{ccccc}
    P_{11} & P_{12} & P_{13} & P_{14} \\
    P_{21} & P_{22} & P_{23} & P_{24} \\
    P_{31} & P_{32} & P_{33} & P_{34}
  \end{array}\right]
  }\phantom{YYYYYYYYYYYYYYY}
\]
where 
\begin{align*}
  P_{11} &= XXXXXXXXXXXXX \\
  P_{12} &= XXXXXXXXXXXXX \\
  P_{13} &= XXXXXXXXXXXXX \\
  P_{14} &= XXXXXXXXXXXXX \\
  %%%%%%%%%%%%%%%%%%%%%%%%%%
  P_{21} &= XXXXXXXXXXXXX \\
  P_{22} &= YYYYYYYYYYYYYYY \\% Longest RHS
  P_{23} &= XXXXXXXXXXXXX \\
  P_{24} &= XXXXXXXXXXXXX \\
  %%%%%%%%%%%%%%%%%%%%%%%%%%
  P_{31} &= XXXXXXXXXXXXX \\
  P_{32} &= XXXXXXXXXXXXX \\
  P_{333} &= XXXXXXXXXXXXX \\% Longest LHS
  P_{34} &= XXXXXXXXXXXXX
\end{align*}

\end{document} 

In the example above, P_{333} is the longest LHS member, and YYYYYYYYYYYYYYY is the longest RHS member. We use these to prop out the LHS P and RHS <array> via a \phantom. The original content is set using \mathllap and \mathrlap (mathtools) - a left/right overlap kept in math mode.

Alignment across the page break will not be visible usually to the end-user, so it's typically not needed. However, an easier alternative is to set where using

...
\shortintertext{where}
...

also provided by mathtools (amsmath provides \intertext) - see Is it possible to break up an align environment and keep the tab positions?. You may also want to set \allowdisplaybreaks in the preamble, but that depends on your use of the align-like environments.

4

You can use only one align environment that will break across pages with the \allowdisplaybreaks switch. Note that if you use empheq with option overload, you cannot break across pages anymore. To do so, you will have to use the AmSalign environment. I also replaced array with bmatrix:

\documentclass[12pt]{article}
\usepackage{amsmath}

\begin{document}
\mbox{}
\vskip10cm
\allowdisplaybreaks
\begin{align*}
P & =
\begin{bmatrix}
P_{11} & P_{12} & P_{13} & P_{14} \\
P_{21} & P_{22} & P_{23} & P_{24} \\
P_{31} & P_{32} & P_{33} & P_{34} \\
\end{bmatrix}
\intertext{where}
P_{11} &= XXXXXXXXXXXXX \\
P_{12} &= XXXXXXXXXXXXX \\
P_{13} &= XXXXXXXXXXXXX \\
P_{14} &= XXXXXXXXXXXXX \\
%%%%%%%%%%%%%%%%%%%%%%%%%%
P_{21} &= XXXXXXXXXXXXX \\
P_{22} &= XXXXXXXXXXXXX \\
P_{23} &= XXXXXXXXXXXXX \\
P_{24} &= XXXXXXXXXXXXX \\
%%%%%%%%%%%%%%%%%%%%%%%%%%
P_{31} &= XXXXXXXXXXXXX \\
P_{32} &= XXXXXXXXXXXXX \\
P_{33} &= XXXXXXXXXXXXX \\
P_{34} &= XXXXXXXXXXXXX \\
\end{align*}

\end{document} 

enter image description here

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.