How do I set the Helvetica font when using the fontspec package?
I have tried using \setmainfont{Helvetica}
by its not working. How do I set this font?
-
Which OS do you run? Windows? MacOS? Something else? The reason I ask is that different OSes use different names for some key fonts.– MicoCommented Jul 27, 2022 at 11:21
-
do you have Helvetica font?– David CarlisleCommented Jul 27, 2022 at 11:21
-
First of do you have Helvetica on your system? Secondly it is very useful for debugginh fontspec if we know which latex engine is used (I'm guessing xelatex or lualatex) plus which OS you are on.– daleifCommented Jul 27, 2022 at 11:21
-
I'm using Windows 10.– itcCommented Jul 27, 2022 at 11:30
-
2you would need to buy helvetica, or use \setmainfont{TeX Gyre Heros} (a clone) or \setmainfont{Arial} (different but not many people would see the differences).– Ulrike FischerCommented Jul 27, 2022 at 11:32
|
Show 2 more comments
1 Answer
First try this code in your system. (pdflatex)
% !TeX TS-program = pdflatex
\documentclass[12pt,a4paper]{article}
\usepackage{helvet} % helvetica font
\begin{document}
Aliquam arcu turpis, ultrices sed luctus ac, vehicula id metus. Morbi eu feugiat velit, et tempus augue. Proin ac mattis tortor. Donec tincidunt, ante rhoncus luctus semper, arcu lorem lobortis justo, nec convallis ante quam quis lectus. Aenean tincidunt sodales massa, et hendrerit tellus mattis ac. Sed non pretium nibh. Donec cursus maximus luctus. Vivamus lobortis eros et massa porta porttitor.
\bigskip
{\fontencoding{T1}\fontfamily{phv}\fontsize{12}{15}\selectfont % helvetica font <<<<<<<<<<<<<<<<
Aliquam arcu turpis, ultrices sed luctus ac, vehicula id metus. Morbi eu feugiat velit, et tempus augue. Proin ac mattis tortor. Donec tincidunt, ante rhoncus luctus semper, arcu lorem lobortis justo, nec convallis ante quam quis lectus. Aenean tincidunt sodales massa, et hendrerit tellus mattis ac. Sed non pretium nibh. Donec cursus maximus luctus. Vivamus lobortis eros et massa porta porttitor.}
\bigskip
{\sffamily Aliquam arcu turpis, ultrices sed luctus ac, vehicula id metus. Morbi eu feugiat velit, et tempus augue. Proin ac mattis tortor. Donec tincidunt, ante rhoncus luctus semper, arcu lorem lobortis justo, nec convallis ante quam quis lectus. Aenean tincidunt sodales massa, et hendrerit tellus mattis ac. Sed non pretium nibh. Donec cursus maximus luctus. Vivamus lobortis eros et massa porta porttitor.}
\end{document}
The package helvet
makes the font helvetica as the sans serif default.
Now run this code (lualatex)
% !TeX TS-program = lualatex
\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
\begin{document}
Aliquam arcu turpis, ultrices sed luctus ac, vehicula id metus. Morbi eu feugiat velit, et tempus augue. Proin ac mattis tortor. Donec tincidunt, ante rhoncus luctus semper, arcu lorem lobortis justo, nec convallis ante quam quis lectus. Aenean tincidunt sodales massa, et hendrerit tellus mattis ac. Sed non pretium nibh. Donec cursus maximus luctus. Vivamus lobortis eros et massa porta porttitor.
\bigskip
{\fontencoding{T1}\fontfamily{phv}\fontsize{12}{15}\selectfont % helvetica font <<<<<<<<<<<<<<<<
Aliquam arcu turpis, ultrices sed luctus ac, vehicula id metus. Morbi eu feugiat velit, et tempus augue. Proin ac mattis tortor. Donec tincidunt, ante rhoncus luctus semper, arcu lorem lobortis justo, nec convallis ante quam quis lectus. Aenean tincidunt sodales massa, et hendrerit tellus mattis ac. Sed non pretium nibh. Donec cursus maximus luctus. Vivamus lobortis eros et massa porta porttitor.}
\bigskip
{\sffamily Aliquam arcu turpis, ultrices sed luctus ac, vehicula id metus. Morbi eu feugiat velit, et tempus augue. Proin ac mattis tortor. Donec tincidunt, ante rhoncus luctus semper, arcu lorem lobortis justo, nec convallis ante quam quis lectus. Aenean tincidunt sodales massa, et hendrerit tellus mattis ac. Sed non pretium nibh. Donec cursus maximus luctus. Vivamus lobortis eros et massa porta porttitor.}
\end{document}
-
1sorry but you should not suggest to use a T1 encoded font with lualatex. Add the text Grüße to see the problem with this approach. Commented Jul 28, 2022 at 9:48
-
Thank you @Simon Dispa. I want the main font in my book to be helvetica, while for headings (title, chapter, section,...etc) is calibri using the fontspec package. Is there a way to automate this?– itcCommented Jul 28, 2022 at 11:28