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?
Best Answer
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, the5
that it is of type\mathclose
, the02F
that the non extensible variant of the delimiter is in position2F
in the math font number0
(that's theoperators
font which is used for\sin
, etc.), the30E
that the extensible version of the delimiter is in position0E
in the math font number3
(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: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: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 forno space
):