Getting text to appear on the same line

12,539

Your problem is that $$ ... $$ puts you in displaymath mode. This is intended for, well, displaying mathematics. When you enclose maths in $$ ... $$, it is placed on a new line, with a little skip between the displayed maths and the line above. Everything outside the closing $$ will then go on a new line, with the same small skip between displayed maths and the line below. The mathematics is also centred. This is the default behaviour at least.

What you do is leave display math mode and then add as $n\longleftarrow\infty$. As I explained above, this is put on a new line. What you want to do is stay in math mode:

\[=\epsilon(M_1+M_2) \longrightarrow 0 \text{ as } n\longrightarrow \infty\]

enter image description here

There are actually a few ways to include text in math mode. I like to use \text{...}, however, as @Werner points out, this requires you to load the amsmath package. \mbox{...} is an alternative which would work as well.

I would also recommend \to over \longrightarrow for n \to \infty, but that's a matter of choice.

In other news, you should use \[ ... \] over $$ ... $$, as I have above. Click the link to find out why.

However all of that being said, this is not the best way to use display math environments. Perhaps consider something like this:

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}

\[
  \begin{aligned}
    |f_{n}&(x)g_{n}(x) - f_{n}(x)g(x) + f_{n}(x)g(x) - f(x)g(x)| \\
    &\leq |f_{n}(x)g_{n}(x) - f_{n}(x)g(x)| + |f_{n}(x)g(x) -
    f(x)g(x)| \\
    &= |f_{n}(x)||g_{n}(x) - g(x)| + |g(x)||f_{n}(x) - f(x)| \\
    &\leq M_{1}\epsilon + M_{2}\epsilon \\
    &= \epsilon(M_1+M_2) \longrightarrow 0 \text{ as } n \to \infty
  \end{aligned}      
\]

\end{document}

enter image description here


Edit:

Or better still, I highly recommend the solutions to my follow-up question over here:

Displaying equation with a line break and all subsequent lines indented

Share:
12,539

Related videos on Youtube

mh1555
Author by

mh1555

Updated on August 01, 2022

Comments

  • mh1555
    mh1555 over 1 year

    enter image description here

    \paragraph{*}
    So we have that: $$|f_n(x)g_n(x)-f_n(x)g(x) + f_n(x)g(x) - f(x)g(x)|$$
    $$\le |f_n(x)g_n(x)-f_n(x)g(x)|+|f_n(x)g(x)-f(x)g(x)|$$
    $$=|f_n(x)||g_n(x)-g(x)|+|g(x)||f_n(x)-f(x)|$$
    $$\le M_1\epsilon+M_2\epsilon$$
    $$=\epsilon(M_1+M_2) \longrightarrow 0$$ as $n\longrightarrow \infty$.
    

    Basically I want to make it such that the "as n tends to infinity" appears on the same line as the tends towards 0 part. How do I do this?

    • David Carlisle
      David Carlisle over 7 years
      never have a blank line before a displayed equation (the resulting space is completely wrong if you do)
    • Au101
      Au101 over 7 years
      By the way in future, please copy and paste the code in as code, rather than a screenshot, it would have made my life so much easier and you'll get answers faster. Also, in future, it is best to provide a complete, compilable Minimal Working Example. The idea is we should be able to copy and paste your whole code, run it and get a document that shows us your problem. Ideally no extraneous code would be present but a little bit too much is better than not enough
  • Werner
    Werner over 7 years
    Using \text{ as } requires the addition of \usepackage{amsmath} to your document preamble.
  • Au101
    Au101 over 7 years
    @Werner good point, I knew there was something!
  • Werner
    Werner over 7 years
    ...you could also use \mbox{ as }...