Specify Typeface as Arial for the Whole Document in LaTeX

Nov. 12, 2024

YouTube video1 provides a way to globally specify typeface as Arial in a LaTeX document, that is using \setmainfont commands provided by fontspec package2:

1
2
\usepackage{fontspec}
\setmainfont{Arial}

A complete example is like:

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}

png-1

But, it should be noted that fontspec package is for compilers XeLaTeX and LuaLaTeX2. For example, the following error occurred when I made the first compilation:

1
2
Fatal Package fontspec Error: The fontspec package requires either XeTeX or(fontspec) LuaTeX. \msg_fatal:nn {fontspec} {cannot-use-pdftex}
Emergency stop. \msg_fatal:nn {fontspec} {cannot-use-pdftex}

because I used pdfLaTeX. It works after I changing the compiler3: in Options > Configure TeXstudio > Build > Default Compiler from my previous setting txs:///pdflatex to txs:///xelatex.


References