# Nested Summation

Using below code i am getting result shown in below image but its not properly displayed for

1. ex space on either side of =.
2. First summation sign is small.
3. Brackets ( ) are small.
4. All items are not placed properly with spaces between them.

How to improve all these things?

T(n)= $\sum\limits_{i=3}^{n-4}(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1)$


MWE

\documentclass{article}

\usepackage{fancyhdr} % Required for custom headers
\usepackage{lastpage} % Required to determine the last page for the footer
\usepackage{extramarks} % Required for headers and footers
\usepackage[usenames,dvipsnames]{color} % Required for custom colors
\usepackage{graphicx} % Required to insert images
\usepackage{listings} % Required for insertion of code
\usepackage{courier} % Required for the courier font
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{mathtools}          %loads amsmath as well
\DeclarePairedDelimiter\Floor\lfloor\rfloor
\DeclarePairedDelimiter\Ceil\lceil\rceil

% Margins
\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in

\linespread{1.1} % Line spacing
\begin{document}
\section{eqn}
T(n)= $\sum\limits_{i=3}^{n-4}(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1)$
\end{document}

• Just put your $ dollar sign before the T(n)=; this should be part of the whole equation. – Andrew Swann Apr 12 '15 at 9:13 • If T(n) should be not typeset in italics (which is the default for math mode, then use \mathrm{T(n)} – user31729 Apr 12 '15 at 9:20 ## 2 Answers There is a bunch of options to improve this: • Put T(n) in math mode --> spacing before = is better • Use \left(....\right) to get bigger bracket, however the spacing before and after brackets are too large • Use \biggl(...\biggr) for larger brackets and better spacing • Use \mleft( and \mright) from the mleftright package for adapted brackets and better spacing The output of those options can be seen from the screen shot \documentclass{article} \usepackage{fancyhdr} % Required for custom headers \usepackage{lastpage} % Required to determine the last page for the footer \usepackage{extramarks} % Required for headers and footers \usepackage[usenames,dvipsnames]{color} % Required for custom colors \usepackage{graphicx} % Required to insert images \usepackage{listings} % Required for insertion of code \usepackage{courier} % Required for the courier font \usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template \usepackage{mathtools} %loads amsmath as well \usepackage{mleftright} \DeclarePairedDelimiter\Floor\lfloor\rfloor \DeclarePairedDelimiter\Ceil\lceil\rceil % Margins \topmargin=-0.45in \evensidemargin=0in \oddsidemargin=0in \textwidth=6.5in \textheight=9.0in \headsep=0.25in \linespread{1.1} % Line spacing \begin{document} \section{eqn} \begin{itemize} \item original \\ T(n)=$\sum\limits_{i=3}^{n-4}(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1)$\item Now with extra space$ T(n)\;= \sum\limits_{i=3}^{n-4}(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1)$\item With brackets improved$T(n)\;= \sum\limits_{i=3}^{n-4}\left(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1\right)$\item With big brackets \texttt{biggl(} and \texttt{biggr)}$T(n) = \sum\limits_{i=3}^{n-4}\biggl(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1\biggr)$\item With brackets from mleftright package$ T(n)= \sum\limits_{i=3}^{n-4}\mleft(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1\mright)\item Displaystyle all together $T(n)\;= \sum\limits_{i=3}^{n-4}\mleft(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1\mright)$ \end{itemize} Now in an align-environment \begin{align} T(n)&= \sum\limits_{i=3}^{n-4}(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1) \\ T(n)&= \sum\limits_{i=3}^{n-4}\left(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1\right) \\ T(n)&= \sum\limits_{i=3}^{n-4}\mleft(\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1\mright) \end{align} \end{document}  • Thats awesome. Can we make summation sign also bigger for outer looop. – Arjun Chaudhary Apr 12 '15 at 10:29 • @ArjunChaudhary I've never seen mathematics written with different-sized summation signs. I'm not going to say that LaTeX can't do it but it's unusual to want to do it. – David Richerby Apr 12 '15 at 10:43 • @ArjunChaudhary: I agree with David Richerby: It's unusual, but could be possible, perhaps, by declaring \SumBig as left delimiter, which can be enlarged by \biggl\SumBig, for example – user31729 Apr 12 '15 at 11:13 • @DavidRicherby: See "Extra large operators" on the MathTimes webpage for an example of different-sized summation signs. – Aditya Apr 18 '15 at 17:48 • @Aditya OK, so I've seen it exactly once and never "in the wild". :-) – David Richerby Apr 18 '15 at 17:55 Such a big formula should be in a displayed formula, see later for reasons. Use equation or equation* (the latter if you don't want an equation number). I also changed a bit your preamble, with instructions to geometry rather than setting internal parameter such as \topmargin or \evensidemargin: you seem to want one inch margins and \geometry{margin=1in} is simpler, isn't it? Also I'm quite uncertain you really need extramarks: in several years of LaTeX I have never used it (except perhaps in a couple of answers here). A point to note: \limits should be used very rarely. Either LaTeX applies it automatically (in displayed formulas) or it makes very big lines that produce bad typesetting. See the example at the bottom, where the formula has been inserted inline to show the effect. Another note: all math should be in math mode. An error frequently made by beginners is writing something like T(n) in normal text mode because it doesn't require special symbols. But it's wrong, because math mode uses a special font and you can see the result in your picture, where T(n) appears upright and not italic. Finally: when a summation symbol with wide limits appears next to a parenthesis, it's better to add \, (a small space) between them in order to avoid clashes. \documentclass{article} \usepackage{geometry} \geometry{margin=1in,headsep=0.25in} \usepackage{fancyhdr} % Required for custom headers \usepackage{lastpage} % Required to determine the last page for the footer \usepackage{extramarks} % Required for headers and footers \usepackage[usenames,dvipsnames]{color} % Required for custom colors \usepackage{graphicx} % Required to insert images \usepackage{listings} % Required for insertion of code \usepackage{courier} % Required for the courier font \usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template \usepackage{mathtools} %loads amsmath as well \DeclarePairedDelimiter\Floor\lfloor\rfloor \DeclarePairedDelimiter\Ceil\lceil\rceil \linespread{1.1} % Line spacing \begin{document} \section{An equation} \lipsum*[2] \begin{equation*} T(n)= \sum_{i=3}^{n-4}\biggl(\,\sum_{j=4}^{n-1} 1 + \sum_{k=10}^{n-3} 1\biggr) \end{equation*} \lipsum*[3] T(n)= \sum\limits_{i=3}^{n-4}\Bigl(\,\sum\limits_{j=4}^{n-1} 1 + \sum\limits_{k=10}^{n-3} 1\Bigr)\$
\lipsum[4]

\end{document}


• Thats awesome. Can we make summation sign also bigger for outer looop – Arjun Chaudhary Apr 12 '15 at 10:33