See EDIT at end of answer for support of sqrt index in \displaystyle
.
\documentclass{article}
\usepackage{scalerel}
\def\sqrt#1{\stretchrel{\surd}{\left[#1\right]}}
\begin{document}
\[
\sqrt{x} \quad \sqrt{\frac{x}{y}} \quad
\sqrt{\frac{1}{\sqrt{\frac{1}{\sqrt{x}}}}}
\]
\end{document}
The macro \stretchrel
takes an optional integer argument indicating the maximum percent stretch allowed. Any stretch beyond that value results in an increasing width, as well. Thus defining \sqrt
as
\def\sqrt#1{\stretchrel[200]{\surd}{\left[#1\right]}}
would result in the following depiction, in which the most stretched \surd
is also widened:
If the gap between the surd and the bracket is considered too large, a negative space could be added:
\def\sqrt#1{\stretchrel{\surd}{\!\left[#1\right]}}
yielding
EDIT to support index on sqrt (but only in displaystyle). The earlier solutions support math styles, as shown in the first two examples of this MWE. Here, I introduce \dsqrt
in the third example below, which supports indices on the sqrt; however it only functions in \displaystyle
.
\documentclass{article}
\usepackage{scalerel,stackengine}
\stackMath
\def\sqrt#1{\stretchrel{\surd}{\left[#1\right]}}
%%% THE FOLLOWING DISABLES MATH-MODE PRESERVATION OF scalerel, WHICH MAKES
%%% NESTED scalerel MACROS MUCH MORE EFFICIENT BY ELIMINATING NESTED \mathchoice
\makeatletter
\def\turnoffsavemode{%
\edef\m@switch{T}\LMex=1ex\relax\LMpt=1pt\relax%
\renewcommand\ThisStyle[1]{\ifmmode\def\@mmode{T}##1\else\def\@mmode{F}##1\fi}%
}
\makeatother
%%%
% \dsqrt only works in displaystyle, but supports sqrt index
\newcommand\dsqrt[2][]{\stackinset{l}{1.8pt}{c}{2.5pt}{\scriptscriptstyle#1}%
{\turnoffsavemode\stretchrel{\surd}{\left[#2\right]}}}
\begin{document}
\[
\sqrt{x} \quad \sqrt{\frac{x}{y}} \quad
\sqrt{\frac{1}{\sqrt{\frac{1}{\sqrt{x}}}}}
\]
\[\scriptstyle
\sqrt{x} \quad \sqrt{\frac{x}{y}} \quad
\sqrt{\frac{1}{\sqrt{\frac{1}{\sqrt{x}}}}}
\]
\[
\dsqrt[3]{x} \quad \dsqrt[3]{\frac{x}{y}} \quad
\dsqrt[3]{\frac{1}{\dsqrt[3]{\frac{1}{\dsqrt[3]{x}}}}}
\]
\end{document}
(x)^{1/2}
instead?$\surd$
?\LetLtxMacro
too ;-)