# Problem with align* moving equations off the page

Here is the Math question and answer that I want to typeset into LaTeX:

I'm using the align* environment to typeset everything and this is the code I've used:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\begin{document}
\begin{align*}
&\text{\textbf{Find the limit of} }\mathbf{\lim_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8}}\text{\textbf{:}}\\
&=\lim_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8}\\
&=\frac{(\infty)^3-7(\infty)-6(\infty)-17}{(\infty)^4-8}\\
&\\
&\text{Since this is an }\frac{\infty}{\infty}\text{ limit, we can use LH}\hat{o}\text{pital's rule}\\
&\frac{dy}{dx}(x^3-7x^2+6x-17) &&\frac{dy}{dx}(x^4-8) &\longrightarrow\text{ LH}\hat{o}\text{pital's rule:}\\
&=3x^2-14x+6                   && =4x^3               &\text{1st attempt}\\
&\\
&\text{Since this is still an }\frac{\infty}{\infty}\text{ limit, we can repeatedly use LH}\hat{o}\text{pital's rule until we get to a result:}\\
&\frac{dy}{dx}(3x^2-14x+6)     &&\frac{dy}{dx}(4x^3)  &\longrightarrow\text{ LH}\hat{o}\text{pital's rule:}\\
&=6x-14                        && =12x^2              &\text{2nd attempt}\\
&\frac{dy}{dx}(6x-14)          &&\frac{dy}{dx}(12x^2) &\longrightarrow\text{ LH}\hat{o}\text{pital's rule:}\\
&=6                            && =24x                &\text{3rd attempt}\\
&\\
&\text{Now we have:}\\
&\lim_{x\to\infty}\frac{6}{24x}\\
&=\frac{6}{24(\infty)}\\
&=\frac{6}{\infty}\\
&=0
\end{align*}
\end{document}


However the problem with this is that my equations go off the page and I'm unsure as to how to fix it.

Note: The math images are from old homework and the LaTeX typesetting of this math is the current assignment I'm working on.

• Welcome. // I entered your fotos directly, as links may disappear over time. Jul 23, 2022 at 11:42
• @MS-SPO Ahh thank you Jul 23, 2022 at 12:09
• Do not incorporate text to your equations – use \intertext{…}. Jul 23, 2022 at 12:23
• @Bernard So do I just replace all the \text{...} with \intertext{...}, or do you mean something else? Jul 23, 2022 at 12:27
• @PranavSundaram: It's exactly that. You also may use \shortintertext from mathtools for a better vertical spacing. Jul 23, 2022 at 12:30

Does this layout befit you?

Note: needless to load amsfonts when you load amssymb – the latter already does it for you.

    \documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb, bm}

\begin{document}

\begin{align*}
\shortintertext{\bfseries{Find the limit of} $\displaystyle \bm{\lim_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8}}$ :}
&=\lim_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8}\\
&=\frac{(\infty)^3-7(\infty)-6(\infty)-17}{(\infty)^4-8}\\
\intertext{Since this is an $\frac{\infty}{\infty}$, we can use L'Hôpital's rule}
&\frac{dy}{dx}(x^3-7x^2+6x-17) &&\frac{dy}{dx}(x^4-8) &\longrightarrow\text{ LHôpital's rule:}\\
&=3x^2-14x+6 && =4x^3 &\text{1st attempt}\\
\intertext{Since this is still an $\frac{\infty}{\infty}$, we can repeatedly use L'Hôpital's rule until we get to a result:}
&\frac{dy}{dx}(3x^2-14x+6) &&\frac{dy}{dx}(4x^3) &\longrightarrow\text{ LHôpital's rule:}\\
&=6x-14 && =12x^2 &\text{2nd attempt}\\
&\frac{dy}{dx}(6x-14) &&\frac{dy}{dx}(12x^2) &\longrightarrow\text{ LHôpital's rule:}\\
&=6 && =24x &\text{3rd attempt}\\
\intertext{Now we have:}
&\lim_{x\to\infty}\frac{6}{24x}\\
&=\frac{6}{24(\infty)}\\
&=\frac{6}{\infty}\\
&=0
\end{align*}

\end{document}


• Aha, this is exactly what I was going for!! Thank you so much for taking this time out to help me! Jul 23, 2022 at 13:32
• You're welcome. Always glad when I can help! Jul 23, 2022 at 13:46

A solution based on multiple nested math environments and left align equations

\documentclass{article}
\usepackage{array}
\usepackage[fleqn]{mathtools}
\usepackage{amssymb}
\usepackage{bm}

\setlength{\parindent}{0pt}
\newcommand\prelen{\hspace{15pt}}
\newlength\eqskip   \setlength\eqskip{9pt} % skips at tries

\begin{document}
\textbf{Find the limit of} $$\displaystyle \mathbf{\bm{\lim}_{x\to\infty} \frac{x^3-7x^2+6x-17}{x^4-8}}$$:

\begin{align*}
&\lim_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8} \\
&\prelen=\ \lim_{x\to\infty}
\frac{(\infty)^3-7(\infty)-6(\infty)-17}{(\infty)^4-8} \\
&\prelen=\ \frac{\infty}{\infty}
\end{align*}

Since this is an $$\displaystyle \frac{\infty}{\infty}$$ limit, we can use L'Hôpital's rule:
\begin{align*}
\begin{aligned}
\frac{dy}{dx}\bigl(x^3-7x^2+6x-17\bigr) \\
=\ 3x^2-14x+6
\end{aligned}
& \hspace{3em}
\begin{aligned}   % {r @{\hspace{3em}} r}
\frac{dy}{dx}\bigl(x^4-8\bigr) \\
=\ 4x^3
\end{aligned}
\end{align*}

Since this is still an $$\displaystyle \frac{\infty}{\infty}$$ limit, we can repeatedly use L'Hôpital's rule until we get to a result:
\begin{align*}
\begin{aligned}
&\frac{dy}{dx}(3x^2-14x+6) \\
&    \prelen=\ 6x - 14 \\[\eqskip]
&\frac{dy}{dx}(6x - 14) \\
&    \prelen=\ 6
\end{aligned}
&&  \begin{aligned}
& \frac{dy}{dx}(4x^3)
&&& \smash{\begin{tabular}{l}
{L'Hôpital's rule} \\
(2nd try)
\end{tabular}} \\
& \prelen=\ 12x^2 \\[\eqskip]
& \frac{dy}{dx}(12x^2)
&&& \smash{\begin{tabular}{l}
{L'Hôpital's rule} \\
(3rd try)
\end{tabular}} \\
& \prelen=\ 24x
\end{aligned}
\end{align*}

Now we have:
\begin{align*}
\lim_{x\to\infty}\,\frac{6}{24x}\ &=\ \frac{6}{24(\infty)} \\
& =\ \frac{6}{\infty} \\
& =\ 0
\end{align*}

\end{document}

• This code is definitely the most aesthetic and complex out of the responses. Thank you for this. Jul 24, 2022 at 3:58

There's a lot of dubious code here, so it's probably best if I just give you a corrected version, rather than listing all the changes. In short, trying to force the whole structure into a single align makes your life very difficult, because it is not what the environment is designed for. I'll say nothing about applying arithmetic operations to infinity symbols, except that it's an abomination. I would consider creating a macro for \mathrm{d} and using this in place of the ordinary 'd' in differential operators.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\begin{document}
Find the limit of
$$\displaystyle\mathbf{\lim_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8}}$$:
\begin{align*}
\lim_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8}
&= \lim_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8}\\
&=\frac{(\infty)^3-7(\infty)-6(\infty)-17}{(\infty)^4-8}.
\end{align*}
Since this is an $$\infty/\infty$$ limit, we can use L'H\^opital's rule:
\begin{align*}
&\frac{dy}{dx}(x^3-7x^2+6x-17) &\frac{dy}{dx}(x^4-8)&&\longrightarrow\text{L'H\^opital's rule:}\\
\end{align*}
Since this is still an $$\infty/\infty$$ limit, we can repeatedly use L'H\^opital's rule until
we get to a result:
\begin{align*}
&\frac{dy}{dx}(3x^2-14x+6) &\frac{dy}{dx}(4x^3)   &&\longrightarrow\text{L'H\^opital's rule:}\\
&\frac{dy}{dx}(6x-14)      &\frac{dy}{dx}(12x^2)  &&\longrightarrow\text{L'H\^opital's rule:}\\
\end{align*}
Now we have:
\begin{align*}
\lim_{x\to\infty}\frac{6}{24x}
&=\frac{6}{24(\infty)}\\
&=\frac{6}{\infty}\\
&=0
\end{align*}
\end{document}


• I can't believe I didn't think of dividing it into multiple align* environments, thank you so much for this. Jul 23, 2022 at 13:16
• @PranavSundaram --- No problem. One last point: if you want alignment between the second and third blocks, you can use Bernard's suggestion: put "Since this is still..." in an \intertext{} command and delete the surrounding \end{align} and \begin{align}. Jul 23, 2022 at 13:21
• Alright sure! I'll do that right now. Jul 23, 2022 at 13:24

I would write your assignment like this:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}

\begin{document}
\noindent\textbf{Find the limit of $\mathbf{\lim\limits_{x\to\infty}\frac{x^3-7x^2+6x-17}{x^4-8}}$ :}
\begin{align*}
\lim_{x\to\infty}\frac{x^3 - 7x^2+6x - 17}{x^4 - 8}
& = \frac{(\infty)^3 - 7(\infty)-6(\infty)-17}{(\infty)^4 - 8}      \\
\intertext{Since this is an $\frac{\infty}{\infty}$ limit, we can use L'Hôpital's rule}
\frac{dy}{dx}(x^3 - 7x^2+6x - 17)
& = 3x^2 - 14x + 6
1st attempt}         \\
\frac{dy}{dx}(x^4 - 8)
& = 4x^3
\intertext{Since this is still an $\frac{\infty}{\infty}$ limit, we can repeatedly use L'Hôpital's rule rule until we get the final result:}
\frac{dy}{dx}(3x^2-14x+6)
& = 6x - 14
2nd attempt}         \\
\frac{dy}{dx}(4x^3)
& =12x^2
\shortintertext{and}
\frac{dy}{dx}(6x-14)
& = 6