# Defining \subsetcong and \subsetsim via proper tilde over and under \subset

I'd like to define a new command \subsetcong that would typeset a tilde over \subseteq to make it look similar to how tilde is over = in \cong. And also, I'd like to define \subsetsim to mean a \subset with a like tilde under, similar to \subsetapprox.

I am aware of this post: Big tilde in math mode, but the answer does not satisfy me, it feels needlessly complex. 'Detexify' app, didn't help much either, but I found one more symbol, which illustrates what I want with \subsetsim: \lesssim, only instead of < I need \subset.

The idea is to use A \subsetcong B or A \subsetsim B (yet to be decided), to mean something along the lines "there exists sub-element of B isomorphic (in a context-dependent sense) to A".

Any suggestions?

Best regards.

Something like this?

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\subsetcong}{\mathrel{\mathpalette\subset@cong\relax}}
\newcommand{\subsetsim}{\mathrel{\mathpalette\subset@sim\relax}}

\newcommand{\subset@cong}[2]{%
\vbox{\offinterlineskip\m@th
\ialign{\hfil$#1##$\hfil\cr
\sim\cr\subset\cr
}%
}%
}
\newcommand{\subset@sim}[2]{%
\vtop{\offinterlineskip\m@th
\ialign{\hfil$#1##$\hfil\cr
\subset\cr\noalign{\kern1pt}\sim\cr
}%
}%
}
\makeatother

\begin{document}

$A\subsetcong B\subsetsim C$

$\scriptstyle A\subsetcong B\subsetsim C$

$\scriptscriptstyle A\subsetcong B\subsetsim C$

\end{document}


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

\makeatletter
\newcommand{\subsetcong}{\mathrel{\mathpalette\subset@cong\relax}}
\newcommand{\subsetsim}{\mathrel{\mathpalette\subset@sim\relax}}

\newcommand{\subset@cong}[2]{%
\vbox{\offinterlineskip\m@th
\ialign{\hfil##\cr
\scalebox{0.9}{$#1\sim$}\cr
\noalign{%
\ifx#1\displaystyle\kern-0.5pt\else
\ifx#1\textstyle\kern-0.5pt\fi\fi
}%
$#1\subset$\cr
}%
}%
}
\newcommand{\subset@sim}[2]{%
\vtop{\offinterlineskip\m@th
\ialign{\hfil##\cr
$#1\subset$\cr\noalign{\kern0.5pt}\scalebox{0.9}{$#1\sim$}\cr
}%
}%
}
\makeatother

\begin{document}

$A\subsetcong B\subsetsim C$

$\scriptstyle A\subsetcong B\subsetsim C$

$\scriptscriptstyle A\subsetcong B\subsetsim C$

\end{document}


• Precisely, beautiful answer @egreg, Thank You! Also, I just found \subsim and \supsim in stix package, which resolves \subsetsim as well. – Piotr Tarasov Feb 14 at 9:24
• One small thing though, I've been playing around with your code in attempt to do two things: 1) make \sim closer to \subset, particularly in case of \subsetcong (in case of \subsetsim it's a matter of setting \kern#pt); 2) make \sim vertically align on the left side with \subset, i.e. to scale \sim down a bit. Would appreciate if you could address these two when time permits. – Piotr Tarasov Feb 14 at 10:16
• @PiotrTarasov Added. – egreg Feb 14 at 10:42
• perfecto and arigato my friend! @egreg – Piotr Tarasov Feb 14 at 13:40