4

I would like to define a new division symbol similar to the bar "/" but which is a minus sign (-) rotated 45 degrees, in the same way \times is a + rotated. I want it to have the same properties as the other arithmetic symbols (+,- and \times), I mean, the same spacing etc.

What I have tried to do is the following.

% Inversa da multiplicação em anéis e grupos
\makeatletter
    \providecommand{\newdiv}{%
    \mathbin{
    \hspace{-1.5pt}\mathpalette\@rotatinganeighth{-}\hspace{-1.5pt}
    }
}
\newcommand*{\@rotatinganeighth}[2]{%
    \rotatebox[origin=c]{45}{$\m@th#1#2$}%
    }
\makeatother

The results seem fine, but I would like to have something "cleaner", I don't like the fact that I input the specific space \hspace{-1.5pt}, I just wanted it to behave as a binary operation and, if possible, as an unary operation when there is no symbol before it (the same way the minus sign behaves).

  • This sounds like \smallsetminus from amssymb, – barbara beeton Aug 23 '19 at 1:06
4

I suggest \mathpalette in order that the symbol properly scales in subscripts and superscripts.

The minus sign has height equal to the plus sign, so we need to smash it and to set it in a box as wide as the plus sign. A vertical phantom will ensure the correct height and depth.

\documentclass{article}
\usepackage{graphicx}

\makeatletter
\newcommand{\newdiv}{\mathbin{\mathpalette\@newdiv\relax}}
\newcommand{\@newdiv}[2]{%
  \begingroup
  \sbox\z@{$\m@th#1+$}%
  \makebox[\wd\z@]{\smash{\rotatebox[origin=c]{45}{$\m@th#1-$}}}%
  \vphantom{\usebox{\z@}}%
  \endgroup
}
\makeatother

\setlength{\fboxsep}{0pt}\setlength{\fboxrule}{0.1pt}% just for the example

\begin{document}

$a+b$ \fbox{$a+b$}

$a\newdiv b$ \fbox{$a\newdiv b$}

$\scriptstyle a+b\newdiv c$

\end{document}

enter image description here

| improve this answer | |
  • Thanks, that's perfect. How can I learn how to write this type of code instead of asking for help every time? Is there any didactic material available online? – Pedro G. Mattos Aug 22 '19 at 23:22
  • @PedroG.Mattos Many of these problems require ad hoc tricks; in this case the bounding box generated by the rotation would be too big. – egreg Aug 23 '19 at 8:31
3

Like this one, from \usepackage{fdsymbol}:

$a\medslash b$ $f_{a\medslash b}$

enter image description here

| improve this answer | |
  • Thanks for the answer. I chose the one above because it is more consistent with what I wanted. – Pedro G. Mattos Aug 22 '19 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.