# How to draw backslash in a certain way

I know there are fair number of questions that have been asked before on how to typeset a backslash; but I am looking for a specific placement of \ as shown below:

I tried \diagdownbut I am not able to put G below the \ as shown in the screenshot.

• The usual manner is just to write $G\backslash X$ as it would else disturb line spacing. Hmm, I almost recognize the handwriting. Feb 5, 2014 at 9:57
• Try something like \raisebox{-.8ex}{$G$}\mkern-2mu\diagdown\mkern-4mu\raisebox{.6ex}{$H$} Feb 5, 2014 at 10:21
• Who wrote the quoted text? Feb 5, 2014 at 11:14
• If you want to have code that behaves nicely under various conditions, I would adapt the code in nicefrac.sty to your needs. You'll have to mirror the lengths and replace the / by either \backslash or \diagdown or \reflectbox{/} but it should be relatively straightforward. Feb 5, 2014 at 11:44
• @daleif: The author is Zev Chonoles. The quoted text is from the bottom of page 2 of his Math 2510 Notes. Feb 5, 2014 at 16:11

\documentclass{article}
\usepackage{amsmath}
\newcommand\mySlash[2]{\ensuremath{%
\!\sideset{_#1}{\!\!^#2}{\mathop\backslash}}}
\begin{document}

\Huge$x\cdot\mySlash{G}{X}$ \mySlash{G}{X}

\end{document}


• I am grateful for all the answers I got, and this answer seems to use the least machinery. ✔ Feb 6, 2014 at 14:58

I just create the numerator and denominator relative to the backslash with stacks, and then I kern the two pieces together.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{calc}
\newlength\tbsw
\setlength{\tbsw}{\widthof{\textbackslash}}
\newcommand\bsfrac[2]{%
\renewcommand\stacktype{L}%
\renewcommand\stackalignment{r}%
\mathop{%
\stackunder[4pt]{\textbackslash}{$\scriptstyle #1$~}%
\kern-\tbsw%
\renewcommand\stackalignment{l}%
\stackon[3pt]{\textbackslash}{~$\scriptstyle #2$}%
}%
}
\begin{document}
The quotient (or orbit) space $\bsfrac{G}{X}$ is the set\ldots
\end{document}


Here is an alternate, with a more tilted backslash:

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{graphicx}
\def\tbs{\rotatebox{30}{\textbackslash}}
\newlength\tbsw
\setlength{\tbsw}{\widthof{\tbs}}
\newcommand\bsfrac[2]{%
\renewcommand\stacktype{L}%
\renewcommand\stackalignment{r}%
\mathop{%
\stackunder[3pt]{\tbs}{$\scriptstyle #1$\ \,}%
\kern-\tbsw%
\renewcommand\stackalignment{l}%
\stackon[4pt]{\tbs}{\ \,$\scriptstyle #2$}%
}%
}
\begin{document}
The quotient (or orbit) space $\bsfrac{G}{X}$ is the set\ldots
\end{document}


Here is an answer based on Angled fraction. The use of TikZ is a little bit heavy but I don't know other way to do it...

\documentclass{article}
\usepackage{tikz}
\usepackage{calc}

\newcommand*{\TextScale}{0.75}
\newcommand*{\SlashAngle}{-45}
\newcommand*{\SlashScale}{1.5}

\newlength{\NeumeratorXShift}
\newlength{\DenomiatorXShift}
\newlength{\NeumeratorYShift}
\newlength{\DenomiatorYShift}

\tikzset{Slash/.style={scale=\SlashScale, rotate=\SlashAngle}}
\tikzset{Neumerator/.style={scale=\TextScale, xshift=-\NeumeratorXShift, yshift=-\NeumeratorYShift, inner sep=0, outer sep=0}}
\tikzset{Denominator/.style={scale=\TextScale, xshift=\DenomiatorXShift, yshift=\DenomiatorYShift, inner sep=0, outer sep=0}}
\newcommand{\Sfrac}[2]{%
\pgfmathsetlength{\NeumeratorXShift}{0.1em+0.5*\widthof{$#1$}}%
\pgfmathsetlength{\DenomiatorXShift}{0.1em+0.5*\widthof{$#2$}}%
\pgfmathsetlength{\NeumeratorYShift}{0.2ex+0.5*\heightof{$#1$}}%
\pgfmathsetlength{\DenomiatorYShift}{0.2ex+0.5*\heightof{$#2$}}%
\tikz [x=1.4ex,y=1.4ex,line width=.09ex, baseline, yshift=0.6ex]
\draw [Slash] (-0.45,0.0) -- (0.45,0)
node  [Neumerator ] at (0,0) {$#1$}
node  [Denominator] at (0,0) {$#2$};
}%

\begin{document}
The quotient (or orbit) space $\Sfrac{G}{X}$ is the set of blablabla ...
\end{document}


A solution that mimics the spacing around \frac, but with slanted fraction line.

\documentclass{article}
\usepackage{graphicx}

\makeatletter
\newcommand*{\revfrac}[2]{%
\ensuremath{%
\mathchoice
{\revfrac@{\displaystyle}{\textstyle}{#1}{#2}}%
{\revfrac@{\textstyle}{\scriptstyle}{#1}{#2}}%
{\revfrac@{\scriptstyle}{\scriptscriptstyle}{#1}{#2}}%
{\revfrac@{\scriptscriptstyle}{\scriptscriptstyle}{#1}{#2}}%
}%
}
\newcommand*{\revfrac@factor}{.5}
\newcommand*{\revfrac@}[4]{%
% dimen 0: height of math axis
\setbox0=\hbox{$#1\vcenter{}$}%
\dimen0=\ht0 %
%
% box 0: numerator
\sbox0{$#2#3\m@th$}%
\ifdim\dp0=\z@
\else
\setbox0=\hbox{\raise\dp0\box0}%
\fi
%
% box 2: denominator
\sbox2{$#2#4\m@th$}%
\ifdim\dp2=\z@
\else
\setbox2=\hbox{\raise\dp2\box2}%
\fi
%
% dimen 2: max. width of unrotated fraction = length of fraction line
\ifdim\wd0>\wd2 %
\dimen2=\wd0 %
\else
\dimen2=\wd2 %
\fi
% box 4: rotated fraction line with middle point at base line
% dimen 4: side bearings of \frac
% dimen 6: half of the thickness of rule with separation space
% For getting the line separation space, an object with an depth
% is needed to minimize the space
\setbox4=\hbox{\kern1ex}%
\dimen6=\wd4 %
\sbox4{%
$% #1% \frac{\kern\dimen2\vrule width\z@ depth\dimen6}{\kern\dimen2}% \m@th$%
}%
\dimen4=.5\dimexpr\wd4-\dimen2\relax
\dimen6=\dimexpr\ht4-\dimen0-\dimen6\relax
\setbox4=\hbox to \dimen2{\hss\lower\dimen0\copy4\hss}%
\ht4=.2pt %
\dp4=.2pt %
\sbox4{\rotatebox[x=.5\wd4,y=\z@]{-30}{\copy4}}%
%
% output left side bearing
\kern\dimen4 %
% output denominator
\dimen8=\dimexpr
-.5\wd2 %
+.4330127\dimexpr\revfrac@factor\ht2\relax % 0.4330127 = 0.5 * sin(60)
+.125\wd2 % .125 = .5 * sin(30) * sin(30)
+.5\dimen6 % 0.5 = sin(30)
-.5\wd4 %
\relax
\ifdim-\dimen8>\wd2 %
\kern\dimexpr-\dimen8-\wd2\relax
\fi
\raise\dimexpr
\dimen0 %
-\ht2 %
-.216506351\wd2 % 0.216506351 = 1/4 sin(60)
-.8660254\dimen6 % 0.8660254 = sin(60)
+.25\dimexpr\revfrac@factor\ht2\relax % 0.25 = sin(30) * sin(30)
\relax\copy2 %
% output fraction line
\kern\dimen8 %
\raise\dimen0\copy4 %
% numerator
\dimen8=\dimexpr
-.5\wd4 %
+.4330127\dimexpr\revfrac@factor\ht0\relax % 0.4330127 = 0.5 * sin(60)
+.125\wd0 % .125 = .5 * sin(30) * sin(30)
+.5\dimen6 % 0.5 = sin(30)
-.5\wd0 %
\relax
\kern\dimen8 %
\raise\dimexpr
\dimen0 %
+.216506351\wd0 % 0.216506351 = 1/4 sin(60)
+.8660254\dimen6 % 0.8660254 = sin(60)
-.25\dimexpr\revfrac@factor\ht0\relax % 0.25 = sin(30) * sin(30)
\relax\copy0 %
\ifdim-\dimen8>\wd0 %
\kern\dimexpr-\dimen8-\wd0\relax
\fi
% output right side bearing
\kern\dimen4
}
\makeatother

\begin{document}
\centering
The quotient space $\revfrac{X}{G}$ is the set of \dots
$X = \bigsqcup_{\bar x\in\revfrac{X}{G}} \bar x$
$\revfrac{X}{G} > \textstyle \revfrac{X}{G} > \scriptstyle \revfrac{X}{G} > \scriptscriptstyle \revfrac{X}{G}$
\newcommand*{\fboxed}[1]{%
\begingroup
\setlength{\fboxsep}{0pt}%
\setlength{\fboxrule}{.2pt}%
\fbox{$#1$}%
\endgroup
}
$\fboxed{\revfrac{a}{b+c+d}}\; \fboxed{\revfrac{\fboxed{a+b+c}}{d}}\; \fboxed{\revfrac{\fboxed{\frac{a}{b}}}{\fboxed{\frac{c}{d}}}} \;\fboxed{\revfrac{\fboxed{a}}{\fboxed{b+c+d}}}$
\end{document}