# Using BibLaTeX for D&D

I'm going to start writing my D&D (Dungeons and Dragons) campaigns in latex because I'm more comfortable with it than Microsoft Word. I also want to use biblatex to make references for monsters used throughout, like this:

@monster{ skeleton,
name = {Skeleton},
size = {medium},
alignment = {lawful evil},
ac = {13},
hp = {13 (2d8+4)},
speed = {30ft},
blah blah blah...
}


So that I could say Something something skeleton\cite{skeleton} and click on citation to quickly see a stat block. Yes I am a genius.

Is there a way to put something in some files somewhere so that would enable latex to understand what I'm trying to do?

Rather than biblatex, perhaps you want the glossaries package.

\documentclass{article}

\usepackage{hyperref}
\usepackage[nonumberlist]{glossaries}

\newglossary*{monster}{Bestiary}
\newglossary*{npc}{Characters}

\makeglossaries

\newglossaryentry{monster:skeleton}{
name = Skeleton,
type=monster,
description = {size: medium,\\
alignment: lawful evil,
ac: 13,
hp: 13 (2d8+4),
speed: 30ft}
}
\newglossaryentry{npc:king}{
name = King Knuth,
description = {Ruler of the realm},
type = npc
}

\begin{document}

A \gls{monster:skeleton} attacks \gls{npc:king}

\printglossaries

\end{document}


It is possible to do this with biblatex (people have done all sorts already: https://www.tug.org/TUGboat/tb35-3/tb111fischer.pdf), but this might not be the most comfortable way to deal with this. biblatex offers a lot of things you won't need and it might be complicated to redefine and opt out of certain things you don't want and get the things you'd like to have instead. In particular it could be painful to obtain a tabular stats block.

There are other tools that can read in data and display it according to your wishes. datatool comes to mind, but Lua (of LuaLaTeX fame) could also offer you some possibilities.

Have a look at How can I create entirely new data types with BibLaTeX/Biber? for the details of defining a new entry type and its driver.

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@monster{gazebo,
name      = {Gazebo},
size      = {large},
alignment = {lawful evil},
ac        = {13},
hp        = {13 (2d8+4)},
speed     = {5ft},
}
\end{filecontents*}
\begin{filecontents}{dnd.dbx}
\DeclareDatamodelEntrytypes{monster}
\DeclareDatamodelFields[type=field,datatype=literal]{
name,
size,
alignment,
ac,
hp,
speed,
}
\DeclareDatamodelEntryfields[monster]{
name,
size,
alignment,
ac,
hp,
speed,
}
\end{filecontents}
\documentclass[english]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[datamodel=dnd,style=authoryear,backend=biber]{biblatex}
\usepackage{hyperref}

\DeclareFieldFormat{alignment}{\mkbibparens{#1}}

\DeclareFieldFormat{ac}{AC\space#1}

\DeclareBibliographyDriver{monster}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{name}%
\printfield{alignment}%
\newunit\newblock
\printfield{size}%
\newunit\newblock
\printfield{ac}%
\newunit\newblock
\printfield{hp}%
\newunit\newblock
\printfield{speed}%
\newunit\newblock
\usebibmacro{finentry}}

\renewbibmacro*{cite}{\printfield[bibhyperref]{name}}

\begin{document}
Then Eric was attacked by a \cite{gazebo}

\printbibliography[title=Monsters]
\end{document}


Depending on how interactive you'd like your document to be maybe PDF is not the right medium and you want a more dynamic HTML page instead? Markdown might be a lighter alternative to LaTeX markup when you don't need most of LaTeX's advanced (especially mathematical and general typographic) features.