4

I want to create two math mode binary operation symbols:

(1) A combination of - (minus symbol) and * (asterisk)

(2) A combination of / (slash symbol) and * (asterisk)

The desired result would be something that looks like the following but is kerned and centered properly and has the left-right spacing of a typical binary operation:

a \minusast b = c \slashast d.

\documentclass[12pt]{article}

\begin{document}
\Huge\[a \mathbin{-\mkern-11.5mu*} b = c \mathbin{/\mkern-8.875mu*} d.\] % my makeshift solution
\end{document}
\[a \minusast b = c \slashast d.\] % desired macro names and syntax

My question is:

How do I create the custom math mode binary relation symbols (1) and (2)?

It would also be nice if there's a version of (2) where the / symbol is adjusted to be a diagonal axis of symmetry of the * symbol.

If it's also possible, how do I generally create a custom math mode binary operation symbol that is a combination of two binary operation symbols?

Thank you.

2

3 Answers 3

8

Something like this? (updated to take into account the OP's additional requirement)

enter image description here

\documentclass{article} 

\usepackage{graphicx} % for '\rotatebox' macro
\newcommand\myslash{\rotatebox[origin=c]{-30}{$\vert$}}

\newcommand\minusast{\mathbin{\ooalign{\hss$*$\hss\cr$-$}}}
\newcommand\slashast{\mathbin{\ooalign{\hss$*$\hss\cr$\myslash$}}}

\begin{document}
$a\minusast b = c \slashast d$
\end{document}
5
  • Thank you for answering. This answer should suffice but as I stated in the question, I was wondering if there is a way to make a custom / such that it divides the asterisk * into two symmetric halves diagonally. So the / would be slightly tilted clockwise. Feb 1, 2023 at 20:07
  • @AmanuensisFrances - I'll need to think about this for a sec...
    – Mico
    Feb 1, 2023 at 20:12
  • @AmanuensisFrances - Please see the updated answer. The main change is that I've replaced / with a vertical bar that's been rotated 30 degrees clockwise. (The / symbols is rotated "only" 20 degrees from vertical...)
    – Mico
    Feb 1, 2023 at 20:24
  • 1
    Thank you very much! Feb 1, 2023 at 20:27
  • An additional observation: The macros \minusast and \slashast shown above work for \displaystyle and \textstyle math. If you need to use them in level-1 or (shudder) level-2 subscript and superscript positions as well, you should employ the versions of the macros provided in the answers of SandyG and egreg.
    – Mico
    Feb 2, 2023 at 9:30
4

The following will work in scriptstyle and scriptscriptstyle.

enter image description here

\documentclass{article}

\usepackage{graphicx}

\makeatletter
\newcommand{\asth}{\mathbin{\mathpalette\ast@h\relax}}
\newcommand{\ast@h}[2]{%
  \ooalign{%
    \hfil$\m@th#1*$\hfil\cr
    \hfil\rotatebox[origin=c]{-30}{$\m@th#1\mid$}\hfil\cr
  }%
}
\newcommand{\astd}{\mathbin{\mathpalette\ast@d\relax}}
\newcommand{\ast@d}[2]{%
  \ooalign{%
    \hfil$\m@th#1*$\hfil\cr
    $\m@th#1-$\cr
  }%
}
\makeatother

\begin{document}

$a*b\asth c\astd a$

\end{document}
4
  • Are the * and rotated-slash symbols aligned on the same center? And should the new symbols be of type mathbin rather than mathrel?
    – Mico
    Feb 1, 2023 at 20:26
  • @Mico: Yes, mathbin not mathrel. Don't know what I was thinking. As for the centers, I believe they are the same, but the rotation should happen outside the switch to math mode. Fixed now.
    – Sandy G
    Feb 1, 2023 at 20:36
  • 1
    +1 I wonder whether the apparent slight asymmetry in the slash is a rendering issue of the pdf viewer. (Can't test now, but rotating math can be tricky, I remember writing an extra macro for that.)
    – campa
    Feb 1, 2023 at 20:40
  • 1
    @campa: I think it's a viewer issue. At 2000% there is no apparent asymmetry.
    – Sandy G
    Feb 1, 2023 at 20:45
4

The idea is to use \mathpalette and \ooalign. Some tricks are necessary, though: a \vphantom{*} ensures the correct bounding box, because \ooalign gets the height from the first item and the depth from the second one.

For the slash, one can use \centernot from the eponymous package.

\documentclass{article}
\usepackage{amsmath}
\usepackage{centernot}

\makeatletter
\newcommand{\astminus}{\mathbin{\mathpalette\astminus@\relax}}
\newcommand{\astminus@}[2]{%
  \vphantom{*}%
  \ooalign{\hidewidth$\m@th#1*$\hidewidth\cr$\m@th#1-$\cr}%
}
\makeatother
\newcommand{\astslash}{\mathbin{\centernot{*}}}

\begin{document}

$a\astminus b \astslash c$

$\scriptstyle a\astminus b \astslash c$

$\scriptscriptstyle a\astminus b \astslash c$

\end{document}

enter image description here

A different version where the \astslash symbol is obtained by rotating 60 degrees \astminus. Don't ask too much about how this is obtained. 😊

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}

% syntactic sugar
\newcommand{\xmathpalette}[2]{%
  \mathchoice
    {#1\displaystyle\textfont{#2}}
    {#1\textstyle\textfont{#2}}
    {#1\scriptstyle\scriptfont{#2}}
    {#1\scriptscriptstyle\scriptscriptfont{#2}}
}

\makeatletter
\newcommand{\astminus}{\mathbin{\mathpalette\astminus@\relax}}
\newcommand{\astminus@}[2]{%
  \vphantom{*}%
  \ooalign{\hidewidth$\m@th#1*$\hidewidth\cr$\m@th#1-$\cr}%
}

\newcommand{\astslash}{\mathbin{\xmathpalette\astslash@\relax}}
\newcommand{\astslash@}[3]{%
  \begingroup\settowidth\dimen@{$\m@th#1*$}%
  \makebox[\dimen@][s]{%
    \hspace{0pt minus 1fil}%
    \raisebox{0pt}[0.75\height][0.1\depth]{%
      \rotatebox[origin=c]{60}{%
        \raisebox{\dimexpr2\fontdimen22 #2 2 - \height}{%
          $\m@th#1\astminus$%
        }%
      }%
    }%
    \hspace{0pt minus 1.8fil}%
  }%
  \endgroup
}
\makeatother

\begin{document}

\fboxsep=0pt\fboxrule=0.1pt
\fbox{$\astslash$}\fbox{$*$}

$a\astminus b \astslash c$

$\scriptstyle a\astminus b \astslash c$

$\scriptscriptstyle a\astminus b \astslash c$

\end{document}

A lot of visual formatting, but the main idea is simple. I lower the \astminus symbol so it lies on the baseline, then rotate it. The bounding box has been set by eye.

enter image description here

2
  • (Already upvoted several hours ago.) A factoid I wasn't aware of until now is that the slash symbol provided by \centernot{ } is tilted 30 degrees to the right, and not just 20 degrees as is the case for /. (Until now, I had simply assumed that the tilt angle was the same for both slash-y symbols.) Oddly, though, while centernot's centering of the slash symbol is fine if \scriptstyle is in effect, it's a tiny bit off if \scriptscriptstyle is in effect, possibly (likely?) because the tilt angle is noticeably larger if \scriptscriptstyle is in effect. Should I inform Heiko about this?
    – Mico
    Feb 2, 2023 at 7:28
  • 1
    @Mico I don’t think Heiko can do anything about this: \centernot uses the \not symbol and that’s all it can get.
    – egreg
    Feb 2, 2023 at 7:40

You must log in to answer this question.

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