Step 1: Use identity for \( \tan^2\theta \).
\[
\tan^2\theta = \sec^2\theta - 1.
\]
So,
\[
\int \tan^2\left(5-\frac{x}{2}\right) dx = \int \left[\sec^2\left(5-\frac{x}{2}\right) - 1\right] dx.
\]
Step 2: Split the integral.
\[
= \int \sec^2\left(5-\frac{x}{2}\right) dx - \int dx.
\]
Step 3: Substitute \( u = 5 - \frac{x}{2} \).
\[
u = 5 - \frac{x}{2}, \quad \frac{du}{dx} = -\frac{1}{2}.
\]
\[
dx = -2\,du.
\]
Step 4: Transform the integral.
\[
\int \sec^2\left(5-\frac{x}{2}\right) dx = \int \sec^2(u)(-2\,du).
\]
\[
= -2 \int \sec^2(u)\,du.
\]
Step 5: Integrate.
\[
\int \sec^2(u)\,du = \tan(u).
\]
So,
\[
-2 \tan(u).
\]
Step 6: Substitute back.
\[
-2\tan\left(5-\frac{x}{2}\right).
\]
Now include the second part:
\[
\int dx = x.
\]
So total integral becomes:
\[
-2\tan\left(5-\frac{x}{2}\right) - x + C.
\]
Step 7: Final conclusion.
Thus, the required integral is:
\[
\boxed{-2\tan\left(5-\frac{x}{2}\right) - x + C}.
\]