Change LaTeX math font to sans serif​

In this LaTeX tutorial, I will show you how to change the math font to sans serif. Whether you want to change the font for a specific math equation or for all the equations in the document, I will demonstrate both examples.

Method 1: Using \mathsf in math mode (For specific equation)

In the below example, we are using \mathsf to change the math font into sans serif:

\documentclass{article}
\begin{document}

This is regular math: \( E = mc^2 \).

And this one is the same in sans-serif math: \( \mathsf{E = mc^2} \).


\end{document}

Emc2 in sans serif

Method 2: Using sansmath package (Effect globally)

If you want to change the math font to sans serif globally in your LaTeX document then you can use the sansmath package. It will change the font for all the formulas in the document. Below is how to do it:

\documentclass{article}
\usepackage{sansmath}

\begin{document}

% Switch to sans-serif math
\sansmath
Here is the math formula in sans-serif: \( E = mc^2 \).

% Switch back to default math font using unsansmath
\unsansmath
Here is the math in regular font: \( E = mc^2 \).


\end{document}

Emc2sansserif

Method 3: Using \usepackage{sfmath} for global sans-serif math

Another way of changing the math font into sans serif globally is by using the \usepackage{sfmath} package. This one simplifies the process as shown in the example below:

\documentclass{article}
\usepackage{sfmath}

\begin{document}

Here is the math formula in sans-serif: \( E = mc^2 \).

\end{document}

As you can see, in this method you don’t need any additional command.

Leave a Reply

Your email address will not be published. Required fields are marked *