[tex]\displaystyle\int\frac{\sqrt{x^2+1}}x\,\mathrm dx=\int\frac{\sqrt{\tan^2B+1}}{\tan B}\sec^2B\,\mathrm dB[/tex]
[tex]\tan^2B+1=\sec^2B[/tex]
[tex]\sqrt{\sec^2B}=\sec B[/tex] (provided that [tex]\sec B>0[/tex])
Then
[tex]\dfrac{\sec B}{\tan B}\cdot\sec^2B=\dfrac{\sec^2B}{\tan B}\cdot\sec B[/tex]
(just moving around a factor of [tex]\sec B[/tex])
[tex]\dfrac{\sec B}{\tan B}\cdot\sec^2B=\dfrac{\sec^2B}{\tan^2B}\cdot\sec B\tan B[/tex]
(multiply by [tex]\dfrac{\tan B}{\tan B}[/tex])