# Format long equation

I have this equation:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\title{}
\author{}
\date{}
\begin{document}
$$\frac{u(x,t)-u(x,t-k)}{k}=c\frac{u(x+h,t)-2u(x,t)+u(x-h,t)}{h^2}+(\frac{u(x+h,t)-u(x-h,t)}{2h})(\frac{c(x+h,t)-c(x-h,t)}{2h}) \\$$
\end{document}


The problem is that it goes off the page. So I tried:

\begin{align}
\frac{u(x,t)-u(x,t-k)}{k} \\
=& c\frac{u(x+h,t)-2u(x,t)+u(x-h,t)}{h^2}+(\frac{u(x+h,t)-u(x-h,t)}{2h})(\frac{c(x+h,t)-c(x-h,t)}
{2h})
\end{align}


That doesn't seem to work either. Any advice?

You could use multline.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\title{}
\author{}
\date{}
\begin{document}

\begin{multline}
\frac{u(x,t)-u(x,t-k)}{k}
= c\frac{u(x+h,t)-2u(x,t)+u(x-h,t)}{h^2}\\
+\left(\frac{u(x+h,t)-u(x-h,t)}{2h}\right)
\left(\frac{c(x+h,t)-c(x-h,t)}{2h}\right)
\end{multline}

\begin{multline}
\frac{u(x,t)-u(x,t-k)}{k}
= c\frac{u(x+h,t)-2u(x,t)+u(x-h,t)}{h^2}\\
+\Bigl(\frac{u(x+h,t)-u(x-h,t)}{2h}\Bigr)
\Bigl(\frac{c(x+h,t)-c(x-h,t)}{2h}\Bigr)
\end{multline}
\end{document}


• Thanks, I didn't actually know that \left or \Bigl even existed. But looking at the way you've written the equations, \Bigl seems to be smaller than \left. Is that correct?
– dave
Apr 19, 2020 at 13:58
• @dave Yes. Some do not like \left and \right so they prefer to add the parentheses by hand. I actually think that \left(...\right) looks better.
– user194703
Apr 19, 2020 at 13:59
• Same! Also just for knowledge, if I wanted to put equals in a new line, how could I do that? For example,  x = 5 + 1 = 6  So basically, something on the top line and having equals on the next line but on the left of it
– dave
Apr 19, 2020 at 14:03
• @dave Then use align. \documentclass[a4paper,12pt]{article} \usepackage{amsmath} \begin{document} \begin{align} x &= 5 + 1\notag\\ & = 6 \end{align} \end{document} The & goes before the = of the respective line.
– user194703
Apr 19, 2020 at 14:05
• @dave I do not understand this comment.
– user194703
Apr 19, 2020 at 17:59