4. If $x \in\left[-\frac{5 \pi}{12},-\frac{\pi}{3}\right]$, then the maximum value of $y=\tan \left(x+\frac{2 \pi}{3}\right)-\tan \left(x+\frac{\pi}{6}\right)+\cos \left(x+\frac{\pi}{6}\right)$ is
A. $\frac{12}{5} \sqrt{2}$
B. $\frac{11}{6} \sqrt{2}$
C. $\frac{11}{6} \sqrt{3}$
D. $\frac{12}{5} \sqrt{3}$
Let $\theta=x+\frac{\pi}{6} \in\left[-\frac{\pi}{4},-\frac{\pi}{6}\right]$, then $y=\tan \left(\theta+\frac{\pi}{2}\right)-\tan \theta+\cos \theta=\cos \theta-\frac{2}{\sin 2 \theta}$. Since the function $y$ is monotonically increasing when $\theta \in\left[-\frac{\pi}{4},-\frac{\pi}{6}\right]$, thus $y_{\text {max }}=\frac{\sqrt{3}}{2}+\frac{4}{\sqrt{3}}=\frac{11}{6} \sqrt{3}$. Therefore, the answer is $C$.