How to Make AI Continue Writing in Your Existing LaTeX Style
Give AI the Source of Your Formatting Rules
Font sizes, spacing, numbering, and citation styles come from the class, package options, and project-defined commands—not just the body text. If AI sees only prose, it can fall back to a different generic style.
These main.tex and refs.bib files form a complete example. The preamble defines \method; the Convergence subsection is the style sample:
\documentclass[11pt]{article}
\usepackage{amsmath,booktabs}
\usepackage[backend=biber]{biblatex}
\addbibresource{refs.bib}
\newcommand{\method}[1]{\textsc{#1}}
\begin{document}
\section{Convergence}\label{sec:convergence}
We use \method{gradient descent}; see~\cite{knuth1984}.
This subsection demonstrates the project's notation.
\printbibliography
\end{document}
@book{knuth1984,
author = {Donald E. Knuth},
title = {The TeXbook},
publisher = {Addison-Wesley},
year = {1984}
}
@book{lamport1994,
author = {Leslie Lamport},
title = {LaTeX: A Document Preparation System},
edition = {2},
publisher = {Addison-Wesley},
year = {1994}
}
Its \method{...}, \cite{...}, and \label{sec:...} calls demonstrate the project's conventions.
Supply an Example of the Same Kind
“Keep the formatting consistent” needs a comparison target. To continue a subsection, provide a finished subsection. To create a table, provide an existing table environment.
For a booktabs table, include the rules and column specification as well as the data:
\begin{table}[htbp]
\centering
\begin{tabular}{lcc}
\toprule
Model & Accuracy & F1 \\
\midrule
Baseline & 0.812 & 0.794 \\
Ours & 0.867 & 0.851 \\
\bottomrule
\end{tabular}
\caption{Illustrative results.}
\label{tab:results}
\end{table}
State the Allowed Commands, Label Prefixes, and Keys
Send the request with the sample source:
Continue with one subsection matching the supplied example; return only new content.
Preserve the document class, preamble, and macro definitions.
Use only the provided commands and citation keys; add no packages.
Use the sec: prefix for new labels and avoid existing names.
Mark uncertain terms, data, and references for confirmation; do not fill them in.
Supply the .bib key list, or restrict citations to keys already demonstrated. Otherwise a generated key may not exist, causing Citation '...' undefined and [?].
Compile and Compare the Continuation
After adding the text, check three things:
- Commands: compare new commands with the preamble definitions; remove or replace undefined ones.
- Labels: every reference must have a matching target, with prefixes and unique names that follow the project rules.
- Citations: every cited key must exist in
.bib. After changes, compile and wait for bibliography processing.
The log does not judge visual consistency. Compare the new subsection with the sample in the PDF. First check whether the new text follows the existing template; do not alter the global preamble or patch the result with arbitrary \vspace just to hide a mismatch.
Common Deviations
| Message or symptom | Cause | Action |
|---|---|---|
Undefined control sequence. \method | Project command was omitted from context | Provide its definition |
Citation 'x' undefined | Invented or missing key | Supply the allowed keys and search .bib |
Reference 'fig:x' undefined | Missing target or inconsistent naming | Check the label and compile the complete document |
Environment tabularx undefined. | The continuation introduced an unloaded package | Use an available package or retain the existing table approach |
Overfull \hbox | Table or equation exceeds the available width | Check column widths and unbreakable content, especially in two-column templates |
Related: safer AI edits, avoiding compilation errors, and reusing LaTeX code.
Takeaways
- Supply the class, preamble, and project commands.
- Provide a matching subsection or table sample.
- Define the command, label, and citation boundaries.
- Use the log for undefined names and the PDF for visual comparison.
In EasyLaTeX, keep the continuation with the whole project, compile, and inspect both output and errors.