# Missing $inserted when using custom math symbol I defined a command: \newcommand{\lequiv}{\raisebox{-0.25 \height}{\overset{<}{\sim}}}  But whenever I try to use it (for instance, in gather, I get Missing$ inserted. Why?

• Because \raisebox switches to text mode. Just change to \newcommand{\lequiv}{\raisebox{-0.25 \height}{$\overset{<}{\sim}$}} – azetina Apr 11 '17 at 15:25
• although the question as stated is answered well, the symbol you are trying to get already exists as \lesssim with \usepackage{amssymb}. – barbara beeton Apr 11 '17 at 16:42

The \raisebox command is used to declare the vertical position of text; that is to lower or raise text. Note the text is processed in LR mode With this said,

\newcommand{\lequiv}{\raisebox{-0.25\height}{\overset{<}{\sim}}}


is incorrectly declared and gives an error because of math declarations that should be in math mode and which are in text mode.

A quick fix is to:

\newcommand{\lequiv}{\raisebox{-0.25\height}{$\overset{<}{\sim}$}}


azetina’s answer addresses the error you get and removes it. On the other hand, the output you get is rather poor.

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

\begin{document}

$A\lesssim B\le C\gtrsim D_{x\lesssim y}$

\end{document}


Here's a better definition than your \lequiv that could come handy in case you want something different from \sim.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\lequiv}{\lg@equiv{<}}
\newcommand{\gequiv}{\lg@equiv{>}}
\newcommand{\lg@equiv}[1]{\mathrel{\mathpalette\lg@@equiv{#1}}}

\newcommand{\lg@@equiv}[2]{%
\raisebox{.3\depth}{%
\vtop{\m@th\offinterlineskip
\ialign{##\cr$#1#2$\cr\noalign{\kern1pt}$#1{\sim}$\cr}%
}%
}%
}
\makeatother

\begin{document}

$A\lequiv B\le C\gequiv D_{x\lequiv y}$

\end{document}


A visual comparison with what you’d get with your definition.

On the other hand, amssymb provides \lesssim and \gtrsim:

• why not just use \lesssim from the amssymb package? – barbara beeton Apr 11 '17 at 16:43
• Should I delete my answer? You can amend yours to reflect the problem and give the improvement. – azetina Apr 11 '17 at 16:51
• @barbarabeeton Because I didn't remember about it! – egreg Apr 11 '17 at 16:55
• @azetina no, keep it and add about \lessim – egreg Apr 11 '17 at 16:56
• @azetina -- note that \lesssim has 3 esses: "less" + "sim". – barbara beeton Apr 11 '17 at 17:15