Here is a possibility:
\newcommand\opn{\mathrel{\ooalign{$\subseteq$\cr
\hidewidth\raise.225ex\hbox{$\circ\mkern.5mu$}\cr}}}
\newcommand\cls{\mathrel{\ooalign{$\subseteq$\cr
\hidewidth\raise.225ex\hbox{$\bullet\mkern.5mu$}\cr}}}
The symbols will change size according to the context. They don't reduce in subscript or superscripts, for that something more is needed.
This is a case where \ensuremath
is superfluous, since the symbols will always be used in math mode, except perhaps in their definition, where adding $
symbols around them is not much of a hassle.
The low level \ooalign
command is one of my favorite tools. I'm telling TeX to superimpose the two symbols, the circle or bullet is aligned at right, but pushed left a bit by \mkern.5mu
and raised with a font dependent dimension (the amount 0.225ex has been computed by trial and error). Act on \mkern.5mu
if you want to push the circles a bit more to the left.
Here's the result of $A\opn B\cls C$
A quick course on \ooalign
Think to \ooalign{...}
pretty much like
\begin{tabular}[t]{@{}l@{}}
...
\end{tabular}
where instead of \\
one has to write \cr
, but all rows are printed on top of each other. It is customary to use \hidewidth
instead of \hfil
to get an entry centered with respect to the widest one and actually it has its benefits.
Let's see an example from plain.tex
(the LaTeX definition is similar, and this one is simplified): we want to put a cedilla after some non standard character.
\def\c#1{{\ooalign{#1\cr\hidewidth\char24\hidewidth\cr}}}
Here \char24
is the cedilla in the usual Knuth font encoding; it's a character that sits just below the baseline, so for characters that don't have descenders, we can print the character (#1
) and superimpose to it the cedilla (it will go under it, of course). With \hidewidth\char24\hidewidth
we pretend that the cedilla takes up no horizontal space, so the resulting block will be the same width as the character; we don't even need to know how wide is \char24
.
If we want to build a "supinf" symbol, superimposing \land
and \lor
, we can define
\newcommand{\supinf}{\mathbin{\ooalign{$\lor$\cr$\land$\cr}}}
Here \mathbin
says that this command must be used in math mode and the symbol is considered as an operation symbol.
The command \hidewidth
just adds a large negative space (it's \hskip -1000pt plus 1fill
compensating it with infinite stretchability. A table cell where \hidewidth
is present will never be the largest one.
Caution
Always enclose {\ooalign{...}}
in a group as shown here and in the definition of \c
, otherwise nasty surprises can spoil your masterpiece of typography. In our cases, the braces in \mathbin{...}
and \mathrel{...}
act as group delimiters.
Here's how you can get size changing according to the math style:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand\opn{\mathrel{\opncls@{\circ}}}
\newcommand\cls{\mathrel{\opncls@{\bullet}}}
\newcommand{\opncls@}[1]{%
\vphantom{\subseteq}% to fix the bounding box
\mathpalette\opncls@@{#1}%
}
\newcommand{\opncls@@}[2]{%
\ooalign{$\m@th#1\subseteq$\cr
\hidewidth\opncls@fix{#1}\hbox{$\m@th#1#2\mkern.5mu$}\cr}}
\newcommand\opncls@fix[1]{%
\ifx#1\displaystyle
\raise.225ex
\else
\ifx#1\textstyle
\raise.225ex
\else
\ifx#1\scriptstyle
\raise.180ex
\else
\raise.150ex
\fi
\fi
\fi
}
\makeatother
\begin{document}
$
\mathcal{F}_x:=
\frac{\bigsqcup\{\mathcal{F}(U);\, x\in U \opn X\}}
{\exists x\in W \opn U\cap U'\!:s|_W=s'|_W}
$
\bigskip
$\displaystyle\opn\cls
\quad
\textstyle\opn\cls
\quad
\scriptstyle\opn\cls
\quad
\scriptscriptstyle\opn\cls$
\end{document}
(I've simplified your formula just to show the effect of the new symbol; however, such a big formula should always be typeset in display style and with \dfrac
.)
A couple of further notes. I used \m@th
in order to avoid problems if the document class sets a nonzero value for \mathsurround
(but it's rare that it's set otherwise).
The \vphantom{\subseteq}
is needed because \ooalign
sets the bounding box using the first row for the height and the last row for the depth.
\!
for something like this; see this answer of mine for details.