To solve this problem we will use a clever substitution to easily integrate and thus obtain the answer.First we can represent tan(x) as its fractional equivalent sin(x)/cos(x), assigning the variable u to cos(x) then du/dx is -sin(x).Having this in mind, we can rearrange the trigonometric fraction to the equivalent form (-) -sin(x)/cos(x) by simply factorising out a -1.Now its easier to see the substitution: (-)du/u (note the dx from the denominator cancels out with that of the integrand).
Finally complete the integration of -du/u, which is -ln(u) + C where C is a constant. Back-substitute the value of u to have -ln(cos(x)) + C. Note this can be written in the form as ln(cos(x)-1) or ln(sec(x)). So the indefinite integral of tan(x) is ln(sec(x)) + C.