[Tex/LaTex] Redefining \smallsetminus by smaller \setminus

math-mode

I don't like the appearance of \setminus (it's big and doesn't look good), and also don't like the appearence of \smallsetminus (its size is perfect but, in my opinion, it's too horizontal and it's not vertically center).

I found that in normal math this is what I can use:

\[
    A \mathbin{\vcenter{\hbox{$\scriptscriptstyle\setminus$}}} B
\]

Which looks like A \xsetminus B. But it's super thin. So I made the next one (I don't really now how many of those commands work, it has a lot of trial and error):

\[
    A \mathbin{\vcenter{\hbox{$\scriptscriptstyle\mathrlap{\setminus}{\hspace{.2pt}\setminus$}}} B
\]

Which looks more like A \xbsmallsetminus B.

At this point I got the desired thickness. But it's ugly if you zoom it, it's not well designed, and does not match the correct size if it's in a subscript (and less in a sub subscript).

Question:

Any ideas about how to redefine \setminus in order to get that orientation (the same as the usual \setminus), more or less the height is shown in the pictures and the same thickness of the usual \setminus (in all sizes: displaysytle, textstyle (the same as displaystyle), scriptstyle and scriptscriptstyle)?

I listen to all your ideas (including that ones where you try to convince me that the usual \setminus or \smallsetminus ar perfect).

EDIT: Here your are an example of how all looks (\setminus, my macro, \smallsetminus):

Comparison1

Here another example including @AndrewSwann \fgebackslash (\setminus, \smallsetminus, my macro, modified smaller \fgebackslash, \fgebackslash)

Comparison2

Best Answer

Given that you don't like the existing shapes in the available fonts, my other suggestion would be to use tikz to draw the symbol; you can then adjust all parameters and coordinates as you wish.

Sample output

\documentclass{article}

\usepackage{amssymb,tikz}

\newcommand{\mysetminusD}{\hbox{\tikz{\draw[line width=0.6pt,line cap=round] (3pt,0) -- (0,6pt);}}}
\newcommand{\mysetminusT}{\mysetminusD}
\newcommand{\mysetminusS}{\hbox{\tikz{\draw[line width=0.45pt,line cap=round] (2pt,0) -- (0,4pt);}}}
\newcommand{\mysetminusSS}{\hbox{\tikz{\draw[line width=0.4pt,line cap=round] (1.5pt,0) -- (0,3pt);}}}

\newcommand{\mysetminus}{\mathbin{\mathchoice{\mysetminusD}{\mysetminusT}{\mysetminusS}{\mysetminusSS}}}

\begin{document} 
\thispagestyle{empty}

\verb+\setminus,\mysetminus,\smallsetminus+:
\begin{displaymath}
 A\setminus B \qquad A \mysetminus B \qquad
A\smallsetminus B 
\end{displaymath}

\verb+\mysetminus+ in display, script and scriptscript styles
\begin{displaymath}
 A\mysetminus B\quad \scriptstyle A\mysetminus B \quad
\scriptscriptstyle A\mysetminus B
\end{displaymath}

\end{document}

The code provides separate commands for displaystyle, textstyle, scriptstyle and scriptscriptstyle and uses \mathchoice to select the correct one. I have put the textstyle version equal to the displaystyle one. In the \tikz command you can now specify exactly which line to use and what width it should have. I have made the ends of the lines round, instead of square, with the line cap option. Finally, if neccessary you can specify a different bounding box for these characters by addingg the tikz construction

\useasboundingbox (-0.5pt,-0.5pt) rectangle (5pt,8pt);

with appropriate choices of coordinates. (This will avoid the \vcenter type juggling you have in your code.)

Addition If you are worried about the overhead of using a tikz command each time, which I don't think is high in this case, then you can instead of using newcommands use boxes as follows with \newsavebox, \sbox and \usebox:

\newsavebox{\mysetminusD}
\sbox{\mysetminusD}{\hbox{\tikz{\draw[line width=0.6pt,line cap=round]
(3pt,0) -- (0,6pt);}}}
\newsavebox{\mysetminusT}
\sbox{\mysetminusT}{\mysetminusD}
\newsavebox{\mysetminusS}
\sbox{\mysetminusS}{\hbox{\tikz{\draw[line width=0.45pt,line
cap=round] (2pt,0) -- (0,4pt);}}}
\newsavebox{\mysetminusSS}
\sbox{\mysetminusSS}{\hbox{\tikz{\draw[line width=0.4pt,line cap=round] (1.5pt,0) -- (0,3pt);}}}

\newcommand{\mysetminus}{\mathbin{\mathchoice{\usebox{\mysetminusD}}{\usebox{\mysetminusT}}{\usebox{\mysetminusS}}{\usebox{\mysetminusSS}}}}
Related Question