Idraluna Archives

Quick & Dirty Guide to Typesetting a TTRPG in LaTeX

I’ve been using LaTeX over the past several months to work on my D&D hack Archons & Armigers, write dungeon keys for my ongoing Worlds Without Number campaign, and generally maintain a set of pdf files for all my GM notes, setting gazetteers, etc. It’s great, but it’s a pain in the ass to learn.

This guide is not meant to be a comprehensive breakdown of everything LaTeX can do. For that, see this e-book, the overleaf documentation, and these superb guides by Vladar, author of Into The Dungeon: Revived.

LaTeX is old software, and for everything you could want to do, there are like five different methods. This guide is just me compiling my favorites, with a focus on just laying out in one place what one could use to typeset a half-decent adventure, hack, or supplement.

Basics

Why LaTeX?

The big question; for many using a layout editor like Scribus, InDesign, or Affinity probably makes more sense. Hell, it might make more sense for me. But:

How Do I Start Using LaTeX?

I’d start with Overleaf, a fully online editor with many nice QoL features. If you start getting deep into a big project, installing it locally is easy enough. I use TexLive + VSCode.

How Do I Git Gud?

Google problems and click on the stack exchange results. Read package manuals. Experiment.

Specific Code Suggestions

Again, these are just what I came up with to meet my formatting needs.

Project Setup

Easiest to ignore the Overleaf templates and just make a blank document. For a typical TTRPG project, one will want to mess with default LaTeX formatting quite a bit and write a custom package. So to start, I recommend creating:

Document Setup

Choosing a Document Class

As far as I understand, LaTeX is actually a ‘primitive’ typesetting software package called TeX plus a set of ‘higher-level’ default instructions that save you, the user, from having to manually define things like page numbering, making a table of contents, etc. It comes, by default, with several ‘document classes’ (such as book, article, letter, and report) that provide some broad instructions about how to setup a page, what levels of organization are allowed, and so on. Most of these are very plain, intended for professional-looking academic publications. Whatever we go with, we’ll want to extend it extensively.

My recommendation is to use the ‘book’ class because it comes with support for parts, chapters, sections, subsections, and sub-subsections. There’s also a ‘memoir’ class with more options, but to be honest using book + packages seem easier. To set up a book, add the following to the blank .tex file:

\documentclass[10pt,letterpaper,twoside,onecolumn,openany]{book}

\begin{document}
% content will go here

\end{document}

Most of the options should be self-explanatory. Note that this code starts off the document in one-column mode. See later for more info on columns.

Invoking Your Package

All our customization will go in the .sty file mentioned earlier. To set that up, open the file and add the following:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{testpkg}

Now, go to your main .tex document and add:

\usepackage{testpkg}

This tells LaTeX to look for your package and follow all the formatting instructions you put there.

Basic formatting

Lists

For a bulleted list:

\begin{itemize}
    \item First item text
    \item Second item text
    \item Blah blah blah
\end{itemize}

For a numbered list, use enumerate instead of itemize.

Parts, Chapters, and Sections

With the book class, your sectioning options are:

To use these, add \section{Section Name} to your document's body, followed by whatever text you want under that header.

If you’re keying a dungeon or similar, it’s worth planning out how you will map sectioning hierarchy onto location hierarchy. (I like to use chapters for floors/levels, sections for major thematic areas, subsections for rooms, and lists for room contents, with in-depth NPC/monster/puzzle descriptions meriting a subsubsection).

Useful Packages & Commands for RPGs

Simple Macros

If you know you’ll want to type something often with specific formatting, you can set up a macro to reduce the amount of typing you’ll have to do (and allow you to quickly adjust all instances of it).

For example, I was writing a Zelda-esque dungeon with color-coded keys, and I wanted the text for ‘Red Key’ to show up red every time I typed it. So with the line

\newcommand{\rk}{{\bfseries\color{red}Red Key}}

I was able to type things like ‘When the elementals are defeated, the statue’s hand opens to reveal the \rk’ to get:

Fonts

The default LaTeX font, ‘Latin Modern’ is pretty bland. There are two main ways to replace it.

First, and easiest, is to brows the LaTeX font catalogue, which comes included with all LaTeX installations (and is fully available on Overleaf). The entry for each font will provide the commands needed to implement it. For example, to use the antiquated-looking IM Fell English font used above, you would add

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

to your preamble or .sty file.

If you want to use a font you downloaded, you can use the fontspec package to define a new font family. For example, here is the code I used to implement the free Philosopher font from Google Fonts.

\RequirePackage{fontspec}
\newfontfamily\philosopherfont{Philosopher}[
    Path=Fonts/,
    Extension = .ttf,
    UprightFont=*-Regular,
    BoldFont=*-Bold,
    ItalicFont=*-Italic,
    BoldItalicFont=*-BoldItalic]

This tells LaTeX to add a new command, \philosopherfont, that will toggle the text that follows to use that font. In the command options, I specify the file path of the font files, tell LaTeX to look for files with a .ttf extension, and specify that the different versions of the font all have the format of Philosopher-[style].ttf.

Page Setup

The Book class comes with a few default page size options, but the geometry package allows for custom page sizes and margins. Simply add the following line to your .sty file and customize as needed:

\usepackage[paperwidth=8.5in, paperheight=11in, margin=0.5in]{geometry}

Custom Part, Chapter, and Section Headings

The default headings for parts, chapters, and sections are pretty bland and aggressively numbered - great for academic works but usually not necessary for a role-playing game. The titlesec package allows one to redefine the code used to format each header type.

To overwrite a heading format, use the following code template:

 \titleformat{<command>}[<shape>]{<format>}{<label>}{<sep>}{<before-code>}[<after-code>]

This can be interpreted as follows:

And here are two examples I've implemented. First, chapter heading code. This places the chapter number in small font above the chapter name, and adds a horizontal line below the name:

\usepackage[explicit]{titlesec}  %this invokes the titlesec package and the explicit command gives extra control over where the chapter name actually goes.

\titleformat{\chapter}[display]
{\normalfont\filcenter}
{ \textemdash \ \chaptertitlename \ \thechapter \ \textemdash }
{3pt}
{\titlerule\Large\bfseries\MakeUppercase{#1}}[\vspace{-3pt}\titlerule]

This code formats the sub-sub-section name to be in-line with the following text and applies the small-caps style to it:

\titleformat{\subsubsection}[runin]{\normalfont\bfseries }{}{0pt}{#1 \textemdash}

Tables

Tables are essential for any TTRPG worth its salt. At first glance, the table formatting for LaTeX is… clunky. But, it can be improved with the right tricks.

In general, LaTeX tables are always filled in by separating cells in a row with an ampersand (&) and adding a line break (\) after every row.

After shopping around, I strongly favor the tabularray package, which extends the basic table syntax and makes it easy to define a default table style with alternating shading and unique formatting for the ‘header’ row.

Here’s my current default table setup:

\newcommand{\ttrpgtbl}[2]{  % this code defines a new command called \ttrpgtbl with two inputs.
\begin{center}  % make sure tables are always centered
\begin{tblr}{  % invoke the tabularry package
 colspec = {#1},  % the column formatting commands will be the first command input
 row{odd} = {white}, row{even} = {lightgray!20},  % alternate row colors
 row{1} = {font=\scshape\small},  % make the header row have small caps and use a smaller fort
 row{2-Z} = {1pt,font=\small},  % normal rows have 1 pt spacing and use a smaller font
}
#2  % the second input will be the actual table contents
\end{tblr}
\end{center}}

Notice that it is set up as a command. The #1 input is for the column setup, which denotes the alignment and with of each column, and the #2 input is for the actual contents of the table. Thus in practice, this:

\ttrpgtbl{X[1,c]X[6,l]}{
    d6 & Complication \\ \midrule  % the midrule command creates a horizontal line after the first row
    1 & Owner of only copy wants twice the base price \\
    2 & Owner of only copy won't sell it \\
    3 & Only copy is in Archon's private library\\ 
    4 & Copy rumored to be in a dangerous ruin or vault \\
    5 & Owner wants a favor as well as besants \\
    6 & A rival mage starts a bidding war
}

results in this:

Illustrations

To insert an illustration, use the \includegraphics[size]{Path/to/image} command, inserting it wherever you want it to be placed in the text.

You can control the size of the image by specifying a width, most usefully by typing a decimal fraction before \textwidth, e.g. 0.25\textwidth which will scale the image according to the allowed width for columns of text.

Minipages

Inserting images is one are where LaTeX suffers compared to dedicated layout software — LaTeX was designed to handle figures in academic publications, where the expectations for artful blending of text & image are much lower.

Of the methods of wrapping text around images, I’ve found using side-by-side minipages to be the most painless, as follows:

\begin{minipage}{0.45\textwidth}
Blah blah blah...
\end{minipage}
\hspace{0.1\textwidth}
\begin{minipage}{0.45\textwidth}
\includegraphics[\textwidth]{Path/to/image}
\end{minipage}

You can then manually adjust the \textwidth scaling factors for each minipage as needed to resize the image, which automatically uses the full width of the minipage.

I should note that LaTeX supports something called ‘floats’ which allow the software to automatically place images in areas that keep the text looking nice. In my experience this works better for long stretches of unbroken text and poorly for ttrpg materials, so I don’t use them.

Fun Stuff & Best Practices

Page Breaks

LaTeX includes several ways to force a page break. \newpage, \clearpage, \cleardoublepage, and \pagebreak all perform this function with slight differences. If your page is in twocolumn mode, note that \newpage will shunt you to the next column, but \pagebreak and \clearpage create an actual new page.

Chapters automatically insert page breaks, but selectively using them between sections can be really helpful for ensuring that edits early in the document don’t wreak havoc on formatting down the line.

Multicolumn

One rule-of-thumb I’ve seen is that 6x9" is roughly the widest you can get away with single-column text. Using multiple columns often helps save space if you have lots of bullet points, lists, narrow tables, etc. (As ttrpgs often do).

For columns, I’ve used two simple options:

Drop Caps

Check out the lettrine package.

Box Text

The mdframed package is my preferred package for placing text into colored boxes. The code I use for a simple grey box is below:

\RequirePackage{mdframed} 
\usepackage{xcolor}
\newenvironment{boxtext}{\vspace{5pt}\begin{mdframed}[backgroundcolor=lightgray!20,nobreak]}{\end{mdframed}}

Headers & Footers

This is one of those things that’s wierdly more of a huge pain that I would have expected, but the fancyhdr package allows one to alter how headers and footers function. See here for more.

Inserting information from a csv

See here :)

Control-panel layouts

A popular RPG-design innovation is the 'control-panel' layout, where information on a particular topic is laid out on an easily-referenced two-page spread. The \cleardoublepage command unfortunately clears to odd-numbered pages, but we can force text to start on an even page by creating a cleartoleftpage command as follows:

\makeatletter
\newcommand*{\cleartoleftpage}{%
  \clearpage
    \if@twoside
    \ifodd\c@page
      \hbox{}\newpage
      \if@twocolumn
        \hbox{}\newpage
      \fi
    \fi
  \fi
}
\makeatother

#DIY #LaTeX