# sqrt - Advices to ameliorate spacing

I do not like the spacing printed by sqrt. In the following code, which not takes care of empty optional argument for the moment, I break the good spacing before the sqrt symbol.

\documentclass[12pt,a4paper]{article}

\let\stdsqrt\sqrt
\renewcommand\sqrt[2][]{\stdsqrt[#1\,\,]{#2\,}}

\begin{document}

Bla, bla $\sqrt{2} = \stdsqrt{2}$ et $\sqrt[2]{3} = \stdsqrt[2]{3}$ .

Bla, bla $\stdsqrt{2} = \sqrt{2}$ et $\stdsqrt[2]{3} = \sqrt[2]{3}$ .

\end{document}

• Might be an idea to include an image as well – daleif Sep 26 '19 at 18:25

You're better using \leftroot:

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}

\begin{document}

Bla, bla $\sqrt{2} = \sqrt{2}$ et $\sqrt[\leftroot{1}3]{3} = \sqrt[3]{3}$.

Bla, bla $\sqrt{2} = \sqrt{2}$ et $\sqrt[\leftroot{3}3]{3} = \sqrt[3]{3}$.

Bla, bla $\sqrt{2} = \sqrt{2}$ et $\sqrt[3\,\,]{3} = \sqrt[3]{3}$.

\end{document}


I've never seen the index just above the left margin of the radical.

• Thanks for pointing me to \leftroot such as to not have no more problem with \sqrt left unsolved. – projetmbc Sep 26 '19 at 20:43

Indeed the problem comes from the missing treatment of the first empty argument. The following code seems to do the job.

\documentclass[12pt,a4paper]{article}

\let\stdsqrt\sqrt
\renewcommand\sqrt[2][]{\if\relax\detokenize{#1}\relax\stdsqrt{#2\,}\else\stdsqrt[\!\!#1\,\,]{#2\,}\fi}

\begin{document}

Bla, bla $\sqrt{2} = \stdsqrt{2}$ et $\sqrt[2]{3} = \stdsqrt[2]{3}$ .

Bla, bla $\stdsqrt{2} = \sqrt{2}$ et $\stdsqrt[2]{3} = \sqrt[2]{3}$ .

\end{document}