Problem in using \everymath{\sansmath}

I would like to use \everymath{\sansmath} and change the typeset of all the equations in my document as a replacement for using \sansmath{$equation$}. However, I am not what I am missing that declaring \everymath{\sansmath} does not cause anything to change.

Here is a MWE.

\documentclass{article}
\usepackage{sansmath}

\begin{document}

\everymath{\sansmath}

\verb|\everymath{\sansmath}| gives $E=mc^2$

\verb|\sansmath{$E=mc^2$}  | gives \sansmath{$E=mc^2$}

\end{document}


The result is illustrated below.

-

To make every math in sans, just issue \sansmath at the beginning of the document.

\documentclass{article}
\usepackage{sansmath}
\sansmath               %% <<--- this
\begin{document}

\verb|\everymath{\sansmath}| gives $E=mc^2$

\verb|\sansmath{$E=mc^2$}  | gives \sansmath{$E=mc^2$}

$$E=mc^2$$
\end{document}


If you want to limit the sans to certain part, you may either put the command inside a group, or use the environment form \begin{sansmath}....\end{sansmath}.

\documentclass{article}
\usepackage{sansmath}
\sansmath
\begin{document}

\verb|\sansmath| gives $E=mc^2$

\unsansmath
\verb|\unsansmath| gives $E=mc^2$

{
\sansmath
With grouping, gives $E=mc^2$
}
After group we get $E=mc^2$

Within environment \verb|sansmath| gives

\begin{sansmath}
$E=mc^2$
\end{sansmath}

\sansmath
Again,
$$E=mc^2$$
\end{document}


-
\unsansmath was a nice command that I should remember. – Ahmad Aug 14 '14 at 5:54