\chapter{Background}
\label{ch:background}

This chapter places the work in its literature, describes the workflow the
later chapters follow, and introduces the datasets used in the evaluation.

\section{Related work}

Document preparation has been studied since the first typesetting systems were
written for authors rather than printers \citep{knuth1984}. The separation of
content from presentation, which \citet{lamport1994} made routine, is what
makes an automated check possible at all: the source of a document carries its
structure, not only its appearance. Later work on packages and document classes
\citep{mittelbach2004} extended that structure, and recent studies of
collaborative writing \citep{someone2024} report the coordination costs that
motivate this thesis.

Two lines of work are close to ours. The first checks documents against a
style guide and reports violations of rules that are fixed in advance. The
second compares versions of the same document and reports what changed. Neither
recovers the relationships inside a single draft, which is what the method in
this thesis does.

\section{The workflow}

Figure~\ref{fig:workflow} shows the three stages the method works in. The
source of the document is parsed once into a structured form, the structure is
turned into a graph whose nodes are symbols, figures, tables and numbers, and
the graph is then queried for the patterns that indicate an inconsistency.

\begin{figure}[htbp]
  \centering
  \begin{tikzpicture}[x=1cm, y=1cm]
    \draw[thick] (0,0) rectangle (3.6,1.4);
    \node at (1.8,0.7) {Source};
    \draw[thick] (5.2,0) rectangle (8.8,1.4);
    \node at (7.0,0.7) {Graph};
    \draw[thick] (10.4,0) rectangle (14.0,1.4);
    \node at (12.2,0.7) {Report};
    \draw[thick,->] (3.6,0.7) -- (5.2,0.7);
    \draw[thick,->] (8.8,0.7) -- (10.4,0.7);
    \node[anchor=south] at (4.4,0.85) {\small parse};
    \node[anchor=south] at (9.6,0.85) {\small query};
  \end{tikzpicture}
  \caption{The three stages of the workflow: the source is parsed, the
    structure becomes a graph, and the graph is queried for inconsistencies.}
  \label{fig:workflow}
\end{figure}

Each stage is deliberately independent. The parser can be replaced for a
different input format without touching the queries, and a new query is a new
pattern over the same graph rather than a new pass over the source.

A run of the method is scored by the share of the seeded errors it recovers,

\begin{equation}
  r = \frac{n_{\mathrm{found}}}{n_{\mathrm{seeded}}} ,
  \label{eq:recovery}
\end{equation}

and the recovery rate of Equation~\ref{eq:recovery} is reported separately for
each of the three collections described below.

\section{Datasets}

Three collections of documents are used, summarized in
Table~\ref{tab:datasets}. The pilot study fixed the interview questions and the
seeding procedure. The main corpus is the body of the evaluation. The held-out
set was not read until the method was frozen, so it reports the performance a
new user should expect.

\begin{table}[htbp]
  \centering
  \caption{The three collections of documents used in the evaluation.}
  \label{tab:datasets}
  \begin{tabular}{lrrr}
    \toprule
    Collection   & Documents & Pages & Size (MB) \\
    \midrule
    Pilot study  &       120 &   2\,400 &   4 \\
    Main corpus  &     8\,400 & 210\,000 & 310 \\
    Held-out set &     2\,100 &  52\,000 &  78 \\
    \midrule
    Total        &    10\,620 & 264\,400 & 392 \\
    \bottomrule
  \end{tabular}
\end{table}

The three collections were drawn from the same sources and split by author, so
no author appears in more than one of them.
