I want to create a formula for summing an arithmetic sequence in which the first term is 'a1' and the nth term is 'an' through the following formula.

${{S_n}}$ = \frac{n(${{a_1}}$+${{a_n}}$)}{2}

However, the result is as follows.

enter image description here

How could I solve this problem? I am currently working on overleaf.

I'm worried that since my native language is not English and I am new to LaTeX, my question may seem a bit odd.

  • 2
    $S_n = \frac{n(a_1+a_n)}{2}$ is the correct input. See What are good learning resources for a LaTeX beginner?
    – egreg
    Sep 5, 2022 at 22:13
  • 1
    Welcome to TeX.SX. To typeset mathematical expressions, don't enter and leave "math mode" for each symbol. $ at the beginning and again at the end. Also, you don't need so many braces: $S_n = \frac{n(a_1+a_n)}{2}$
    – Sandy G
    Sep 5, 2022 at 22:14
  • 1
    Welcome. // The problem seems to be that you switch the math mode on and off several times. In running text you type $ formulas $, i.e. just 2 $, just like opening and closing braces. Or for longer equation you start math mode by [ and end it by ] . See related links to the right for examples.
    – MS-SPO
    Sep 5, 2022 at 22:16
  • 2
    A different issue: Your description of the summation sounds more to me like $S_n = \frac{n(a_1 + \ldots + a_n)}{2}$ with an ellipsis representing a₂, a₃, etc., but I might be misunderstanding.
    – frabjous
    Sep 5, 2022 at 22:17
  • @frabjous $S_n = a_1+\dots+a_n = n(a_1+a_n)/2$.
    – Teepeemm
    Sep 6, 2022 at 2:08

1 Answer 1


your code has a lot of unnecessary "{..}"


S_{n}= \frac{n(a_1 + a_n)}{2} 

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .