Graphics, Figures & TablesSum Limits above and below Operator instead of besides

Information and discussion about graphics, figures & tables in LaTeX documents.
financialwar
Posts: 29
Joined: Wed Jul 18, 2012 4:55 pm

Sum Limits above and below Operator instead of besides

Post by financialwar »

Code: Select all

\sum_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}
The result is that {t=0} and {n} exists on the side of the Sum symbol instead of on direct top and bottom of the sum symbol.

How do I get it right?
Last edited by localghost on Sat Sep 01, 2012 12:51 pm, edited 1 time in total.
MiKTex 2.9, Texmaker 3.5 on Windows 7
Learning LaTeX for Finance and Actuarial Studies.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Sum Limits above and below Operator instead of besides

Post by Stefan Kottwitz »

You could add \limits to change that:

Code: Select all

\sum\limits_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}
Here's an example for comparing different methods:

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}
\centering
$\sum_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}$
\[\sum_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}\]
$\displaystyle\sum_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}$

$\sum\limits_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}$
\end{document}
The first is inline math, then we see math in displayed style, the next one is inlined but switched to displayed style for the whole expression, the last one just tells \sum to use the limits above and below.
sum.png
sum.png (11.72 KiB) Viewed 55883 times
Have a look at the excellent mathmode documentation to learn more about this.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Sum Limits above and below Operator instead of besides

Post by localghost »

Due to missing information only some guesses.
  • You are writing in in-line math mode.
    • add \limits after the \sum operator but before the limits.
    • add \displaystyle before the \sum operator.
    Note that this can disturb interline spacing.
  • You are already writing in displayed math mode.
    • Remove the \nolimits command at all critical places in the concerned equations.
    • Remove the nolimits option from amsmath (or mathtools, or …)
And next time kindly prepare a proper minimal example to avoid guesswork.


Further reading:

Thorsten
financialwar
Posts: 29
Joined: Wed Jul 18, 2012 4:55 pm

Sum Limits above and below Operator instead of besides

Post by financialwar »

Code: Select all

$$\sum_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}$$

Code: Select all

$\displaystyle\sum_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}$
so basically these two are the same?
MiKTex 2.9, Texmaker 3.5 on Windows 7
Learning LaTeX for Finance and Actuarial Studies.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Sum Limits above and below Operator instead of besides

Post by Stefan Kottwitz »

Regarding size and limits, yes. But $...$ is for math within text, and $$...$$ is for displayed math, i.e. centered and within its own paragraph.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Sum Limits above and below Operator instead of besides

Post by localghost »

financialwar wrote:

Code: Select all

$$\sum_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}$$
Never use $$ … $$ for unnumbered displayed equations. Use \[ … \] instead.
financialwar
Posts: 29
Joined: Wed Jul 18, 2012 4:55 pm

Re: Sum Limits above and below Operator instead of besides

Post by financialwar »

I see, thanks.
MiKTex 2.9, Texmaker 3.5 on Windows 7
Learning LaTeX for Finance and Actuarial Studies.
financialwar
Posts: 29
Joined: Wed Jul 18, 2012 4:55 pm

Sum Limits above and below Operator instead of besides

Post by financialwar »

localghost wrote:
financialwar wrote:

Code: Select all

$$\sum_{t=0}^{n}\dfrac{CF_t}{(1+r)^t}$$
Never use $$ … $$ for unnumbered displayed equations. Use \[ … \] instead.
What do you mean by "unnumbered displayed equation"?

I thought $$ … $$ is the same as \[ … \].

Is there a good latex book for absolute beginner?
MiKTex 2.9, Texmaker 3.5 on Windows 7
Learning LaTeX for Finance and Actuarial Studies.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Sum Limits above and below Operator instead of besides

Post by localghost »

financialwar wrote:What do you mean by "unnumbered displayed equation"? […]
You know the difference between in-line and displayed equations? The latter ones can be automatically numbered by according environments (equation, align, …).
financialwar wrote:I thought $$ … $$ is the same as \[ … \]. […]
Both produce unnumbered displayed formulas. The first is TeX syntax, the latter is LaTeX syntax and thus preferable. Furthermore the TeX syntax causes some unwanted side effects. The below example demonstrates one of them.

Code: Select all

% TeX program = pdflatex
\documentclass[11pt,fleqn]{article}
\usepackage[T1]{fontenc}

\begin{document}
  \[ E=mc^2 \]
  $$ E=mc^2 $$
\end{document}
As you can see, equations written in TeX syntax are not affected by the fleqn (force left equations) option for the document class. For details see l2tabu.
financialwar wrote:[…] Is there a good latex book for absolute beginner?
Our topic »LaTeX Resources for Beginners« and the excellent »Math mode« document (which I already mentioned earlier).
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Sum Limits above and below Operator instead of besides

Post by Stefan Kottwitz »

financialwar wrote:Is there a good latex book for absolute beginner?
I wrote the LaTeX Beginner's Guide, available in print and as ebook, also in Kindle format. There's free information available on the internet, but not always up to date, and if you prefer to tackle it hands on with a step-by-step guide, this book may help you.

Stefan
LaTeX.org admin
Post Reply