# Legendre symbol in theory of numbers

How can I get a Legendre symbol

,

which just used the dashed line instead of the fractional rule?

-

\documentclass[a4paper]{article}
\usepackage{amsmath}
\makeatletter
\def\legendre@dash#1#2{\hb@xt@#1{%
\kern-#2\p@
\vrule\@height.2\p@\@depth.2\p@\@width\p@
\kern.5\p@}\hfil
\kern-#2\p@
}}
\def\@legendre#1#2#3#4#5{\mathopen{}\left(
\sbox\z@{$\genfrac{}{}{0pt}{#1}{#3#4}{#3#5}$}%
\dimen@=\wd\z@
\kern-\p@\vcenter{\box0}\kern-\dimen@\vcenter{\legendre@dash\dimen@{#2}}\kern-\p@
\right)\mathclose{}}
\newcommand\legendre[2]{\mathchoice
{\@legendre{0}{1}{}{#1}{#2}}
{\@legendre{1}{.5}{\vphantom{1}}{#1}{#2}}
{\@legendre{2}{0}{\vphantom{1}}{#1}{#2}}
{\@legendre{3}{0}{\vphantom{1}}{#1}{#2}}
}
\def\dlegendre{\@legendre{0}{1}{}}
\def\tlegendre{\@legendre{1}{0.5}{\vphantom{1}}}
\makeatother

\begin{document}
$\genfrac(){}{0}{a}{b}$

$\dlegendre{a}{b}\dlegendre{10}{20}$

$\genfrac(){}{}{a}{b}\legendre{a}{b}\legendre{100}{200}$

$\scriptstyle\genfrac(){}{}{a}{b}\legendre{a}{b}\legendre{10}{20}$

$\scriptscriptstyle\genfrac(){}{}{a}{b}\legendre{a}{b}\legendre{10}{20}$

$\displaystyle\legendre{a}{b}\textstyle\legendre{a}{b} \scriptstyle\legendre{a}{b}\scriptscriptstyle\legendre{a}{b}$
\end{document}


The user command are \legendre that typesets the symbol in the current math style or \dlegendre and \tlegendre to force display or text style.

The \genfrac parts are only for comparisons.

-
The $\genfrac(){}{}{p}{q}\legendre{p}{q}$ get a bit of larger parenthese. – fas Jun 10 '11 at 16:52
@fas: I've edited the macros. – egreg Jun 10 '11 at 17:10
@fas: I should add that I've seen nowhere this notation. – egreg Jun 10 '11 at 20:08

If you are going to use this type of notation a lot, I am not sure if the following is suitable but at least, it is quite simple to get some automation wrapped around it

\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix}

\newcommand{\lege}[2]{\ensuremath{%
\begin{aligned}
\begin{tikzpicture}
\node[matrix of math nodes,left delimiter=(,right delimiter=)] (lege) at (0,0) {
#1  \\
#2  \\
};
\draw[densely dashed] (lege.west) -- (lege.east);
\end{tikzpicture}\end{aligned}}%
}

\begin{document}
$\lege{1252}{567}\lege{1}{0} \int^\infty_0{dx}$
\end{document}


I can't foresee any problems with my code but I can sense that there are. Hence, I am pretty sure that advanced users here would find a smarter way to do it (especially the spacing of the delimiters with xshift etc.). You can scale the whole tikzpicture to get different sizes. Cheers.

-

Interesting question. My first idea was to write In french the symbol is

$\left(\dfrac{a}{b}\right)$


but without dashed line, the second idea was to use \genfrac but I don't know how to draw the dashed line so the last idea is to use arydshln

\documentclass[10pt]{article}
\usepackage{amsmath,arydshln}

\def\Legendre(#1,#2){%
\begin{pmatrix}
#1\cr
\hdashline[1pt/1pt]
#2\cr
\end{pmatrix}}

\begin{document}
$\Legendre(97,37)$
\end{document}


-
Looking at the code, \genfrac uses \over (or \above) internally so the line is produced by a primitive and thus I don't think one could easily modify \genfrac to produce a dashed line. Shame. – Loop Space Jun 10 '11 at 7:56