0

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?

7
  • Which OS do you run? Windows? MacOS? Something else? The reason I ask is that different OSes use different names for some key fonts.
    – Mico
    Commented Jul 27, 2022 at 11:21
  • do you have Helvetica font? Commented 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.
    – daleif
    Commented Jul 27, 2022 at 11:21
  • I'm using Windows 10.
    – itc
    Commented Jul 27, 2022 at 11:30
  • 2
    you 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). Commented Jul 27, 2022 at 11:32

1 Answer 1

2

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.

b

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}

e

2
  • 1
    sorry 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?
    – itc
    Commented Jul 28, 2022 at 11:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .