4

I want to overlay one math symbol on over another -- not on top, but literally overlap. In the language of good-old typewriter (!): Type a character, moving one character back and retype another character at the same spot. Following

\subseteq + \circ as a single symbol ("open subset")

I came up with the following minimal working example:

\documentclass{amsart}
\begin{document}
$
\mathrel{\ooalign{\hss\circ\hss\cr\times}}
$
\end{document}

The symbols overlay the way I want, but I also got repeated error message

Missing $ inserted.

I am confused... Your help and comments are most appreciative!

(note: The example above is just to show what I was trying to do; I know that I can get this particular combo of symbols in other ways)

David Carlisle
  • 757,742
underflow
  • 559

2 Answers2

6

\ooalign is based on \halign which like \hbox takes you out of math mode so you could use

\documentclass{amsart}
\begin{document}
$
\mathrel{\ooalign{\hss$\circ$\hss\cr$\times$}}
$
\end{document}

although usually you would use a \mathchoice construct to adapt to superscripts etc.

enter image description here

\documentclass{amsart}

\newcommand\zza{\mathrel{\ooalign{\hss$\circ$\hss\cr$\times$}}}

\newcommand\zzb{\mathrel{\mathpalette\zzbb{}}} \newcommand\zzbb[1]{\ooalign{\hss$#1\circ$\hss\cr$#1\times$}}

\begin{document} $ 1 \zza -2 + x^{1 \zza 2} $

$ 3 \zzb -4 + x^{3 \zzb 4} $ \end{document}

David Carlisle
  • 757,742
2

If you look at the code in the linked answer, you'll see that \subseteq is surrounded by $ signs:

\newcommand{\opncls}[2]{%
  \ooalign{$#1\subseteq$\cr
  \hidewidth\raisefix{#1}\hbox{$#1#2\mkern.5mu$}\cr}}

These are necessary, because the contents of \ooalign is typeset in text mode.

Your symbol should probably be a \mathbin, as it's composed of two binary operation symbols (the symbol for the linked answer was instead a binary relation).

Also that answer skips over some finer aspects that one day I'll include.

Thus you should do

\makeatletter
\newcommand{\circtimes}{\mathbin{\vphantom{\times}\mathpalette\circtimes@\relax}}
\newcommand{\circtimes@}[2]{%
  \ooalign{$\m@th#1\times$\cr\hidewidth$\m@th#1\circ$\hidewidth\cr}%
}
\makeatother

Full example:

\documentclass{article}
\usepackage{amsmath} % not really required for this example

\makeatletter \newcommand{\circtimes}{\mathbin{\vphantom{\times}\mathpalette\circtimes@\relax}} \newcommand{\circtimes@}[2]{% \ooalign{$\m@th#1\times$\cr\hidewidth$\m@th#1\circ$\hidewidth\cr}% } \makeatother

\begin{document}

\begin{gather} A \circtimes B^{\circtimes} \ A \times B^{times} % for comparison \end{gather}

\end{document}

enter image description here

  1. \vphantom{\times} is necessary to get the correct bounding box.
  2. \m@th is necessary to counteract a possible positive value of the \mathsurround parameter.
egreg
  • 1,121,712