官术网_书友最值得收藏!

Introduction

When LaTeX was young, documents looked quite similar, since there was a precious little choice of fonts. Over time, many new fonts were invented and gained support from LaTeX.

To find the perfect fonts for your documents, visit the LaTeX font catalogue at http://www.tug.dk/FontCatalogue/.

In this chapter, we will see how to choose fonts globally and how to adjust them within the document.

Before we take off, let's take a quick look at basic LaTeX commands for switching between fonts. We keep it very short, as introductory texts usually cover it. Experienced LaTeX users may skip this section.

Basic font commands

Fonts for text have five main attributes:

  • Encoding: We covered this in the previous chapter and concluded that T1 encoding is usually a good choice for common Latin text, which can be activated by the following command:
    \usepackage[T1]{fontenc}
  • Family: This is what we we call sets of fonts of the same origin and the same type. You can switch to a font family using one of these commands:
    • \rmfamily: This is the default that switches to Roman font, which means text with serifs.
    • \sffamily: This switches to sans serif font.
    • \ttfamily: This is for typewriter font.
  • Series: This denotes how heavy a font is. Following are the commands:
    • \bfseries: This is for bold font.
    • \mdseries: This is for medium font, which is the default.
  • Shape: This attribute relates to the shape of the text; a font family can have several shapes:
    • \upshape: This switches to upright text, which is the default
    • \itshape: This switches to italics.
    • \slshape: This gives slanted text.
    • \scshape: This is for small capitals.
  • Size: The base size is specified as an option to the document class, as we did earlier. We can choose a different size:
    • We get a larger text size in the increasing order using \large, \Large, \LARGE, \huge, and \Huge.
    • We get lower text size using \small, \footnotesize, \scriptsize, and \tiny.
    • We can switch back to the normal size using \normalfont.

The effect of these commands is limited by environments. You can also limit the effect by curly braces, for example, {\bfseries ... }.

There's another more consistent syntax for modifying short pieces of text. For example. the following commands choose a font family for a piece of text:

  • \textrm{...} switches the argument to Roman text, \textsf{...} switches it to sans-serif, and \texttt{...} switches the argument to typewriter text.

Similarly, the following applies to the series and shape:

  • \textbf{...} makes the argument bold, \textmd{...} makes it medium.
  • \textit{...} applies Italics, \textsl{...} gives slanted text, \textsc{...} switches the argument to small capitals, and \textup{...} is for upright font.

That's easier to remember. There's no such command for font size. It's unusual anyway to manually change the font size within surrounding text. Just think of calculating the interline distance for the paragraph.

There's more...

Classes and packages use these font commands to define consistent styles. As the author, we state elements such as section headings, footnotes, subscripts, and emphasized snippets; while LaTeX chooses the corresponding size, shape, and series.

What if you would like to use those commands yourself? It's a very good practice to use such font commands only in the preamble, in macro definitions, not in the document's body text. For example, instead of scattering the \textbf{...} commands all over the text for bold author names, you should define an author name style using:

\newcommand{\authorname}[1]{\textbf{#1}}

This allows to implement easy and consistent changes at a single place—the preamble, for example, when you would decide to use small caps or Italics instead.

A macro for each required formatting brings logic into the text. And you can modify all occurrences at the same time by changing the macro.

主站蜘蛛池模板: 綦江县| 武宣县| 赤水市| 新竹市| 土默特右旗| 丹巴县| 宁乡县| 招远市| 青海省| 达州市| 射阳县| 永胜县| 舒兰市| 长垣县| 临安市| 巨鹿县| 江川县| 清河县| 毕节市| 射阳县| 洛川县| 巫山县| 延边| 卫辉市| 息烽县| 宁化县| 安图县| 通化县| 巴林左旗| 赤峰市| 禄丰县| 清徐县| 奉化市| 平南县| 镇江市| 华安县| 肇州县| 中西区| 富民县| 道真| 西宁市|