Latex doctor

From Alexander-M-Dickerson/ai-asset-pricing · View interactive version

Latex doctor is an AI agent skill from the GitHub repository Alexander-M-Dickerson/ai-asset-pricing. Clean and fix .tex files -- strip comments, fix compilation errors, verify section markers

How to use this skill

Skill file

LaTeX Doctor Skill

The "clean room" skill. Run to get a .tex file into a consistent, compilable state with verified section markers.

Examples

Workflow

Step 1: Initial Compile

  1. Run the compile command (use pdflatex/bibtex paths from canonical local state reported by tools/bootstrap.py audit, or a repo-root compatibility shim if present):

```bash

cd {latex_dir} && pdflatex -interaction=nonstopmode {file} && bibtex {stem} && pdflatex -interaction=nonstopmode {file} && pdflatex -interaction=nonstopmode {file}

```

  1. Parse the log for:
  1. Report: "Current state: N errors, M warnings"

Step 2: Comment Cleanup

Scan the .tex file and remove unnecessary comments:

REMOVE:

PRESERVE (never touch):

Report: "Removed N comment lines (K characters saved)"

Step 3: Verify Section Markers

Verify %% BEGIN/END markers for consistency.

  1. Scan the .tex file for all %% BEGIN key and %% END key markers
  2. If the project's CLAUDE.md defines registered section keys, cross-reference against them
  3. Check for:
  1. Fix any issues found, or flag for human review if ambiguous

Report: "Verified N markers. M issues found."

Step 4: Compilation Fixes

Address common compilation errors:

Missing packages:

Undefined references:

Missing bibliography:

Orphaned labels:

Step 5: Warning Reduction

Address common warnings:

Overfull \hbox:

Underfull \hbox:

Missing references:

Report: "Addressed N warnings. Reduced from M to K remaining."

Step 6: Recompile and Report

  1. Run full compile cycle
  2. Parse the new log
  3. Generate final report:
LATEX DOCTOR REPORT
====================

File: [filename]

COMMENTS:
  Removed: N lines (K characters)
  Preserved: M marker/directive lines

SECTION MARKERS:
  Verified: N markers
  Issues: M issues found [list if any]

COMPILATION:
  Before: E errors, W warnings
  After:  E' errors, W' warnings
  Fixed:  [list of fixes applied]

REMAINING ISSUES:
  - [list of issues that need human attention]

STATUS: [CLEAN COMPILE / N ISSUES REMAINING]
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.