1

So in the accompanying image, The text "Note: The "variable of integration" is irrelevant" should be on the same line as the formula under it. In the code I have it all on one line, but it is not displaying that way. The formula above it and all the formulas in the middle need to be left aligned. I have tried flalign, and align but flalign just gives me errors and align is not working for some reason.

Here is the code that I want to display all on 1 line: Note: The "variable of integration" is irrelevant. $$\int_{-2}^{5} x^3 dx = \int_{-2}^{5} y^3 dy = \int_{-2}^{5} t^3 dt = ...$$

And I just need to left align some of the formulas with a little bit of space indented to the right to make it show as different from the text.

Thanks enter image description here

Here is my full code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\documentclass[fleqn]{article}
\setlength{\mathindent}{0pt}
\begin{document}


\section{1 Limit of a Riemann Sum}Suppose $f$ is defined on [$a,b$] and $L$ is a real number. We write \\ $$\int_{a}^{b} f(x) dx = \lim_{|| P ||\to\ 0} \sum\limits_{k=1}^n f(C_k)\Delta \chi _k = L$$
if for every $\epsilon$ $>$ 0, there is a  $\delta$ $>$ 0 so that if $P$ is any partition of [$a,b$] with $\left\Vert\left P \left\Vert\left $ $<$ $\delta$ and each $C_k$ is a number in the $k$th subinterval of $P$, then

$$\left\vert\left \sum\limits_{k=1}^n f(C_k)\Delta \chi _k - L \right\vert\right \textless \thinspace \thinspace \epsilon$$
\\
\\
 \newline Note: The "variable of integration" is irrelevant. $$\int_{-2}^{5} x^3 dx = \int_{-2}^{5} y^3 dy = \int_{-2}^{5} t^3 dt = ...$$
 \\
 Ex: Do the following exist?
 \\
 \begin{flalign}
 $$\left \int_{1}^{3} \frac{1}{x^2} dx$$ &&
  \\&&
 $$\left \int_{0}^{2} \frac{1}{x^2} dx$$&&
 \end{flalign}
 \\
 \\
 Ex: Evaluate $$\int_{1}^{4} f(x) dx$$ where $f(x)$ = 

 \end{flalign}

 \\
 \begin{cases}
 $$3x^2 + 1, \quad 1 \leq x \leq 3$$
 \\
 $$28, \quad \quad \quad \quad 3$$ $<$ $$x \leq 4$$

 \end{cases}
 \\
 \\
 \\

 You may use the fact that $$\int_{1}^{3} x^2 dx = \frac{26}{3}$$ where $f(x)$ 


 \section{Miscellaneous Trivia}
 Prove: If A $$\subseteq B, then \quad A \cap C \subseteq B \cap C$$
 \\
 \\
 Fact: $C(n,r)$ = \Bigg(\overset{n}{r}\Bigg) = $$\frac{P(n,r)}{r!} = \frac{\frac{n!}{(n-r)!}}{r!} = \frac{n!}{r!(n-r)!}$$
\end{document}
  • use $ instead of $$ to write inline math. Or else write text in math environment with text or mathrm. – nidhin Nov 10 '18 at 18:15
  • Welcome to TeX SX! Could you post a full code, so we don't have to type everything from scratch? – Bernard Nov 10 '18 at 19:09
  • See also Why is [ … ] preferable to $$ … $$? – GuM Nov 10 '18 at 19:14
  • Ok, I put in my full code. On overleaf in my project when I try to change them to single $ from $$ it automatically corrects it so I can't do that. It is still separating the text onto multiple lines by default. – user2565352 Nov 10 '18 at 21:36
  • I need the formula to come right after the text – user2565352 Nov 10 '18 at 21:47
3

The posted code produces the error

! LaTeX Error: Two \documentclass or \documentstyle commands.

as there are two \documentclass

If you comment out the second one you get the error

! Undefined control sequence.
<argument> \mathindent 

l.6 \setlength{\mathindent}{0pt}

as that length isn't defined

Commenting out that line you get the error

! Missing delimiter (. inserted).
<to be read again> 
                   $
l.11 ... with $\left\Vert\left P \left\Vert\left $
                                                   $<$ $\delta$ and each $C_...

as \left appears at the end of the formula. If you scroll past that you get errors that there is no matching \right. \left and \right must be in matching pairs in the same expression.

If you fix the mismatched \left then you get

! Missing } inserted.
<inserted text> 
                }
l.30  \end{flalign}

as you have $ inside flalign which is wrong as falign already enters math mode.

If you fix the nested math you get the error

! LaTeX Error: There's no line here to end.

as \\ appears but can not force a linebreak where there is no line, so deleting these, which will also remove the warnings

Underfull \hbox (badness 10000) in paragraph at lines 18--22

which are from \\ mis-placed at the ends of paragraphs

You then get the error

! Missing $ inserted.
<inserted text> 
                $
l.44  Fact: $C(n,r)$ = \Bigg(\overset{n}{r}

as you finished the math before the = so the math mode commands following the = generate errors.

Fixing that finally produces an error free log. It is only at this point you should look at the generated PDF as TeX makes no attempt to make sensible PDF output after an error, it just recovers enough to syntax check the remaining document it does not make usable output if you scroll past an error.

Changing $$ to \[ then results in this document

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
%\documentclass[fleqn]{article}
%\setlength{\mathindent}{0pt}
\begin{document}


\section{1 Limit of a Riemann Sum}

Suppose $f$ is defined on [$a,b$] and $L$ is a real number. We write
\[\int_{a}^{b} f(x) dx = \lim_{|| P ||\to\ 0} \sum\limits_{k=1}^n f(C_k)\Delta \chi _k = L\]
if for every $\epsilon$ $>$ 0, there is a  $\delta$ $>$ 0 so that if $P$ is any partition 
of [$a,b$] with $\lVert P \rVert < \delta$ and each $C_k$ is a number
in the $k$th subinterval of $P$, then

\[\left\vert \sum\limits_{k=1}^n f(C_k)\Delta \chi _k - L \right\vert < \epsilon\]

Note: The "variable of integration" is irrelevant.
\[\int_{-2}^{5} x^3 dx = \int_{-2}^{5} y^3 dy = \int_{-2}^{5} t^3 dt = ...\]

 Ex: Do the following exist?
 \begin{flalign}
 \int_{1}^{3} \frac{1}{x^2} dx &&
  \\&&
 \int_{0}^{2} \frac{1}{x^2} dx&&
 \end{flalign}
 Ex: Evaluate $$\int_{1}^{4} f(x) dx$$ where $f(x)$ = 
 \[\begin{cases}
 3x^2 + 1, \quad 1 \leq x \leq 3
 \\
 28, \quad \quad \quad \quad 3<x \leq 4
 \end{cases}
 \]

 You may use the fact that $$\int_{1}^{3} x^2 dx = \frac{26}{3}$$ where $f(x)$ 


 \section{Miscellaneous Trivia}
 Prove: If A
\[\subseteq B, then \quad A \cap C \subseteq B \cap C\]

 Fact:
\[C(n,r) = \Bigg(\overset{n}{r}\Bigg) = 
\frac{P(n,r)}{r!} = 
\frac{\frac{n!}{(n-r)!}}{r!} = 
\frac{n!}{r!(n-r)!}\]
\end{document}

which is

enter image description here

adding fleqn to the \documentclass will make the displayed expressions flush left and also all expressions such as $\epsilon$ $>$ 0 should be typeset as a single math expression so you get the correct spacing and the final 0 is inside the math so $\epsilon > 0$, Also never have a blank line before a display math.

Finally get this which may be an approximation to your required layout, I had to make some guesses

enter image description here

\documentclass[fleqn]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
%\documentclass[fleqn]{article}
%\setlength{\mathindent}{0pt}
\begin{document}


\section{1 Limit of a Riemann Sum}

Suppose $f$ is defined on [$a,b$] and $L$ is a real number. We write
\[\int_{a}^{b} f(x) dx = \lim_{|| P ||\to\ 0} \sum\limits_{k=1}^n f(C_k)\Delta \chi _k = L\]
if for every $\epsilon > 0$, there is a  $\delta >0$ so that if $P$ is any partition 
of $[a,b]$ with $\lVert P \rVert < \delta$ and each $C_k$ is a number
in the $k$th subinterval of $P$, then
\[\left\vert \sum\limits_{k=1}^n f(C_k)\Delta \chi _k - L \right\vert < \epsilon\]

Note: The "variable of integration" is irrelevant.
\[\int_{-2}^{5} x^3 dx = \int_{-2}^{5} y^3 dy = \int_{-2}^{5} t^3 dt = ...\]

 Ex: Do the following exist?
 \begin{gather}
 \int_{1}^{3} \frac{1}{x^2} dx\\
 \int_{0}^{2} \frac{1}{x^2} dx
 \end{gather}
 Ex: Evaluate \[\int_{1}^{4} f(x) dx\] where
\[f(x) = 
 \begin{cases}
 3x^2 + 1, \quad 1 \leq x \leq 3\\
 28, \quad \quad \quad \quad 3<x \leq 4
 \end{cases}
 \]

 You may use the fact that
\[\int_{1}^{3} x^2 dx = \frac{26}{3}\]
 where $f(x)$ 


 \section{Miscellaneous Trivia}
 Prove: If 
\[A\subseteq B, then \quad A \cap C \subseteq B \cap C\]

 Fact:
\[C(n,r) = \Bigg(\overset{n}{r}\Bigg) = 
\frac{P(n,r)}{r!} = 
\frac{\frac{n!}{(n-r)!}}{r!} = 
\frac{n!}{r!(n-r)!}\]
\end{document}
  • Also \section{1 Limit ...} should be \section{Limit ...}. Since LaTeX adds the numbering, you don't want to be adding your own. – Teepeemm Nov 21 '18 at 1:40
  • @Teepeemm yes, and all the \quad need removing from the cases as they are just messing up the alignment, and the math italic then\quad should be \text{ then } and possibly several more improvements could be done. the oversized () at the bottom should be \binom{a}{r] – David Carlisle Nov 21 '18 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.