15 LaTeX Document Preparation
LaTeX is the standard for academic writing, especially in fields with mathematical notation. Claude Code can make LaTeX significantly more approachable.
15.1 Why LaTeX?
- Professional typography: Beautiful equations, consistent formatting
- Reference management: BibTeX handles citations automatically
- Version control friendly: Plain text works well with git
- Journal requirements: Many journals provide LaTeX templates
15.2 Getting Started with LaTeX
If you don’t have LaTeX installed:
> Help me install LaTeX on my system
Mac:
brew install --cask mactexWindows: Download MiKTeX from miktex.org
Linux:
sudo apt-get install texlive-full15.3 Setting Up a LaTeX Project
> Create a LaTeX project for a scientific paper with:
> - Main document
> - Separate file for references (BibTeX)
> - Folder for figures
Claude creates:
paper/
├── main.tex
├── references.bib
├── figures/
└── sections/
├── introduction.tex
├── methods.tex
├── results.tex
└── discussion.tex
Sample main.tex:
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{natbib}
\usepackage{hyperref}
\title{Your Paper Title}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
Your abstract here.
\end{abstract}
\input{sections/introduction}
\input{sections/methods}
\input{sections/results}
\input{sections/discussion}
\bibliographystyle{plainnat}
\bibliography{references}
\end{document}15.4 Common LaTeX Tasks
15.4.1 Writing Equations
> Help me write the equation for logistic regression in LaTeX
\begin{equation}
P(Y=1|X) = \frac{1}{1 + e^{-(\beta_0 + \beta_1 X_1 + ... + \beta_n X_n)}}
\end{equation}> I need a system of equations for a differential equation model
\begin{align}
\frac{dS}{dt} &= -\beta SI \\
\frac{dI}{dt} &= \beta SI - \gamma I \\
\frac{dR}{dt} &= \gamma I
\end{align}15.4.2 Creating Tables
> Create a LaTeX table from this data:
> Gene | Control | Treatment | p-value
> BRCA1 | 2.3 | 5.7 | 0.001
> TP53 | 4.1 | 3.9 | 0.45
\begin{table}[h]
\centering
\caption{Differential expression results}
\begin{tabular}{lccc}
\hline
Gene & Control & Treatment & p-value \\
\hline
BRCA1 & 2.3 & 5.7 & 0.001** \\
TP53 & 4.1 & 3.9 & 0.45 \\
\hline
\end{tabular}
\label{tab:de_results}
\end{table}15.4.3 Including Figures
> Add a figure from figures/umap.pdf with a caption about cell clustering
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{figures/umap.pdf}
\caption{UMAP visualization of single-cell data revealing distinct cell populations.
Cells are colored by cluster identity.}
\label{fig:umap}
\end{figure}15.4.4 Managing References
> Add this paper to my BibTeX file: DOI 10.1016/j.cell.2015.05.002
Claude fetches the citation information and creates:
@article{macosko2015highly,
title={Highly parallel genome-wide expression profiling of individual
cells using nanoliter droplets},
author={Macosko, Evan Z and Basu, Anindita and Satija, Rahul and ...},
journal={Cell},
volume={161},
number={5},
pages={1202--1214},
year={2015},
publisher={Elsevier},
doi={10.1016/j.cell.2015.05.002}
}15.5 Troubleshooting LaTeX Errors
LaTeX error messages can be cryptic. Claude Code helps:
> I'm getting this error when compiling:
> ! Undefined control sequence.
> l.45 \includegraphics
Claude identifies: “You need to add \usepackage{graphicx} to your preamble.”
> My references aren't showing up, just [?] marks
Claude guides you through the BibTeX compilation process:
pdflatex main
bibtex main
pdflatex main
pdflatex main15.6 Journal Templates
> I need to format my paper for submission to Nature Methods.
> Help me set up their LaTeX template.
Claude helps you: 1. Find and download the official template 2. Restructure your content to fit 3. Adjust formatting requirements
15.7 Converting to/from LaTeX
15.7.1 Word to LaTeX
> Convert this Word document to LaTeX, preserving citations and figures
15.7.2 LaTeX to Word
> Convert my LaTeX paper to Word format for a collaborator
Using pandoc:
pandoc main.tex -o main.docx --bibliography=references.bib15.8 Automating Compilation
> Create a Makefile for compiling my LaTeX document
MAIN = main
BIB = references
all: $(MAIN).pdf
$(MAIN).pdf: $(MAIN).tex $(BIB).bib
pdflatex $(MAIN)
bibtex $(MAIN)
pdflatex $(MAIN)
pdflatex $(MAIN)
clean:
rm -f *.aux *.log *.bbl *.blg *.out
.PHONY: all clean15.9 Tips for LaTeX with Claude Code
15.9.1 Let Claude Handle the Syntax
> I want a matrix with 3 rows and 3 columns showing the values...
Don’t memorize LaTeX syntax—describe what you want.
15.9.2 Debug Incrementally
If compilation fails after many changes:
> Compile after each change to identify which one broke it
15.9.3 Use Version Control
LaTeX is plain text—perfect for git:
> Commit the current working version before making major changes
15.10 Next Steps
Continue to Automating Repetitive Tasks.