6

I want to define a macro that prints two adjacent sqrt symbols. (Notation from Cauchy's analysis book).

enter image description here

I get something close but the spacing is changing depending if there is a number before it. If there is not a number in front the sqrt (surd) symbols are too close.

MWE

\documentclass[class=book]{book}
% Run with xelatex

%%% fonts
\usepackage{libertine}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

%%% mathfonts
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\usepackage{microtype}


% "221A is the surd symbol in unicode. \surd is not working, it shows a p
\usepackage{mathtools}
\NewDocumentCommand\dsqrt{o m}{%
  \IfNoValueTF{#1}{%
    \,\mathrlap{\char"221A}\,\char"221A#2%
  }%
  {
    \,\mathrlap{\raisebox{3pt}{$\scriptscriptstyle#1$}}\mathrlap{\char"221A}\,\char"221A#2%
  }
}

\begin{document}

\begin{equation}\label{pre1}
\dsqrt{a} = \pm\sqrt{a}
\end{equation}

\begin{equation}\label{pre1}
2\dsqrt{a} = \pm2\sqrt{a}
\end{equation}

\begin{equation}\label{pre1}
\dsqrt[n]{a} = \pm\sqrt[n]{a}
\end{equation}

\begin{equation}\label{pre1}
2\dsqrt[n]{a} = \pm2\sqrt[n]{a}
\end{equation}

And here is another: inline  $\dsqrt{y} =\pm \sqrt{y}$.

And here is another: inline  $2\dsqrt{y} =\pm 2\sqrt{y}$.

And here is another: inline $\dsqrt[n]{y} =\pm \sqrt[n]{y}$.

And here is another: inline $2\dsqrt[n]{y} =\pm 2\sqrt[n]{y}$.

\end{document}

enter image description here

  • Obviously I'm no Cauchy but his notation is ugly as hell. – percusse Jan 13 '16 at 12:34
  • At the moment in the old book looks nicer, but I don't like either. I am working in a translation – TeXtnik Jan 13 '16 at 12:36
  • @TeXtnik Can you post an image of the original? – egreg Jan 13 '16 at 12:40
  • You can see an example here (dl.dropboxusercontent.com/u/196902/Cauchy.pdf) – TeXtnik Jan 13 '16 at 14:02
  • @TeXtnik -- can you please provide the full bibliographic information on the book? (i've forwarded information regarding this inquiry to my unicode contacts.) – barbara beeton Jan 13 '16 at 15:33
2

Here's another attempt; unfortunately, it seems that the “surd” symbol is not available in Unicode.

\documentclass{book}
% Run with xelatex

%%% fonts
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}

%%% mathfonts
\usepackage{unicode-math}
\setmainfont{TeX Gyre Pagella}
\setmathfont{texgyrepagella-math.otf}
\usepackage{microtype}

% "221A is the surd symbol in unicode. \surd is not working, it shows a p
\NewDocumentCommand\dsqrt{o m}{%
  \mathop{%
    \IfNoValueTF{#1}
      {\doublesurd}
      {\mathrlap{^{\scriptscriptstyle#1}}\doublesurd}%
  }%
  {}#2
}

\makeatletter
\newcommand{\doublesurd}{\mathpalette\double@surd\relax}
\newcommand{\double@surd}[2]{%
  \ooalign{$\m@th#1\char"221A$\hidewidth\cr$\m@th#1\,\char"221A$\cr}%
}
\makeatother

\begin{document}

\begin{equation}
\dsqrt{a} = \pm\sqrt{a}
\end{equation}

\begin{equation}
2\dsqrt{a} = \pm2\sqrt{a}
\end{equation}

\begin{equation}
\dsqrt[n]{a} = \pm\sqrt[n]{a}
\end{equation}

\begin{equation}
2\dsqrt[n]{a} = \pm2\sqrt[n]{a}
\end{equation}

And here is another: inline  $\dsqrt{y} =\pm \sqrt{y}$.

And here is another: inline  $2\dsqrt{y} =\pm 2\sqrt{y}$.

And here is another: inline $\dsqrt[n]{y} =\pm \sqrt[n]{y}$.

And here is another: inline $2\dsqrt[n]{y} =\pm 2\sqrt[n]{y}$.

\end{document}

enter image description here

| improve this answer | |
  • I choose this one, because I think it gives better result at different math style. – TeXtnik Jan 15 '16 at 8:13
4

Here is a version that uses stacks. It is not currently set up to obey the smaller math styles, however.

\documentclass[class=book]{book}
% Run with xelatex

%%% fonts
\usepackage{libertine}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{stackengine}
\stackMath
%%% mathfonts
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\usepackage{microtype}


% "221A is the surd symbol in unicode. \surd is not working, it shows a p
\usepackage{mathtools}
\NewDocumentCommand\dsqrt{o m}{%
  \IfNoValueTF{#1}{%
    \,\stackengine{0pt}{\char"221A}{\,\char"221A#2}{O}{l}{F}{F}{L}%
  }%
  {
    \,\raisebox{3pt}{$\scriptscriptstyle#1$}\mkern-13mu\stackengine{0pt}{\char"221A}{\,\char"221A#2}{O}{l}{F}{F}{L}%
  }
}

\begin{document}

\begin{equation}\label{pre1}
\dsqrt{a} = \pm\sqrt{a}
\end{equation}

\begin{equation}\label{pre1}
2\dsqrt{a} = \pm2\sqrt{a}
\end{equation}

\begin{equation}\label{pre1}
\dsqrt[n]{a} = \pm\sqrt[n]{a}
\end{equation}

\begin{equation}\label{pre1}
2\dsqrt[n]{a} = \pm2\sqrt[n]{a}
\end{equation}

And here is another: inline  $\dsqrt{y} =\pm \sqrt{y}$.

And here is another: inline  $2\dsqrt{y} =\pm 2\sqrt{y}$.

And here is another: inline $\dsqrt[n]{y} =\pm \sqrt[n]{y}$.

And here is another: inline $2\dsqrt[n]{y} =\pm 2\sqrt[n]{y}$.

\end{document}

enter image description here

enter image description here

If one wanted the surd to match the argument size (as occurs with the \sqrt), then this definition should be substituted:

\NewDocumentCommand\dsqrt{o m}{%
  \IfNoValueTF{#1}{%
    \,\stackengine{0pt}{\sqrt{\vphantom{#2}}}{\,\sqrt{#2}}{O}{l}{F}{F}{L}%
  }%
  {
    \,\raisebox{3pt}{$\scriptscriptstyle#1$}\mkern-13mu\stackengine{0pt}{%
      \sqrt{\vphantom{#2}}}{\,\sqrt{#2}}{O}{l}{F}{F}{L}%
  }
}

Notice the difference with an x vs. a y argument.

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.