DC level in Fourier series
This stumped me for a while as well but it is actually quite simple.

The general Fourier series:

\$ g(x) = a_0 +  \displaystyle \sum_{n=1}^{\infty}[a_n sin(n x) + b_n cos(n x) ]  \$

I am not going to do all the math but if you use the orthogonal signal space \$ \left\{{1, cos(nx),sin(nx)}\right\} n\in N \$ you can derive the fourier series terms as:

\$ a_n = \dfrac{1}{\pi} \displaystyle \int_{-\pi}^{\pi} g(x)cos(n x)\,\mathrm{d}x\$

\$ b_n = \dfrac{1}{\pi} \displaystyle \int_{-\pi}^{\pi} g(x)sin(n x)\,\mathrm{d}x\$

And:

\$ a_0 = \dfrac{1}{2\pi} \displaystyle \int_{-\pi}^{\pi} g(x)\,\mathrm{d}x\$

The "regular" Fourier series

\$ g(x) = \dfrac{a_0}{2} +  \displaystyle \sum_{n=1}^{\infty}[a_n sin(n x) + b_n cos(n x)]\$

For the sake of symmetry the \$a_0\$ term was redefined as:

\$ a_0 = \dfrac{1}{\pi} \displaystyle \int_{-\pi}^{\pi} g(x)\,\mathrm{d}x\$

to be similar to \$a_n\$ and \$b_n\$. Therefore the \$\dfrac{1}{2}\$ term was added to the expression of the Fourier series.

Reference:

Generalized Fourier Series
Fourier Series