# Theorem won't go to multiple lines and is causing text to run off the page

I am writing a paper for a class that has to include a proof. I have started out by listing what I want to prove as a theorem and then I'll go through the process of proving it. However, the code I am using below puts everything on one line and the text portion of the theorem ends up running off the page. I tried putting in "\" after the equation to put the text onto the line below it but that doesn't seem to work. Any ideas as to how I can fix this issue?

\begin{theorem}
$G(x)=\sum_{k\geq0}C_kx^k=\frac{1-\sqrt{1-4x}}{2x},\\ where G(x) is the generating function for the catalan number sequence.$
\end{theorem}

• One can't have line breaks in a single-line displayed equation. Incidentally, why would you wish to place where G(x) is the generating function for the catalan number sequence. inside the displayed equation?
– Mico
Apr 30 '19 at 18:45
• you can not have linebreaks (\\ ) in a displayed equation () nor can you have words of text, move where... out of the math display Apr 30 '19 at 18:59

First off, I wouldn't place the string where G(x) is the generating function for the catalan number sequence. inside a displayed equation. Second, one cannot have line breaks inside $...$. If you need to create a multi-line displayed equation, use a suitable environment provided by the amsmath package, such as align, gather, and multline.

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}

\begin{theorem}
Bla bla bla \dots
$G(x)=\sum_{k\geq0}C_kx^k=\frac{1-\sqrt{1-4x}}{2x}\,,$
where $G(x)$ is the generating function for the catalan number sequence.
\end{theorem}
\end{document}

• I didn't know that this was an option, I'm still new to Latex so I'm figuring most things out as I go. Thank you very much for the input, this solved the problem. Apr 30 '19 at 18:53

If you really wish the "where G(x) is the generating function for the catalan number sequence"-phrase to belong to the equation, which would affect the vertical spacing/the size of the vertical gap between the equation and that phrase, you can, e.g., use a gather- or a split-environment:

\documentclass{article}
\usepackage{amsmath}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\begin{gather*}
G(x)=\sum_{k\geq0}C_kx^k=\frac{1-\sqrt{1-4x}}{2x},\\
\text{where $$G(x)$$ is the generating function for the catalan number sequence.}%
\end{gather*}
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\begin{equation*}\begin{split}
&G(x)=\sum_{k\geq0}C_kx^k=\frac{1-\sqrt{1-4x}}{2x},\\
&\text{where $$G(x)$$ is the generating function for the catalan number sequence.}%
\end{split}\end{equation*}
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}
\end{document}


And in some situations a simple minipage-environment might be your friend:

\documentclass{article}
\usepackage{amsmath}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
$% G(x)=\sum_{k\geq0}C_kx^k=\frac{1-\sqrt{1-4x}}{2x}, \text{% \begin{minipage}[t]{4cm}% where $$G(x)$$ is the generating function for the catalan number sequence.% \end{minipage}% }%$
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}
\end{document}


Using \parshape inside minipage, you can achieve things that are even more funny:

\documentclass{article}
\usepackage{amsmath}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
$% \boxed{% G(x)=\sum_{k\geq0}C_kx^k=\frac{1-\sqrt{1-4x}}{2x}, \text{% \begin{minipage}[t]{1.9cm}% \parshape 3 0cm 1.9cm 0cm 1.9cm -5.2cm 7.1cm where $$G(x)$$ is the generating function for the catalan number sequence.% \end{minipage}% }% }%$
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}
\end{document}