Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to create symbols \opn for "open subset" and \cls "closed subset". I want them to look like this:

enter image description here

enter image description here

My current solution is:

\def\opn{\!\ensuremath{\subseteq\!\!\!\!\!\raisebox{1pt}{$\circ$}}\,} 
\def\cls{\!\ensuremath{\subseteq\!\!\!\!\!\raisebox{1pt}{$\bullet$}}\,}

But the problem is when I use this, Latex doesn't treat \subseteq and \circ as a single symbol, so the spacing is incorrect when for example I write $U~\!\!\!\opn\!\!\!~X$:

enter image description here

How can I make the position of the circle be fixed in the middle, so that \opn becomes a single symbol that is resizable, i.e. responds well to \huge?

Edit: @egreg @MartinScharrer: When using your command (to define the stalk of a sheaf)

\mathcal{F}_x:=\frac{\bigsqcup\{\mathcal{F}(U);\, x\in U \opn X\}}{s\sim s' 
\,\Longleftrightarrow\, s\in\mathcal{F}(U)\text{ and }s'\in\mathcal{F}(U')\text{ and }
\exists x\in W \opn U\cap U'\!:s|_W=s'|_W}

I get ugly results, namely (egreg's solution) enter image description here
and (Martin Scharrer's solution) enter image description here.

Currently, I like this edited Martin's solution the most aesthetically appealing:

\def\opn{ \ensuremath{\mathrel{\subseteq \!\!\!\!\!\raisebox{1.63pt}{$\scriptstyle\circ$}}}}    %odprta podmnozica
\def\opnn{\ensuremath{\mathrel{\subsetneq\!\!\!\!\!\raisebox{1.63pt}{$\scriptstyle\circ$}}}}    %prava odprta podmnozica
\def\cls{ \ensuremath{\mathrel{\subseteq \!\!\!\!\!\raisebox{1.63pt}{$\scriptstyle\bullet$}}}}  %zaprta podmnozica
\def\clsn{\ensuremath{\mathrel{\subsetneq\!\!\!\!\!\raisebox{1.63pt}{$\scriptstyle\bullet$}}}}  %prava zaprta podmnozica

but there is still a problem in the above code. Could anyone edit this last code to fix the problem with spacing?

share|improve this question
1  
One should never use negative spacing like \! for something like this; see this answer of mine for details. – Hendrik Vogt Jun 15 '12 at 17:31

3 Answers

up vote 39 down vote accepted

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$

enter image description here

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}

\newcommand\opn{\mathrel{\mathpalette\opncls\circ}}
\newcommand\cls{\mathrel{\mathpalette\opncls\bullet}}
\newcommand{\opncls}[2]{%
  \ooalign{$#1\subseteq$\cr
  \hidewidth\raisefix{#1}\hbox{$#1#2\mkern.5mu$}\cr}}

\def\raisefix#1{%
  \ifx#1\displaystyle
    \raise.225ex
  \else
    \ifx#1\textstyle
      \raise.225ex
    \else
      \ifx#1\scriptstyle
        \raise.180ex
      \else
        \raise.150ex
      \fi
    \fi
  \fi
}


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

enter image description here

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

share|improve this answer
Great answer, as always. The \ooalign is very interesting. – Martin Scharrer Jul 5 '11 at 12:53
Thank you very much. I'm don't really understand what your code actually does, but I'll study it when the need to construct another sign comes. In the meantime, I'll be happily using this one. Again, thank you very much :). – Leon Lampret Jul 5 '11 at 12:57
1  
@Leon: It's similar to a tabular (which uses \halign internally), but the alignment is different (overlayed instead table structure). The \cr stands for the line end, i.e. like \\. But egreg can it of course explain better. – Martin Scharrer Jul 5 '11 at 13:11
1  
I've added some words about \ooalign. – egreg Jul 5 '11 at 13:33
There is a problem (see edit). Would you be willing to fix it? – Leon Lampret Mar 22 at 5:39
show 3 more comments

Obligatory Unicode answer: With XeLaTeX or LuaLaTeX with the unicode-math package, you can use (i.e. U+27C3 OPEN SUBSET) directly (or use the alias \subsetcirc). There is also (U+2ABD SUBSET WITH DOT; \subsetdot) and (U+2ACF CLOSED SUBSET; \csub). Unicode doesn't seem to contain a subset symbol with a bullet inside.

share|improve this answer

You need to place your symbol inside \mathrel{..} so it is taken as a relation symbol. To support different size you should define \raisebox using the ex unit instead.

\def\opn{\ensuremath{\mathrel{\subseteq\!\!\!\!\!\raisebox{1pt}{$\circ$}}}} 
\def\cls{\ensuremath{\mathrel{\subseteq\!\!\!\!\!\raisebox{1pt}{$\bullet$}}}}

See also the similar question Overlay symbol with another.

share|improve this answer
Thank you also, it's good to have different solutions of varying complexity, so it's easier to understand. – Leon Lampret Jul 5 '11 at 12:59
There is a problem (see edit). Would you be willing to fix it? – Leon Lampret Mar 22 at 5:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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