What is the best way to typeset mathematical quotients and double quotients?

I mean constructions like X/~ (~ an equivalence relation on X) and G\X/H (where G and H are groups acting on X). While the simple case is solved by something like X/\mathord\sim (or maybe with \mathbin/), this gets hard to parse for the reader in more complicated situations and with double quotients. An alternative is a slanted \sfrac{X}{\mathord\sim} (from xfrac), but that makes the X rather small and doesn't work for double quotients.

Do you have better ideas?

  • Could you add an example of a more compicated situation?
    – morbusg
    Commented Dec 14, 2010 at 10:28
  • 2
    Maybe this is (partly) answered here? Commented Dec 14, 2010 at 10:50

2 Answers 2


The problem is that TeX's spacing table is missing a class for / and \ which are binary operators without any spacing before and after. As it's not possible to add spacing classes like \mathrel, \mathbin (I hope it will be possible one day with LuaTeX), there is no perfect solution for this problem.

One way to emulate this spacing class is to use \mathclose{}/\mathopen{}, but this will not work with \big, \middle, etc. In order to get around this problem, you need to use the TeX primitive \delimiter (the LaTeX equivalent \DeclareMathDelimiter won't do here because it doesn't allow to add code after it). For the slash, it is \delimiter"502F30E. The " indicates it's a hex number, the 5 that it is of type \mathclose, the 02F that the non extensible variant of the delimiter is in position 2F in the math font number 0 (that's the operators font which is used for \sin, etc.), the 30E that the extensible version of the delimiter is in position 0E in the math font number 3 (that's the font containing extensible symbols). So by using \delimiter"502F30E\mathopen{}, we would have something which has the correct spacing and works well with \left, \right, etc.

There are two choices now: either you define a macro containing this definition (which is the natural solution for \backslash) or you want just to type / and still get the correct spacing. For the first solution, you could use any macro, but if you want to use \slash and keep the original definition of \slash in text mode, you could use something like this:





$E\slash\sim$ $\left.E\middle\slash\sim\right.$

$H\backslash G\slash K$ $\left.H\middle\backslash G\middle\slash K\right.$


If you prefer the second solution, you must make / active in math mode (in text mode, it will remain normal). It's a bit tricky if you want it to work well with babel packages which also mess with active characters. The following is adapted from code used by the magyar language babel module for their factorial:


\makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Define \addto if it doesn't exists


% Command to add commands "at every math formula" which
% takes into account the package nath.
% Adapted from:
%   http://www.math.bme.hu/latex/magyar_pre_tug2004.pdf#page=28

  \expandafter\addto\csname \expandafter\ifx
  \csname mathoptions@on\endcsname\relax % detect nath.sty
  check@mathfonts\else mathoptions@on\fi\endcsname

% Command to define a single character even when it is not active
% with a lowercase trick


% Command to change the definition of #1 into #2 ; beware of cyclic
% behaviours when using this to redefine characters like !, :, or ;
% Adapted from:
%   http://www.math.bme.hu/latex/magyar_pre_tug2004.pdf#page=28

    \catcode`#1=12 \mathcode`#1="8000

\makeatother %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




$E/\sim$ $\left.E\middle/\sim\right.$

$H\backslash G/ K$ $\left.H\middle\backslash G\middle/ K\right.$


The macro \fixmathspacing should work with any math character you want (semi-colon, etc.), just beware of cyclic redefinitions as mentioned in the comments of the code (using \delimiter or \mathchar is safe).

One last thing: if you want to specify the height of the slash or backslash, neither \big nor \bigm will produce the right spacing (unlike \middle) so you should probably also define a new \big variant, called for example \bign (n standing for no space):

alt text

\def\bign#1{\mathclose{\hbox{$\left#1\vbox to8.5\p@{}\right.\n@space$}}\mathopen{}}
\def\Bign#1{\mathclose{\hbox{$\left#1\vbox to11.5\p@{}\right.\n@space$}}\mathopen{}}
\def\biggn#1{\mathclose{\hbox{$\left#1\vbox to14.5\p@{}\right.\n@space$}}\mathopen{}}
\def\Biggn#1{\mathclose{\hbox{$\left#1\vbox to17.5\p@{}\right.\n@space$}}\mathopen{}}
\verb"\big" & $E\big/\sim$ & $E\Big/\sim$ & $E\bigg/\sim$ & $E\Bigg/\sim$ & too much space after \\
\verb"\bigm" & $E\bigm/\sim$ & $E\Bigm/\sim$ & $E\biggm/\sim$ & $E\Biggm/\sim$& too much space before \\
\verb"\bign" & $E\bign/\sim$ & $E\Bign/\sim$ & $E\biggn/\sim$ & $E\Biggn/\sim$ & correct spacing \\
  • Thank you, this looks good. I'll accept your answer once I had some time to play around with it.
    – Caramdir
    Commented Dec 15, 2010 at 16:36
  • Just a small observation: \backslash and / are of type Ord, not Bin. The spacing in your first example comes actually from the fact that \sim is of type Rel.
    – morbusg
    Commented Dec 19, 2010 at 16:13
  • @morbusg: syntactically, \backslash and / are binary operators, but, as their spacing is special, they cannot be of type \mathbin. The choice of \mathord for them was probably not the best as putting / of type \mathopen and \backslash of type \mathclose prevents the most obvious problems like E/\sim, E/\ker f, n/\ln n and \sim\backslash E and requires no hacks. Commented Dec 19, 2010 at 18:07
  • @PhilippeGoutet: I guess you mean ‘So by using \delimiter"502F30E\mathopen{}’ at the end of the second paragraph, don’t you?
    – mhp
    Commented Aug 31, 2012 at 11:57
  • @mhp: yes, it should be \mathopen. I've edited the answer to correct it. Commented Aug 31, 2012 at 14:37

The simplest way to write the tilde is to wrap \sim in braces (so the quotient set is denoted X/{\sim}). This stops TeX from treating \sim as a binary operator, so the tilde is spaced correctly.

Source: http://pbelmans.wordpress.com/2010/11/16/caveat-correct-spacing-in-quotient/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .