Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change the document font in LaTeX?

Tags:

fonts

latex

How do you change the font for the whole document to sans-serif (or anything else)?

like image 472
nickf Avatar asked May 18 '09 12:05

nickf


People also ask

How do I change the font of an entire document in LaTeX?

Set the font size of the whole document by adding an option to the \documentclass command. (10pt, 11pt, and 12pt are available on most classes.) Extsizes package makes more sizes from 8pt to 20pt available for the whole document. Moresize package adds two more size commands: \HUGE and \ssmall.

How do you change the font and size in LaTeX?

If you want a different size for your document, you can use extsizes packages. The command used are \documentclass[10pt]{extarticle} and \documentclass[14pt]{extreport}. You can also style the text differently.

How do you change the font of a document overleaf?

To open the menu, click the menu button in the top-left-hand corner of the screen. From here, scroll down to find the 'Font Size' option to change the font size in the editor.

What is the default font for LaTeX document?

LaTeX's default font is Computer Modern, but the editor also supports a number of other font types.


2 Answers

I found the solution thanks to the link in Vincent's answer.

 \renewcommand{\familydefault}{\sfdefault} 

This changes the default font family to sans-serif.

like image 163
nickf Avatar answered Oct 21 '22 17:10

nickf


For a different approach, I would suggest using the XeTeX or LuaTex system. They allow you to access system fonts (TrueType, OpenType, etc) and set font features. In a typical LaTeX document, you just need to include this in your headers:

\usepackage{fontspec} \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} \setmainfont{Times} \setmonofont{Lucida Sans Typewriter} 

It's the fontspec package that allows for \setmainfont and \setmonofont. The ability to choose a multitude of font features is beyond my expertise, but I would suggest looking up some examples and seeing if this would suit your needs.

Just don't forget to replace your favorite latex compiler by the appropriate one (xelatex or lualatex).

like image 21
fideli Avatar answered Oct 21 '22 19:10

fideli