(7) The maximum value of the function $y=\tan x-\frac{2}{|\cos x|}$ is ( ).
(A) $1-2 \sqrt{2}$
(B) $1+2 \sqrt{2}$
(C) $-\sqrt{3}$
(D) $\sqrt{3}$
(7) To maximize $y$, we should have $\tan x > 0$. Suppose $0 < x < \frac{\pi}{2}$, then
$$
y = \tan x - \frac{2}{\cos x} = \frac{\sin x - 2}{\cos x},
$$

which means
$$
\sin x - y \cos x = 2.
$$

Therefore,
$$
\sin (x - \theta) = \frac{2}{\sqrt{1 + y^2}}
$$

where $\tan \theta = y$. Since $\sin (x - \theta) \leq 1$, we get $\frac{2}{\sqrt{1 + y^2}} \leq 1$, solving which yields $y \leq -\sqrt{3}$ or $y \geq 3$. It is easy to see that $y < 0$, so $y \leq -\sqrt{3}$. Substituting $y = -\sqrt{3}$ into $\sin x - y \cos x = 2$, we get $x = \frac{\pi}{6}$. Hence, $y_{\max} = -\sqrt{3}$. Therefore, the answer is C.