Skip to main content
Added box based version of commands
Source Link
Andrew Swann
  • 98.4k
  • 13
  • 210
  • 473

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}}}}

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.)

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}}}}
Source Link
Andrew Swann
  • 98.4k
  • 13
  • 210
  • 473

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.)