# Using a math font matching San Serif Font

How can I match the font of an equation to a Sans Serif font? I am using the following code.

\documentclass{article}

\usepackage[scaled, mono=false]{libertine}
\renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be sans serif
\usepackage[T1]{fontenc}

\begin{document}
\section*{Sans Serif Font along with equation and formula}

\noindent How can I put my equation between dollar signs, e.g., \verb|$E=mc^2$|, and get an output which matches a Sans Serif font?

\noindent Here is the result of \verb|$E=mc^2$|: $E=mc^2$

\end{document}


Here is the output.

-
well, not all fonts have a math support. I think that Euler matches Libertine reasonably: add \usepackage{eulervm} into your preamble and see whether you like it or not. – yo' Aug 13 '14 at 6:53
Is it just me who reads the title as my kingdom for a horse? Free association is weird. – percusse Aug 13 '14 at 9:53

Use the sansmath package.

The package is designed to offer sans-serif mathematics in the absence of proper sans maths fonts.

The package’s name could be misconstrued: there was an ambition to do the job for “non-standard” sans fonts (as indicated by the value of \sfdefault), but the only good results have been with Computer Modern and cmss.

To use the package, add \usepackage{sansmath} to your preamble, and then use the \sansmath command in any maths environment when you want to switch to a sans-serif font.

If you want this applied to every maths environment in your document, you can use \sansmath in your document preamble.

-
It did not work for me. I get the same result, no change. – Ahmad Aug 13 '14 at 6:40
However, that's a poor man's solution... – yo' Aug 13 '14 at 6:52
@tohecz: I liked the look of the sansmath's result more than \usepackage{eulervm} after I got sansmath to work by using \sansmath{$E=mc^2$} but you know sansmath is kind of inconvenient as I have to put in in front of all the equations. The solution you suggested is very convenient but the look is different. – Ahmad Aug 13 '14 at 7:23
@A2009 I've edited my answer to show you how to avoid having to put \sansmath in front of every equation. – ChrisS Aug 13 '14 at 9:18
@A2009 Answer updated so that it actually works. – ChrisS Aug 15 '14 at 1:56