Answer
\[x\tan x-\ln|\sec x|-\frac{1}{2}x^2+C\]
Work Step by Step
Let \[I=\int x\tan^2 x\:dx\]
\[I=\int x(\sec^2 x-1)\:dx\]
\[I=\int x\sec^2 x\:dx-\int x\:dx\;\;\\;\ldots(1)\]
Let\[I_1=\int x\sec^2 x\:dx\]
Using integration by parts taking
$f(x)=x\;,\;g(x)=\sec^2 x$
\[I_1=x\int \sec^2 x\:dx-\int\left(\frac{d}{dx}(x)\int\sec^2 x\:dx\right)dx\]
\[I_1=x\tan x-\int\tan x\:dx\]
\[I_1=x\tan x-\ln |\sec x|\;\;\;\ldots(2)\]
Using (2) in (1)
\[I=x\tan x-\ln|\sec x|-\frac{1}{2}x^2+C\]
Hence,
\[I=x\tan x-\ln|\sec x|-\frac{1}{2}x^2+C.\]