Fonts & Character SetsBest Practice for using Fonts

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
Ryan Henderson
Posts: 5
Joined: Sun Sep 09, 2012 4:25 pm

Best Practice for using Fonts

Post by Ryan Henderson »

I am new to LaTeX, so please forgive any errors on my part.

My question deals with the coding of fonts in a document. The example below demonstrates the way that I am using fonts:

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[light,math]{iwona}

\begin{document}
Lorem ipsum dolor sit amet, consectitur adipiscing elit.

\renewcommand*\rmdefault{ppl}\normalfont\upshape
Lorem ipsum dolor sit amet, consectitur adipiscing elit.

\renewcommand*rmdefault{iwona}\normalfont\upshape
Lorem ipsum dolor sit amet, consectitur adipiscing elit.

\end{document}
Is this the best way to use fonts in a document, or is there a better, more efficient method? Can I declare fonts in the preamble, or just at the points of their use in the document?

I'm using Kopka and Daly's »Guide to LaTeX« in my learning, but their section on font encoding is a bit obtuse for my liking.

I thank you all in advance for your help.

Ryan
Last edited by localghost on Mon Sep 10, 2012 8:58 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Best Practice for using Fonts

Post by localghost »

The method from your example is the way to go when using PDFTeX. This compiler is able to use Postscript Type 1 fonts like Iwona.

A better access to fonts is given by the XeTeX typesetting engine. It can use fonts (OpenType and TrueType) that are installed on the operating system. Documents have to be migrated because other things like the document language are determined differently. But with the ifxetex package documents can be prepared for both PDFTeX and XeTeX. With LuaTeX there is a quite new engine similar to XeTeX.


Best regards and welcome to the board
Thorsten
Ryan Henderson
Posts: 5
Joined: Sun Sep 09, 2012 4:25 pm

Re: Best Practice for using Fonts

Post by Ryan Henderson »

First off, thanks to Torsten for the answer.

I have a couple of follow up questions.

1. How would I go about declaring a font for an entire document, and

2. what if I wanted to use non-Latin fonts in a multilingual document?

Again, I appreciate the assistance.

Ryan
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Best Practice for using Fonts

Post by Stefan Kottwitz »

Hi Ryan,

welcome to the board!
Ryan Henderson wrote:Can I declare fonts in the preamble, or just at the points of their use in the document?
Declare used fonts and settings in the preamble. Within the document body, use only switches to change from one predefined font to another one. Even better: define logical styles, so you don't have to specify fonts within the text. This makes it much easier to change the font later.

Good documents usually don't have a big mix of fonts. Often there's a serif (roman) font for the body text, a sans serif font (for example for headings), an italic font shape (for emphasizing), a typewriter font (for code snippets), and more - but rarely several roman fonts or different sans serif fonts. So, in many cases one defines the specific font just by loading the font package in the preamble, while in the document the style is just switched.

To explain what I mean with logical styles, an example: it's much better to define a keyword style, such as by

Code: Select all

\newcommand*{\keyword}[1]{\textbf{\texttt{#1}}}
and later use \keyword{code} instead of frequently using \textbf{\texttt{code}} in the document. It's much easier to change the style later on in the preamble, instead of replacing every instance in the text. You could even extend the macro later, if you like, such as

Code: Select all

\newcommand{\keyword}[1]{\textbf{\texttt{#1}}\index{#1}}
for an automatically generated index.

So, avoid using such \renewcommand* lines in the document body.

Stefan
LaTeX.org admin
Ryan Henderson
Posts: 5
Joined: Sun Sep 09, 2012 4:25 pm

Re: Best Practice for using Fonts

Post by Ryan Henderson »

Thank you for your post, Stefan. You gave some wonderful information. I truly appreciate it.

I am wondering if some of these font packages contain more than one useable font. When I open my package manager and take a look at a fonts package (palatino, for example), I see several files contained within the package. How can I know which of these files is a useable font and how can I declare that font in the document?

Again, thank you all for bearing with me. I hope I'm not bringing back nightmares from your "newbie" days!

Ryan
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Best Practice for using Fonts

Post by localghost »

Ryan Henderson wrote:[…] I am wondering if some of these font packages contain more than one useable font. When I open my package manager and take a look at a fonts package (palatino, for example), I see several files contained within the package. How can I know which of these files is a useable font and how can I declare that font in the document? […]
The different files in the package are for different families, series and shapes of the same font. Stefan already mentioned that. The names of the files follow the Karl Berry scheme, which is described in the document »Fontname – Filenames for TeX fonts«. One package provides access to only one font at a time. But there are font packages that only affect one specific family. Some examples:
  • mathptmx determines the roman font family (Times New Roman, actually Nimbus Roman No9 L)
  • helvet affects the sans serif font family (Helvetica)
  • inconsolata provides access to typewriter (mono spaced) font family (Inconsolata)
Font packages like lmodern affect families, series and shapes of one single font (Latin Modern here). Fonts for PDFLaTeX are listed in »The LaTeX Font Catalogue«.
Post Reply