Is it true that $\int_0^\infty \frac{f(x)}{x} \sin \bigl(\frac{\pi x}{a}\bigr) \,\mathrm{d}x = \frac{\pi}{2} \int_0^{a/2} f(x) \,\mathrm{d}x$? I dont recall where, but I found this interesting identity a few years ago. It was shown in one of Victor Moll's papers about elliptic integrals.

Corollary 3.1. Let $f$ be an even function with period $a$. Then,
  $$\int_0^\infty \frac{f(x)}{x} \sin \bigl(\frac{\pi x}{a}\bigr)
 \,\mathrm{d}x = \frac{\pi}{2} \int_0^{a/2} f(x) \,\mathrm{d}x.$$

To prove this result the following lemma is applied

Lemma 3.1. Let $f$ be an odd periodic function of period $a$. Then
  $$ \int_0^{\infty} \frac{f(x)}{x} \,\mathrm{d}x = \frac{\pi}{2} \int_0^{a/2} f(x) \cot\bigl( \frac{\pi x}{a} \bigr) \,\mathrm{d}x $$

I have no qualms about this lemma. Further, Victor writes that Corollary 3.1 follows from using the lemma on $f(x) = g(x) \sin (\frac{\pi x}{a})$ with the half-angle formula
$$ \tan \frac{x}{2} = \frac{\sin x}{1 + \cos x} $$
However, this is where my problems starts. Inserting in our values and using that $\cot x = 1/\tan x$
$$ \cot \bigl( \frac{\pi x}{a} \bigr) = \frac{1 + \cos(2\pi x/a)}{\sin(2\pi x/a)}$$
Inserting this into the lemma with $f = g \cdot \sin(\pi x/a)$ gives
$$
\int_0^{\infty} \frac{g(x)}{x} \sin \bigl( \frac{\pi x}{a} \bigr)\,\mathrm{d}x = \frac{\pi}{2} \int_0^{a/2} g(x) \sin \bigl( \frac{\pi x}{a} \bigr) \bigl[ 1 + \cos \bigl( \frac{2 \pi x}{a} \bigr) \bigr] \csc \bigl( \frac{2\pi x}{a} \bigr) \,\mathrm{d}x
$$
I would really like the $\csc(x)$ and $\sin(x)$ to cancel out, however the extra factor of $2$ throws the entire calculation of. Any help proving the desired equality would be much obliged.
EDIT: Maybe the lemma is missing a 1/2 factor in the cotan argument?
 A: robjohn has already given a complete derivation of both results. I would like only to point out the details which have prevented you from deriving the Corollary from the Lemma.


*

*There is either a misprint or a mistake in both Lemma and Corollary. The prefactor on the rhs of the equalities shoud be $\frac\pi a$ rather than $\frac\pi2$.

*As you quite correctly guessed there is a missing 1/2 factor in the cotan argument. However it is missing not in the lemma but in the derivation!
Indeed the function 
$$
f(x)=g(x)\sin\frac{\pi x}a,
$$
where $g(x)$ is an even $a$-periodic function, is an odd $\color{red}{2a}$-periodic function. Therefore the Lemma 3.1 for this function reads:
$$
\int_0^\infty g(x)\sin\frac{\pi x}a dx =\frac\pi{\color{red}{2a}}\int_0^\color{red}a
g(x)\sin\frac{\pi x}a \cot\frac{\pi x}{\color{red}{2a}} dx.
$$
PS. I have just looked into the cited paper and found that the authors used the correct prefactor.
A: Corollary 3.1
An even function with period $a$ means $f(a-x)=f(x)$.
$$
\begin{align}
\int_0^\infty\frac{f(x)}x\sin\left(\frac{\pi x}a\right)\,\mathrm{d}x
&=\sum_{k=0}^\infty\int_0^af(x)\left(\frac1{x+2ka}-\frac1{x+(2k+1)a}\right)\sin\left(\frac{\pi x}a\right)\,\mathrm{d}x\tag1\\
&=\sum_{k=0}^\infty\int_0^af(x)\left(\frac1{x+2ka}+\frac1{x-(2k+2)a}\right)\sin\left(\frac{\pi x}a\right)\,\mathrm{d}x\tag2\\
&=\sum_{k\in\mathbb{Z}}\int_0^af(x)\,\frac1{x+2ka}\,\sin\left(\frac{\pi x}a\right)\,\mathrm{d}x\tag3\\
&=\frac\pi{2a}\int_0^af(x)\cot\left(\frac{\pi x}{2a}\right)\sin\left(\frac{\pi x}a\right)\,\mathrm{d}x\tag4\\[3pt]
&=\frac\pi{2a}\int_0^af(x)\tan\left(\frac{\pi x}{2a}\right)\sin\left(\frac{\pi x}a\right)\,\mathrm{d}x\tag5\\[3pt]
&=\frac\pi{2a}\int_0^af(x)\,\mathrm{d}x\tag6\\
&=\frac\pi{a}\int_0^{a/2}f(x)\,\mathrm{d}x\tag7\\
\end{align}
$$
Explanation:
$(1)$: $f(x+a)=f(x)$ and $\sin\left(\frac{\pi(x+a)}a\right)=-\sin\left(\frac{\pi x}a\right)$
$(2)$: $f(a-x)=f(x)$ and $\sin\left(\frac{\pi(a-x)}a\right)=\sin\left(\frac{\pi x}a\right)$ on the second term of the sum
$(3)$: write as a sum over $\mathbb{Z}$
$(4)$: use $(7)$ from this answer
$(5)$: $f(a-x)=f(x)$ and $\sin\left(\frac{\pi(a-x)}a\right)=\sin\left(\frac{\pi x}a\right)$
$(6)$: average $(4)$ and $(5)$
$(7)$: $f(a-x)=f(x)$

Lemma 3.1
An odd function with period $a$ means $f(a-x)=-f(x)$.
$$
\begin{align}
\int_0^\infty\frac{f(x)}x\,\mathrm{d}x
&=\sum_{k=0}^\infty\int_0^af(x)\left(\frac1{x+ka}\right)\,\mathrm{d}x\tag8\\
&=\sum_{k=0}^\infty\int_0^af(x)\left(\frac1{x-(k+1)a}\right)\,\mathrm{d}x\tag9\\
&=\frac12\sum_{k\in\mathbb{Z}}\int_0^af(x)\left(\frac1{x+ka}\right)\,\mathrm{d}x\tag{10}\\
&=\frac\pi{2a}\int_0^af(x)\cot\left(\frac{\pi x}a\right)\,\mathrm{d}x\tag{11}\\
&=\frac\pi{a}\int_0^{a/2}f(x)\cot\left(\frac{\pi x}a\right)\,\mathrm{d}x\tag{12}
\end{align}
$$
Explanation:
$\phantom{1}(8)$: $f(x+a)=f(x)$
$\phantom{1}(9)$: $f(a-x)=-f(x)$
$(10)$: average $(8)$ and $(9)$ and write as a sum over $\mathbb{Z}$
$(11)$: use $(7)$ from this answer
$(12)$: $f(a-x)\cot\left(\frac{\pi(a-x)}a\right)=f(x)\cot\left(\frac{\pi x}a\right)$
