1

I am referring to these Font typefaces from Overleaf for reference.

So, my question is how to set the font type globally.

Example 1:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tgbonum}

\begin{document}
test sentence 1.

test sentence 2.

test sentence 3.
\end{document}

Here is my result, the font is all successfully set to TEX Gyre Bonum.

enter image description here

Example 2:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{helvet}

\begin{document}
test sentence 1.

test sentence 2.

test sentence 3.
\end{document}

Here is my result, unfortunately, the font is all set to the default font Computer Modern Roman.

enter image description here

To set all the font to helvet, I have to do something like this:

Example 3:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{helvet}

\begin{document}
{\fontfamily{phv}\selectfont test sentence 1.}

{\fontfamily{phv}\selectfont test sentence 2.}

{\fontfamily{phv}\selectfont test sentence 3.}
\end{document}

Here is my result, the font is all set to helvet.

enter image description here

So my question is, to be specific, when using \usepackage{tgbonum}, font will be set globally. However, when using \usepackage{helvet}, font is not changed at all. Why would it happen? How to set the font globally for helvet?

3
  • 1
    helvet changes the sans serif family. If you want to change the rmfamily to sans serif you can use \renewcommand\familydefault{\sfdefault}. Nov 7, 2023 at 10:15
  • 1
    The package helvet does not change the default text font family from roman. Try \renewcommand{\familydefault}{\sfdefault}.
    – Ingmar
    Nov 7, 2023 at 10:17
  • so my understanding is, currently, the default font family is \rmfamily but helvet belongs to the \sffamily. So if I want to use helvet globally, I need to change the default font family first. Is that correct? Nov 7, 2023 at 10:43

1 Answer 1

3

If you want phv as the default font, just issue the instruction

\renewcommand\familydefault\sfdefault

after running \usepackage{helvet}.

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{helvet}
\renewcommand\familydefault\sfdefault

\begin{document}
test sentence 1.

test sentence 2.

test sentence 3.
\end{document}
4
  • Thank you very much. So my understanding is, currently, the default font family is \rmfamily but helvet belongs to the \sffamily. So if I want to use helvet globally, I need to change the default font family first. Is that correct? Nov 7, 2023 at 10:43
  • 1
    @liaoming999 - That's (essentially) correct for most document classes: The default text font family is "serif" or "roman"; to make the sans-serif font the default font family, it's necessary to tell LaTeX about this, e.g., by issuing the instruction \renewcommand\familydefault\sfdefault.
    – Mico
    Nov 7, 2023 at 10:56
  • 1
    +1 I'd suggest tgheros. It's a basically a clone of helvet but with full T1 and TS1 support.
    – campa
    Nov 7, 2023 at 11:30
  • 1
    @campa - I agree. The set of glyphs provided by the helvet package is fairly minimal.
    – Mico
    Nov 7, 2023 at 14:21

You must log in to answer this question.

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