LaTeX/Fonts
In order to select a font other than the default typeface in Latex environment, it is necessary to include some commands in the preamble of the document.
For example:
\usepackage[T1]{fontenc} \usepackage[light,math]{iwona}
Important: note that this only works for fonts that are already prepared for use with LaTeX. If what you have is a ttf font or similar, you will have to convert it and make it available to LaTeX. See the external links section below for some useful resources.
Contents |
[edit] Example
Below is an example found at the Google discussion group latexlovers. The example demonstrates how to select different fonts in a simple document.
\documentclass{book} \begin{document} % using default font (\familydefault = \rmdefault = Computer Modern Roman) Lorem ipsum dolor sit amet, consectitur adipiscing elit. \renewcommand*\rmdefault{ppl}\normalfont\upshape Lorem ipsum dolor sit amet, consectitur adipiscing elit. % using Palatino font \renewcommand*\rmdefault{iwona}\normalfont\upshape Lorem ipsum dolor sit amet, consectitur adipiscing elit. % using Iwona font \end{document}
[edit] XeTeX
If you use the XeTeX or LuaTeX engine and the fontspec package, you'll be able to use any font installed in the system effortlessly. XeTeX also allows using OpenType technology of modern fonts like specifying alternate glyphs and optical size variants. XeTeX also uses Unicode by default, which might be helpful for font issues.
To use the fonts, simply load the fontspec package and set the font:
\documentclass{article} \usepackage{fontspec} \setmainfont{Arial} \begin{document} Lorem ipsum... \end{document}
Then compile the document with XeLateX or LuaLaTeX. Note that you can only generate .pdf files, and that you need a sufficiently new TeX distribution (TeX Live 2009 should work for XeTeX and Tex Live 2010 for LuaTeX). Also you should NOT load the inputenc or fontenc package. To make support both pdflatex and XeTeX you can use the \ifxetex macro from the ifxetex package.
\documentclass{article} \usepackage{ifxetex} \ifxetex \usepackage{fontspec} \usepackage{xunicode} \defaultfontfeatures{Mapping=tex-text} % To support LaTeX quoting style \setromanfont{Hoefler Text} \else \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \fi \begin{document} Lorem ipsum... \end{document}
[edit] Useful websites
- The Latex Font Catalogue
- LaTeX font commands
- How to change fonts in Latex
- Understanding the world of TEX fonts and mastering the basics of fontinst
- Font installation the shallow way "For one-off projects, you can cut corners with font installation (i.e. fontinst) and end up with a more manageable set of files and a cleaner TEX installation. This article shows how and why"
[edit] TrueType (ttf) fonts
- Step-by-step guide to manually install a ttf-font for PdfTeX
- A bash script for installing a LaTeX font family (MikTeX / TeXLive)
- LaTeX And TrueType Font
- True Type Fonts with LaTeX under Linux + MiKTeX 2.5
- Unicode Truetype font installer for LaTeX under Windows + MikTeX
- Using TrueType fonts with TeX (LaTeX) and pdfTeX (pdfLaTeX) (for MikTeX)