Ayal Chen-Zion

Home

Generating LaTeX PDFs with Claude Code

Published Apr 19, 2026

Claude Code can write, compile, and iterate on LaTeX documents directly from your terminal—no GUI, no Overleaf, no manual pdflatex invocations required. This post walks through the workflow and links to a PDF it generated, including a set of canonical econometric estimators.

This post, the .tex source, and the compiled PDF were produced entirely from the Code section of the Claude mobile app—no laptop, no terminal, no IDE.

The Mobile-First Workflow

The Claude mobile app includes a Code tab that runs a full Claude Code agent in the cloud. It has shell access, can install packages, compile documents, and commit to GitHub—everything you would do in a local terminal session, from your phone or tablet.

  1. Open the Code section of the Claude mobile app and connect it to your repository.
  2. Ask Claude to write a .tex file for whatever you need—an equation, a table, a full article.
  3. Claude calls pdflatex (or xelatex) via its Bash tool, reads the .log for errors, and revises until the build is clean.
  4. Review the PDF, ask for changes, and Claude iterates—all without leaving the app.

Because the Code agent has full shell access it can also install missing packages via tlmgr or apt and place the finished PDF anywhere in your repository.

A Useful Prompt Pattern

End every LaTeX request with "compile and fix any errors." For multi-pass documents (bibliographies, cross-references), ask Claude to use latexmk -pdf instead of bare pdflatex. A minimal prompt looks like:

Write a one-page LaTeX document with the OLS and IV estimators in
amsmath align environments. Use the article class, 11pt font, 1-inch
margins via the geometry package. Compile with pdflatex and fix any
errors. Save to pdfs/estimators.pdf.

Econometric Equations in LaTeX

Below are the six estimators from the companion PDF, with the LaTeX source for each.

OLS

\hat{\beta}_{\mathrm{OLS}} = (X^\top X)^{-1} X^\top y

2SLS / IV

\hat{\beta}_{\mathrm{2SLS}} = \bigl(X^\top P_Z X\bigr)^{-1} X^\top P_Z y,
\qquad P_Z = Z(Z^\top Z)^{-1}Z^\top

Difference-in-Differences (two-way FE)

Y_{it} = \alpha + \tau D_{it} + \gamma_i + \delta_t + \varepsilon_{it}

Sharp Regression Discontinuity

\tau_{\mathrm{RD}}
  = \lim_{x \downarrow c} \mathbb{E}[Y \mid X = x]
  - \lim_{x \uparrow   c} \mathbb{E}[Y \mid X = x]

Panel Fixed Effects (within estimator)

\hat{\beta}_{\mathrm{FE}}
  = (\ddot{X}^\top\ddot{X})^{-1}\ddot{X}^\top\ddot{y},
\quad \ddot{y}_{it} \equiv y_{it} - \bar{y}_i

Efficient GMM

\hat{\theta}_{\mathrm{GMM}}
  = \arg\min_{\theta}\; g(\theta)^\top S^{-1} g(\theta)

Why This Is Useful

  • Transcribe hand-written estimators into clean align environments instantly.
  • Generate regression tables (estout, stargazer) directly from Python, R or even Stata output.
  • Produce a full article skeleton—front matter, sections, bibliography—from a one-sentence description.
  • Rebuild a document after switching between pdflatex and lualatex without touching the source yourself.
  • Do all of the above from your phone, entirely within the Claude mobile app.

The companion PDF, the .tex source, and this blog post were all written and committed in a single Claude Code session run from the Code tab of the Claude mobile app— a few prompts and some back-and-forth iteration—all from a porch swing on a sunny Seattle day.

This workflow is collected alongside other tech productivity skills in tech-econ-productivity-skills, a repository of practical tools and techniques for economists working with code.