When dealing with complex trigonometric functions, it is quite natural to ask how the real/imaginary part of $\tan(a+bi)$ can be expressed using $a$ and $b$. Of course, since $\tan z$ and $\tanh z$ are tightly linked for complex variables, we could derive the real/imaginary part for hyperbolic tangent from the corresponding results for $\tanh(a+bi)$ and vice-versa. (We have $\tanh(iz)=i\tanh z$ and $\tan(iz)=i\tanh(z)$.)
I was not able to find this in a few basic sources I looked at. For example, I do not see it in the Wikipedia articles Trigonometric functions (current revision) and Hyperbolic function (current revision). (And List of trigonometric identities (current revision) does not mention much about complex trigonometric functions other than the relation to the exponential function.)
I have at least tried to find what are a results for some specific value of $a$ and $b$. I have tried a few values in WolframAlpha, for example, tangent of $2+i$, tangent of $1+2i$, tangent of $1+i$. On this site I found this question: Calculate $\tan(1+i)$.
I have tried to calculate this myself, probably my approach is rather cumbersome - I post it below as an answer. I will be grateful for references, different derivations, different expressions for this formula. (And I will also be grateful if I receive some corrections to my approach - but do not treat this primarily as a solution-verification question, it is intended as a general question.)