show that $\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx=\frac{\pi^2}{4} \operatorname{sech}^2 \left(\frac{a\pi}{2}\right) $ 
Show that $$\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx=\frac{\pi^2}{4} \operatorname{sech}^2\left(\frac{a\pi}{2}\right) $$

I think we can solve it by contour integration, but how? and it would be better if there were two ways, the first with real analysis and the second with complex analysis.

Here's another complex analytic approach.
Since 
$$\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx
\quad\textrm{and}\quad
\int_{0}^{\infty}\frac{\sin ax}{\sinh x}dx$$ 
are uniformly convergent, differentiation and integration commute.
Also, the integrals are even. 
We find 
$$\begin{eqnarray*}
\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx
&=& \frac{\partial}{\partial a} \int_{0}^{\infty}\frac{\sin ax}{\sinh x}dx \\
&=& \frac{1}{2} \frac{\partial}{\partial a} \int_{-\infty}^{\infty}
    \frac{\sin ax}{\sinh x}dx \\
&=& \frac{1}{2}\frac{\partial}{\partial a} \mathrm{Im}
    \int_{-\infty}^{\infty}\frac{e^{iax}}{\sinh x}dx.
\end{eqnarray*}$$
We close the contour for the last integral along a semicircular contour in the upper half plane. Here we assume, with little loss of generality, that $\mathrm{Re}(a)>0$.
(Due to the good behavior of $e^{iax}$, the integral along this contour is zero.)
We pick up the residues in the upper half plane occurring at $x=in\pi$, where $n=1,2,\ldots$. 
Thus, 
$$\begin{eqnarray*}
\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx
&=&  \frac{1}{2}\frac{\partial}{\partial a} \mathrm{Im} \,2\pi i
    \sum_{n=1}^\infty \mathrm{Res}_{x_n=i n\pi}
    \frac{e^{iax_n}}{\sinh x_n} \\
&=&  \frac{1}{2}\frac{\partial}{\partial a} \mathrm{Im} \,2\pi i
    \sum_{n=1}^\infty
    \frac{e^{-n\pi a}}{\cosh i n\pi} \\
&=&  \pi \frac{\partial}{\partial a}
    \sum_{n=1}^\infty (-1)^n e^{-n\pi a} \\
&=& -\pi \frac{\partial}{\partial a} \frac{1}{1+e^{a\pi}} \\
&=& \frac{\pi^2 e^{a\pi}}{(1+e^{a\pi})^2} \\
&=& \frac{\pi^2}{4}\mathrm{sech}^2\frac{a\pi}{2}.
\end{eqnarray*}$$
