# Wrap/break equations text when exporting to PDF

So I just finished writing my homework in Lyx and I was about to print it after exporting to PDF, but I noticed that some of the centered equations were too long and their most-right part is exceeding the right margin of the PDF page.

I saw that I can use AMSmath to solve it but for that it seems like I need to manually copy all of the equations to AMSmath boxes.

Is there any way to solve it with a quick PDF-export preprocess? edit some setting?

This is one of the long equations (gaussian elimination):

\L{
$\left(\begin{matrix}0 & 0 & 0\\ 2 & 0 & 2\\ 8 & 0 & 2\\ 18 & 0 & 2 \end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\ 1 & 0 & 1\\ 4 & 0 & 1\\ 9 & 0 & 1 \end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\ 1 & 0 & 1\\ 4 & 0 & 1\\ 5 & 0 & 0 \end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\ 1 & 0 & 1\\ 4 & 0 & 1\\ 1 & 0 & 0 \end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\ 1 & 0 & 1\\ 0 & 0 & 1\\ 1 & 0 & 0 \end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\ 0 & 0 & 1\\ 0 & 0 & 1\\ 1 & 0 & 0 \end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 1\\ 1 & 0 & 0 \end{matrix}\right)\to\left(\begin{matrix}1 & 0 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ 0 & 0 & 0 \end{matrix}\right)$
}


and as you can see in the PDF it's being cut right before the end: thanks...

• Better than you add your PDF result too, so we can see the problem clearly. Oct 29 '17 at 18:49
• Does Lyz support \usepackage{showframe} ? Oct 30 '17 at 14:45

Just use \multline in package amsmath to divide long expressions taking more than one line.

\begin{multline}
a+b+c+d+e+f+g+h+i+j+k+l+m\\
+n+o+p+q+r+s+t+w+x+y+z=0
\end{multline}


It will divide that long equation into 2 line.

Or you can use gather environment (gather*) if you need a non-numbered equation).

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{gather*}
\left(\begin{matrix}0 & 0 & 0\\
2 & 0 & 2\\
8 & 0 & 2\\
18 & 0 & 2
\end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\
1 & 0 & 1\\
4 & 0 & 1\\
9 & 0 & 1
\end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\
1 & 0 & 1\\
4 & 0 & 1\\
5 & 0 & 0
\end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\
1 & 0 & 1\\
4 & 0 & 1\\
1 & 0 & 0
\end{matrix}\right)\to\\ %<= this where the eq will be splitted
\left(\begin{matrix}0 & 0 & 0\\
1 & 0 & 1\\
0 & 0 & 1\\
1 & 0 & 0
\end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\
0 & 0 & 1\\
0 & 0 & 1\\
1 & 0 & 0
\end{matrix}\right)\to\left(\begin{matrix}0 & 0 & 0\\
0 & 0 & 0\\
0 & 0 & 1\\
1 & 0 & 0
\end{matrix}\right)\to\left(\begin{matrix}1 & 0 & 0\\
0 & 0 & 1\\
0 & 0 & 0\\
0 & 0 & 0
\end{matrix}\right)
\end{gather*}

\end{document}


I think this is not bad to show the Gaussian Method.

• But it means I have to add these tags for every single equation in my document, right? Oct 29 '17 at 19:13
• @gbi1977 yes of course, you can also use gather environment to get same as multline but the splitted equation will be centered. You can check amsmath documentation for more information. Oct 29 '17 at 19:21
• I acutally used all of these environments right now and it still won't help, the equations exceed the right margin. the best way I found is to add a new line with CTRL+ENTER and copy to tail of the eqaution there. But I thought there should be at least one simple setting to wrap the eqautions during pdflatex export... Oct 29 '17 at 19:24