Take the 2-minute tour ×
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 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.

enter image description here

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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

\begin{equation}
E=mc^2
\end{equation}
\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,
\begin{equation}
E=mc^2
\end{equation}
\end{document}

enter image description here

share|improve this answer
    
\unsansmath was a nice command that I should remember. –  A2009 Aug 14 at 5:54

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.