Evaluate $\int_0 ^x \frac{\sin\left(\frac{1}{2}-n\right) t}{\sin\frac{t}{2}}\,dt$. Evaluate
$$\int_0 ^x \frac{\sin\left(\frac{1}{2}-n\right) t}{\sin\frac{t}{2}}\,dt$$
for $x\in(0,2\pi)$ and $n\in\mathbb Z$. From trigonometric formulas, we have:
$$\int_0 ^x\cos nt\, dt-\int_0 ^x \frac{\cos\frac{t}{2}}{\sin\frac{t}{2}}\, \sin nt\,dt$$
What can we say for the second integral? I was not able to solve it.

It is sufficient to  consider an integral of the form $$\int \frac{\sin \left(\left(2k+1\right)t\right)}{\sin t}dt.$$ One has $$\frac {\sin\left(\left(2k+1\right)t\right)}{\sin t}=\frac{e^{i\left(2k+1\right)t}-e^{-i\left(2k+1\right)t}}{e^{it}-e^{-it}}=2\left[\cos 2kt +\cos \overline{2(k-1)}t + \cos \overline{2(k-2)}t + \cdot\cdot\cdot+\cos 2t \right]+1.$$ Each of the terms are easily integrated, but can't think of a further simplification.
