1

I want to increase the size of the bracket to display more nicely the output, but I didn't find out how.

$$s^2 = \frac{1}{n-1}[\sum\limits_{i=1}^n x_i^2 -
\frac{(\sum\limits_{i=1}^n x_i)^2}{n}]$$

Here is the image that I obtain :

enter image description here

And here is the output that I want. (PS. I want the sum with i=1 below and n above, in the image the output is not 100% what I want), I took that from a word document)

enter image description here

To test the output, I use the sample file : sample-dynamic-2.html from MathJax.

UPDATED :

I changed the formula to :

$$s^2 = \frac{1}{n-1}\Biggl[\sum\limits_{i=1}^n x_i^2 - \frac{(\su\limits_{i=1}^n x_i)^2}{n}\Biggr]$$

I obtain this instead :

enter image description here

  • 1
    See comments on this post from a couple of days ago. In another news, $$ ... $$ should be replaced by \[ ... \] in LaTeX – Au101 Mar 07 '16 at 02:12
  • Well, again, you would have to add \biggl( ... \biggr) around the summation in the fraction to adjust those brackets (although here you could probably use \left( \right) without ill effect. – Au101 Mar 07 '16 at 02:32
  • 2
    However I would really advise against using limits in the numerator of a fraction, it makes for a very unbalanced appearance. You also don't need to use \limits at all with the first summation. – Au101 Mar 07 '16 at 02:33
  • I think \left[ ... \right] will produce the desired results... – Alex Nelson Mar 07 '16 at 03:25
  • thanks a lot for your answers. That helped me to understand LaTeX. – Sebastien Dionne Mar 09 '16 at 01:18

2 Answers2

2

I can propose three ways of typesetting the formula, in order of preference (see the comments in the code):

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[% the ugly
s^2 = \frac{1}{n-1}\biggl[\,
  \sum_{i=1}^n x_i^2 -
    \frac{\Bigl(\,\sum\limits_{i=1}^n x_i\Bigr)^{\!2}}{n}
  \biggr]
\]
\[% the bad
s^2 = \frac{1}{n-1}\biggl[\,
  \sum_{i=1}^n x_i^2 -
    \frac{\bigl(\sum_{i=1}^n x_i\bigr)^2}{n}
  \biggr]
\]
\[% the good
s^2 = \frac{1}{n-1}\biggl[\,
  \sum_{i=1}^n x_i^2 -
    \frac{1}{n}\biggl(\,\sum_{i=1}^n x_i\biggr)^{\!2}
  \,\biggr]
\]
\end{document}

enter image description here

See Why is \[ ... \] preferable to $$ ... $$? for $$; in a normal document, there shouldn't be consecutive display environments, but here it's just as way of example.

egreg
  • 1,121,712
0

Unfortunately I cannot comment (too less reputation), because this is only an answer on top of the answer of egreg.

The best way to obtain proper sized brackets are left/right brackets, which resize depending on the size of the formula "in between" them. Therefore one should extend the answer of egreg to:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[% the ugly
    s^2 = \frac{1}{n-1}\biggl[\,\sum_{i=1}^n x_i^2 - \frac{\Bigl(\,\sum\limits_{i=1}^n x_i\Bigr)^{\!2}}{n} \biggr]
\]
\[% the bad
    s^2 = \frac{1}{n-1}\biggl[\,\sum_{i=1}^n x_i^2 - \frac{\bigl(\sum_{i=1}^n x_i\bigr)^2}{n}\biggr]
\]
\[% the good
    s^2 = \frac{1}{n-1}\biggl[\,\sum_{i=1}^n x_i^2 - \frac{1}{n}\biggl(\,\sum_{i=1}^n x_i\biggr)^{\!2}\,\biggr]
\]
\[% the better
    s^2 = \frac{1}{n-1}\left[\sum_{i=1}^n x_i^2 - \frac{1}{n}\left(\sum_{i=1}^n x_i\right)^{\!2} \right]
\]
\[% the better but ugly
    s^2 = \frac{1}{n-1}\left[\sum_{i=1}^n x_i^2 - \frac{\left(\sum\limits_{i=1}^n x_i\right)^{2}}{n} \right]
\]
\end{document}

By the left/right brackets it is also no problem to let the sum in the numerator, although (as the others) I would strongly recommend to omit this.

Output of given code with pdflatex

Further I would recommend to define somthing like

\renewcommand*{brr}[1]{\left(#1\right)} % bracket round
\renewcommand*{brs}[1]{\left[#1\right]} % bracket square
\renewcommand*{brc}[1]{\left\{#1\right\}} % bracket curly

To be able to adjust spacings through your whole document (compare the \, after the opening square bracket in examples 1-3 and the versions without (4 and 5).

marlam
  • 544