Vladar's Blog

LaTeX and its fancy fonts

An introduction to text formatting in LaTeX.

Contents


Attributes

Basic font attributes in LaTeX are family, series, shape, and size. There is also encoding, but for our purposes, T1 (\usepackage[T1]{fontenc}) will suffice.

Family

\command{text} {\command text} Family
\textrm \rmfamily Roman (serif)
\textsf \sffamily Sans serif
\texttt \ttfamily Typewriter

Series

\command{text} {\command text} Series
\textmd \mdseries Medium
\textbf \bfseries Bold

Shape

\command{text} {\command text} Shape
\textit \itshape Italic
\textsl \slshape Slanted
\textsc \scshape Small caps
\emph \em Emphasized
\textulc \ulcshape Change small caps to upper/lower case
\textup \upshape Change italic, slanted, or emphasized to upright
\textnormal \normalshape Reset shape to normal

Use \normalfont command to reset it all back to default.

Size

Keep in mind that this list of commands is not comprehensive. For more information, check out the full documentation of LaTeX font commands.1


Underline

The basic way to underline the text is to use \underline command. For more options, including various like shapes, strike-out, crossed-out, and more, check out the ulem package.2


Superscript and subscript

\textsuperscript and \textsubscript command will transform the text to superscript and subscript accordingly.


Verbatim

To display large blocks of verbatim text, use verbatim environment:

\begin{verbatim}
  Large block of
  verbatim text.
\end{verbatim}

For the short snippets, use \verb:

\verb!verbatim text!

Starred versions (verbatim* and \verb*) replace spaces with "open box" character .


Justification

\declaration \begin{environment} Justification
\justifying justify Fully justified
\centering center Centered
\raggedright flushleft Left-justified
\raggedleft flushright Right-justified

Special characters

For more special characters, including accented letters, ligatures, and punctuation, see Chapter 2: "Body-text symbols" of "The Comprehensive LaTeX Symbol List".3


Breaks

Line breaks

The simplest way to start a new line in LaTeX is to leave an empty line between two blocks of text. Some other useful commands are listed below:

Page breaks


Different fonts

The LaTeX Font Catalogue4 contains the list of all free fonts available for LaTeX, including instructions on how to use them.

For example, let's say we want to change our main font to a fancier one — IM Fell English.5

\usepackage{imfellEnglish}
\usepackage[T1]{fontenc}

Usage of your own fonts is also possible through the fontspec6 package, but requires you to use XeTeX or LuaTeX compiler.

\usepackage{fontspec}
\setmainfont{YourFontHere}

Symbol fonts

If you need a rare special symbol, a glyph, or a dingbat, you most probably will find it in "The Comprehensive LATEX Symbol List".7

Another useful package in that regard, is fontawesome5,8 that provides Font Awesome9 implementation in LaTeX.


Initials

AKA drop capitals — is a letter at the beginning that is larger than the rest of the text.10 The easiest way to do this is the lettrine11,12 package, and when combined with some fancy font from the catalogue, produces beautiful results.

example.sty

% Initials
\RequirePackage{lettrine}
\input Typocaps.fd
\newcommand*\initfamily{\usefont{U}{Typocaps}{xl}{n}}
\renewcommand{\LettrineFontHook}{\initfamily}

Basic usage of this:

lettrine[<options>]{<letter>}{<text>}

<letter> is a drop cap, 2 lines high by default, and <text> is the rest of the first word in small caps.

And here's how it will look in the document:

example_sub1.tex

\lettrine[lines=2]{H}{ere} is an example of a custom command
defined in \verb|example.sty| that formats a monster stat block:

latex-initials

There are a lot of options for this command, even to replace the initial with a custom image. Consult the package's documentation and experiment a bit.


There are more topics on text formatting and decoration, but we'll leave it for the next time.

Discuss this post on Reddit

  1. https://www.ctan.org/pkg/fntguide

  2. https://ctan.org/pkg/ulem

  3. https://www.ctan.org/pkg/comprehensive

  4. https://tug.org/FontCatalogue

  5. https://tug.org/FontCatalogue/imfellenglish/

  6. https://www.ctan.org/pkg/fontspec

  7. https://www.ctan.org/pkg/comprehensive

  8. https://ctan.org/pkg/fontawesome5

  9. https://fontawesome.com/

  10. https://en.wikipedia.org/wiki/Initial

  11. https://ctan.org/pkg/lettrine

  12. https://en.wikibooks.org/wiki/LaTeX/Initials

#fonts #gamedev #guide #latex #software #ttrpg