Specify Typeface as Arial in LaTeX Using \setsansfont Command
Blog1 introduces a way to specify the typeface as Arial for a whole LaTeX document (don’t forget to change the compiler to XeLaTeX):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{lipsum}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\usepackage{fontspec}
\setmainfont{Arial}
\begin{document}
\lipsum[1-8]
\end{document}

which way relies on the fontspec package and its \setmainfont command:
1
2
\usepackage{fontspec}
\setmainfont{Arial}
which means setting main typeface of the document as Arial.
However, recently I found a problem about this method, that is, it will lead to the typeface of the text in equation environments changing to Arial as well (especially the \min font in the following example):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\usepackage{fontspec}
\setmainfont{Arial}
\begin{document}
\lipsum[1]
\begin{equation}
\begin{split}
\min\ & a^2+b^2\\
& a,\ b\ge0\ \text{This is constraints.}\\
\end{split}
\end{equation}
\lipsum[2]
\end{document}

Actually, this feature is reasonable, because we set the main typeface.
If we don’t want to influence equation environments, we can choose using:
1
\setsansfont{Arial}
to only change the sans-serif font as Arial, and then use \sffamily command in the main text (by the way, using this method, we also need to specify the compiler as XeLaTeX of course):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\usepackage{fontspec}
\setsansfont{Arial}
\begin{document}
\sffamily
\lipsum[1]
\begin{equation}
\begin{split}
\min\ & a^2+b^2\\
& a,\ b\ge0\ \text{This is constraints.}\\
\end{split}
\end{equation}
\lipsum[2]
\end{document}

At this time, we can see the font of “min” in the equation is still Time New Roman (although the text created by \text command is changed to Arial, like we used \setmainfont{Arial} above).
Or, we can put \sffamily in a {} to make it functional locally:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\usepackage{fontspec}
\setsansfont{Arial}
\begin{document}
{\sffamily \lipsum[1]}
\begin{equation}
\begin{split}
\min\ & a^2+b^2\\
& a,\ b\ge0\ \text{This is constraints.}\\
\end{split}
\end{equation}
\lipsum[2]
\end{document}

By the way, if we don’t specify sans-serif font as Arial, the default sans-serif font is Computer Modern Sans Serif (a font designed by Knuth)2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\begin{document}
{\sffamily \lipsum[1]}
\begin{equation}
\begin{split}
\min\ & a^2+b^2\\
& a,\ b\ge0\ \text{This is constraints.}\\
\end{split}
\end{equation}
\lipsum[2]
\end{document}

It seems, at least for me, not that common.
References