\documentclass[11pt]{article}
\usepackage{amsmath, amssymb, amsthm}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{parskip}

\hypersetup{
  colorlinks=true,
  linkcolor=blue,
  urlcolor=blue
}

\title{Generating \LaTeX{} PDFs with Claude Code}
\author{Ayal Chen-Zion}
\date{April 2026}

\begin{document}

\maketitle

\begin{abstract}
Claude Code can generate, compile, and iterate on \LaTeX{} documents entirely
from the \textbf{Code section of the Claude mobile app}---no laptop, no
terminal, no IDE required. This document, its \texttt{.tex} source, and the accompanying blog post were
all produced this way---through a few prompts and some back-and-forth
iteration, from a porch swing on a sunny Seattle day. The workflow is
illustrated with a set of canonical econometric estimators.
\end{abstract}

\section{The Mobile-First Workflow}

The Claude mobile app includes a \textbf{Code} tab that runs a full Claude Code
agent in the cloud with shell access, package installation, and Git
integration---everything available in a local terminal, from your phone or
tablet. The core loop is:

\begin{enumerate}
  \item Open the Code section of the Claude mobile app and connect it to your
        repository.
  \item Ask Claude to write a \texttt{.tex} file for whatever you need.
  \item Claude calls \texttt{pdflatex} (or \texttt{xelatex}) via its Bash
        tool to compile the document and checks the log for errors.
  \item Review the PDF, ask for revisions, and Claude iterates---all without
        leaving the app.
\end{enumerate}

Because the Code agent has full shell access it can install missing packages via
\texttt{tlmgr} or \texttt{apt}, fix compilation errors by reading the log, and
place the finished PDF anywhere in your repository---including linking to it
from a website.

\section{Why This Is Useful for Economists}

Writing econometric papers involves a lot of repetitive \LaTeX: regression
tables, equation environments, theorem/proof pairs, TikZ diagrams. Claude Code
can:

\begin{itemize}
  \item Transcribe a hand-written estimator into a clean \texttt{align}
        environment.
  \item Generate \texttt{estout} or \texttt{stargazer} tables directly from
        Python, R or even Stata output.
  \item Produce a full article skeleton (front matter, sections, bibliography)
        from a one-sentence description.
  \item Rebuild a document after you change a package or switch between
        \texttt{pdflatex} and \texttt{lualatex}.
\end{itemize}

\section{Canonical Econometric Estimators}

The examples below represent the estimators an applied economist encounters
most often. Each was typeset by Claude Code in a single pass.

\subsection{Ordinary Least Squares}

The OLS estimator minimises the sum of squared residuals:
\[
  \hat{\beta}_{\mathrm{OLS}}
    = \arg\min_{\beta}\, (y - X\beta)^\top(y - X\beta)
    = (X^\top X)^{-1} X^\top y.
\]
Under the Gauss--Markov assumptions it is BLUE.  Its sampling variance is
\[
  \mathrm{Var}(\hat{\beta}_{\mathrm{OLS}} \mid X)
    = \sigma^2 (X^\top X)^{-1}.
\]

\subsection{Instrumental Variables / Two-Stage Least Squares}

When $\mathrm{Cov}(X,\varepsilon)\neq 0$ we need instruments $Z$ satisfying
relevance ($Z^\top X \neq 0$) and exogeneity ($\mathrm{Cov}(Z,\varepsilon)=0$).
The 2SLS estimator is
\[
  \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.
\]
With a single instrument this collapses to the Wald estimator:
\[
  \hat{\beta}_{\mathrm{IV}}
    = \frac{\mathrm{Cov}(Z, y)}{\mathrm{Cov}(Z, X)}
    = \frac{\bar{y}_1 - \bar{y}_0}{\bar{X}_1 - \bar{X}_0}.
\]

\subsection{Difference-in-Differences}

The two-way fixed-effects DiD regression is
\[
  Y_{it} = \alpha + \tau D_{it} + \gamma_i + \delta_t + \varepsilon_{it},
\]
where $\gamma_i$ are unit fixed effects, $\delta_t$ are time fixed effects, and
$D_{it}$ is the treatment indicator.  Under parallel trends,
$\hat{\tau}_{\mathrm{DiD}}$ identifies the average treatment effect on the
treated (ATT).

With staggered adoption (Callaway \& Sant'Anna 2021) the ATT for cohort $g$
at time $t$ is
\[
  \mathrm{ATT}(g,t)
    = \mathbb{E}\bigl[Y_t(g) - Y_t(0) \mid G = g\bigr],
\]
and the aggregate ATT aggregates over $(g,t)$ pairs with appropriate weights.

\subsection{Regression Discontinuity}

The sharp RD estimand is the local average treatment effect at the cutoff $c$:
\[
  \tau_{\mathrm{RD}}
    = \lim_{x \downarrow c} \mathbb{E}[Y \mid X = x]
    - \lim_{x \uparrow   c} \mathbb{E}[Y \mid X = x].
\]
A local-linear estimator with bandwidth $h$ solves
\[
  \min_{\alpha_\ell, \beta_\ell, \alpha_r, \beta_r}
  \sum_{i} K\!\left(\frac{X_i - c}{h}\right)
  \Bigl[Y_i - \alpha_{s(i)} - \beta_{s(i)}(X_i - c)\Bigr]^2,
\]
where $s(i) \in \{\ell, r\}$ indicates the side of the cutoff and $K(\cdot)$
is a kernel function (commonly triangular).

\subsection{Panel Fixed Effects and the Within Estimator}

For panel data the fixed-effects model is
\[
  y_{it} = X_{it}^\top\beta + \alpha_i + \varepsilon_{it}.
\]
Demeaning within units eliminates $\alpha_i$:
\[
  \ddot{y}_{it} = \ddot{X}_{it}^\top\beta + \ddot{\varepsilon}_{it},
  \quad
  \ddot{y}_{it} \equiv y_{it} - \bar{y}_i.
\]
The within estimator $\hat{\beta}_{\mathrm{FE}} = (\ddot{X}^\top\ddot{X})^{-1}\ddot{X}^\top\ddot{y}$
is numerically equivalent to including unit dummies.

\subsection{Generalised Method of Moments}

GMM minimises the weighted distance of moment conditions $g(\theta) =
\frac{1}{n}\sum_i m(W_i;\theta)$:
\[
  \hat{\theta}_{\mathrm{GMM}}
    = \arg\min_{\theta}\; g(\theta)^\top W\, g(\theta).
\]
The efficient (two-step) GMM sets $W = S^{-1}$ where
$S = \mathrm{Var}\!\bigl(\sqrt{n}\,g(\theta_0)\bigr)$ is the long-run variance
of the moments.  The asymptotic distribution is
\[
  \sqrt{n}\,(\hat{\theta} - \theta_0)
    \xrightarrow{d}
    \mathcal{N}\!\left(0,\; (G^\top S^{-1} G)^{-1}\right),
  \quad G = \mathbb{E}\!\left[\frac{\partial m}{\partial\theta^\top}\right].
\]

\section{Practical Tips}

\begin{description}
  \item[Use the Claude mobile app's Code tab.] Everything in this document was
    produced from the Code section of the Claude mobile app---the blog post,
    this \texttt{.tex} file, and this PDF---without a laptop or local terminal.

  \item[Be explicit about packages.] Tell Claude which \LaTeX{} packages you
    want to use (\texttt{amsmath}, \texttt{booktabs}, \texttt{pgfplots}, etc.).
    Claude will use them and install them if missing.

  \item[Ask for iterative compilation.] A good prompt ends with ``compile and
    fix any errors.'' Claude will read the \texttt{.log} and revise until the
    build is clean.

  \item[Commit both \texttt{.tex} and \texttt{.pdf}.] The source is the
    authoritative record; the compiled PDF lets others read without a \LaTeX{}
    install.

  \item[Use \texttt{latexmk} for multi-pass documents.] Bibliographies and
    cross-references need multiple runs. Ask Claude to use
    \texttt{latexmk -pdf} instead of bare \texttt{pdflatex}.
\end{description}

\end{document}
