[Tex/LaTex] How to set the document font

fonts

Getting a package is not the same as executing an instruction to tell TeX to use a specific font or fontsize or typestyle (like italics or boldface), right?

So I have this:

\documentclass[letterpaper]{article}

%% Language and font encodings
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins
\usepackage[letterpaper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

%% Useful packages
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}

\title{Your Paper}
\author{You}

\begin{document}
\maketitle

\end{document}

and I get this ostensibly vanilla-flavored font with serifs.

ostensibly vanilla-flavored font with serifs

Suppose one wants a sans-serif font like Helvetica or a plain mono-spaced font like we have in the edit boxes here at SE (or one like Courier)? Or a standard serif font like Times Roman?

Where do I get the different font packages and how do I tell TeX what the default document font is and how to switch from one font to another, to another font size, and to a different font style? FYI, I am using TeXworks with MiKTeX on a Windoze 10 PC.

I tried searching for another question like this and couldn't find it or, if I did, I couldn't decode it to even guess I had an answer.

Best Answer

Your question asks about four broad areas:

  1. customising the font configuration for text;

  2. customising the font configuration for maths;

  3. how to switch between sans, serif, typewriter and special fonts, and how to change font size in text;

  4. how to switch between sans, serif, typewriter and special fonts, and how to change font size in maths.

The answer to 1 and 2 is that you load a suitable package or packages using

\usepackage[]{}

The LaTeX Font Catalogue can help with this, as Bernard suggested in comments. I also provide some resources which might be helpful. See What font packages are installed in TeX live? for a list of packages and this font sampler.

The answer to 3 and 4 is that, generally, you shouldn't. This is because something like 'switch to italic bold' is appearance mark-up rather than logical or semantic mark-up. Generally, such changes should be handled by the class and packages you load so that, say

\section{A section}

typesets A section in a suitable font. Similarly,

\emph{I really mean this.}

should be used where emphasis is needed because it is logical/semantic rather than appearance.

Occasionally, you may want something special for a one-off effect. A typical use would be in typesetting a title page. Then you might actually want to hard-code the appearance.

\textbf{Bold} or {\bfseries bold}
\textit{Italic} or {\itshape italics}
\textsc{Small-caps} or {\scshape small-caps}
\textsf{Sans} or {\sffamily sans}
\textrm{Serif} or {\rmfamily serif}
\texttt{Typewriter} or {\ttfamily typewriter}

{\tiny tiny\par
\scriptsize script\par
\footnotesize footnote\par
\small small\par
\normalsize normal\par
\large large\par\Large larger\par
\LARGE larger\par
\huge larger\par
\Huge largest\par}

font changes: family, shape, series and size

Generally, sizing etc. is automatic in maths mode. Where necessary, you can use

\mathit{Italics}
\mathsf{Sans}

and so on, but these should not usually be necessary.

For further information, see What are good learning resources for a LaTeX beginner?.