Review LaTeX Files
Run the comprehensive LaTeX review protocol focused on hardcoded numeric results.
Steps
- •
Identify files to review:
- •If an argument is a specific
.texfilename: review that file only - •If the argument is
all: review all.texfiles inlatex/
- •If an argument is a specific
- •
For each file, follow the review protocol below.
- •Save report to
quality_reports/[filename]_tex_review.md
- •Save report to
- •
After all reviews complete, present a summary:
- •Total issues found per file
- •Breakdown by severity (Critical / High / Medium / Low)
- •Top 3 most critical issues
- •
IMPORTANT: Do NOT edit any LaTeX source files unless auto-fixing (see Phase 2).
Review Protocol
Detect hardcoded numeric results in LaTeX manuscript prose and, when possible, automatically replace them with dynamically generated macros from the code pipeline.
Background
The project's code pipeline (R/Julia) generates .txt files containing \newcommand definitions in output/numbers/. The latex/Makefile sets TEXINPUTS to include ../output/numbers/, so the manuscript uses plain filenames:
\input{revenue_estimate.txt}
% Then in prose:
% a U.S. carbon tariff raises \$\revenueEstimate\ billion
Phase 1: Detection (Read-Only Scan)
Step 1: Build the Dynamic Value Registry
- •Glob for
output/numbers/*.txtand all\input{...}lines in.texfiles - •Read each
.txtfile and extract\newcommanddefinitions - •Build a registry:
{macro_name: value, ...}
Step 2: Scan Prose Sections
Read the .tex files. For each line, skip if inside:
- •Math environments:
equation,align,gather,multline, inline$...$ - •Table environments:
tabular,table,longtable - •Preamble (before
\begin{document}) - •Comment lines,
\ref,\eqref,\label,\citecommands - •LaTeX layout commands:
\vspace,\hspace,\setcounter,\setlength
Step 3: Classify Numbers
Always OK (never flag):
- •Section/equation/figure/table references
- •Years (1900--2100)
- •Structural descriptors: "12-sector", "N-country", "3-digit"
- •Numbers inside math or table environments
- •Page numbers, ordinals in prose
Suspicious (flag for review):
- •Dollar amounts:
\$N.NNfollowed by "billion"/"million"/"trillion" - •Percentages:
N\%,N percent,N percentage points - •Parenthetical numbers resembling standard errors:
(0.042) - •Numbers preceded by result verbs: "raises", "increases", "lowers", "reduces"
- •Decimal numbers in prose context
Step 4: Cross-Reference Against Registry
- •If an existing macro holds approximately this value: Critical -- macro exists but prose uses hardcoded number
- •If no matching macro: proceed to Phase 2
Phase 2: Source Tracing and Auto-Fix
Step 1: Trace the Source
- •Grep
code/for the numeric value, nearby variable names, or contextual keywords - •Examine Makefiles to find which scripts produce output files
- •Identify the specific script and line that computes the value
Step 2: Decide
- •Auto-fix if exactly one script clearly produces the value
- •Escalate to user if multiple candidates, no match, or external source
Step 3: Auto-Fix (When Source Is Clear)
- •Add stats generation code to the source script
- •Update
latex/MakefileSOURCES - •Replace hardcoded number with macro in manuscript
- •Rebuild and verify the generated number matches
Template State
If output/numbers/ does not exist AND code/ has no scripts, report:
No code pipeline found. Hardcoded number detection is informational only.
Report Format
# Hardcoded Number Review: [filename].tex **Date:** [YYYY-MM-DD] **Reviewer:** review-tex skill ## Summary - **Auto-fixed:** N - **Escalated:** N - **Clean:** No hardcoded results detected ## Auto-Fixed [List: line, old value, new macro, generated value] ## Escalated Issues ### Issue N: [Brief description] - **File:** `latex/[file]:[line_number]` - **Severity:** [Critical / High / Medium] - **Hardcoded value:** [the number] - **Context:** [surrounding sentence] - **Candidate sources:** [script paths, if any] - **Action needed:** [What the user should decide]
Severity Levels
| Severity | Condition | Quality Deduction |
|---|---|---|
| Critical | Macro exists but prose uses hardcoded number | -15 |
| High | Number is clearly a computed result but source not traced | -5 |
| Medium | Numbers do not match between hardcoded and dynamic | -5 |