# How to create a bracket-ing √-Operator?

In formulas involving square roots, I consider the overline rather irritating and would like to create an operator that turns \sqrt{x} into √[x], i.e. the argument is bracket-delimited instead of the usual overlining. How can this be achieved?

So far, I tried

\usepackage{letltxmacro}
\LetLtxMacro{\orgsqrt}{\sqrt}
\renewcommand{\sqrt}[2][]{\orgsqrt[#1]{}\left[#2\right]}


but the spacing is not very appealing:

Ideally, the end of the √-Symbol would directly connect to the ['s upper left corner.

• Not an answer your question, but have you considered writing (x)^{1/2} instead? – Najib Idrissi Feb 16 '15 at 12:15
• What about $\surd$? – user31729 Feb 16 '15 at 12:16
• @NajibIdrissi Sure, but a √ is more distinctive to spot, and fractions in exponents don't look that nice either... – Tobias Kienzler Feb 16 '15 at 12:16
• @ChristianHupfer Good point, it does look better, though that unfortunately fails at the optional argument, i.e. cube roots and the like cannot be typeset that way – Tobias Kienzler Feb 16 '15 at 12:19
• @TobiasKienzler: Then use \LetLtxMacro too ;-) – user31729 Feb 16 '15 at 12:28

## 2 Answers

If you let the \sqrt grow large it might be hard to avoid a horizontal notch at the top, but...

\documentclass{article}
\usepackage{mathtools}
\begin{document}

$\sqrt{\frac{1}{\sqrt{\frac{1}{\sqrt{x}}}}}$

\newcommand\bsqrt[2][]{%
\sqrt[{#1}]{\vphantom{\left[#2\right]}}\left[#2\right]%
}

$\bsqrt{\frac{1}{\bsqrt{\frac{1}{\bsqrt{x}}}}}$

\newcommand\bbsqrt[2][]{%
\sqrt[{#1}]{\vphantom{\left[\vcenter{\hbox{$#2$}}\right]}}%
\left[\vcenter{\hbox{$#2$}}\right]%
}

$\bbsqrt{\frac{1}{\bbsqrt{\frac{1}{\bbsqrt{x}}}}}$

\end{document}

• +1 hm, looking at the big √s makes me thing by adding a line to the lower right corner would already make it look like a [, so this question could basically be used to create a slightly different √ that is overlayed with a [... – Tobias Kienzler Feb 17 '15 at 8:47

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}


• +1, though it's too bad \surd cant do e.g. $\sqrt[3]{\ }$ – Tobias Kienzler Feb 17 '15 at 8:47
• @TobiasKienzler I have provided \displaystyle support for the feature. See edit at end of answer. – Steven B. Segletes Feb 17 '15 at 11:54
• NOTE TO READERS: The functionality of the \turnoffsavemode macro has been incorporated into the pre-existing scalerel macro named \ignoremathstyle as of version 1.7 of scalerel (FEBRUARY 2015). – Steven B. Segletes Jun 24 '15 at 11:01