Real and Imaginary Parts of tan(z)
I think that the simpler way is to write: $$ \sin z=\sin(x+iy)=\sin x \cos (iy)+\cos x \sin(iy)=\sin x \cosh y +i \cos x \sinh y $$ $$ \cos z=\cos(x+iy)=\cos x \cos (iy)+\sin x \sin(iy)=\cos x \cosh y -i \sin x \sinh y $$ $$ \tan z= \frac{\sin x \cosh y +i \cos x \sinh y}{\cos x \cosh y -i \sin x \sinh y} \cdot\frac{\cos x \cosh y +i \sin x \sinh y}{\cos x \cosh y +i \sin x \sinh y} = $$ $$ =\frac{\sin x \cos x +i \sinh y \cosh y}{\cosh^2 y - \sin^2 x} =\frac{\sin 2x +i \sinh 2y }{2\cosh^2 y - 2\sin^2 x+1-1}=\frac{\sin 2x +i \sinh 2y }{\cos 2x+\cosh2y} $$
Your way seems also good but a bit more complicated.
Edit note:
x was written y by mistake in two of expressions which I corrected so that no confusion is encountered.
$$ \begin{align} \tan(x+iy) &=\overbrace{i\frac{e^{y-ix}-e^{ix-y}}{e^{y-ix}+e^{ix-y}}}^{\tan(z)=i\frac{e^{-iz}-e^{iz}}{e^{-iz}+e^{iz}}}\overbrace{\frac{e^{y+ix}+e^{-ix-y}}{e^{y+ix}+e^{-ix-y}}}^1\\ &=i\frac{e^{2y}-e^{-2y}+e^{-2ix}-e^{2ix}}{e^{2y}+e^{-2ix}+e^{2ix}+e^{-2y}}\\[3pt] &=\frac{\sin(2x)+i\sinh(2y)}{\cosh(2y)+\cos(2x)} \end{align} $$