Free SKILL.md scraped from GitHub. Clone the repo or copy the file directly into your Claude Code skills directory.
npx versuz@latest install vivekkarmarkar-claude-code-os-skills-reproduce-multiple-pages-basic-texgit clone https://github.com/VivekKarmarkar/claude-code-os.gitcp claude-code-os/SKILL.MD ~/.claude/skills/vivekkarmarkar-claude-code-os-skills-reproduce-multiple-pages-basic-tex/SKILL.md---
name: reproduce-multiple-pages-basic-tex
description: Reproduce a CONTIGUOUS RANGE of research-paper PDF pages as standalone LaTeX source files (`.tex` only — NO compile, NO open, NO viewer launch). Validates the page range against the PDF's total page count first, then loops the `reproduce-page-basic-tex` pipeline over [p_start, p_end]. Use when the user invokes `/reproduce-multiple-pages-basic-tex` with a PDF path and a page range, or whenever they want to batch-generate `.tex` files for many pages of one paper in a single command.
---
# reproduce-multiple-pages-basic-tex
Produce `.tex` source files for every page in a contiguous range `[p_start, p_end]` of a single PDF, by looping the single-page pipeline from `reproduce-page-basic-tex`. This is the **batch** variant of `reproduce-page-basic-tex` — same source-only contract (no compile, no viewer), just wrapped in a validated loop with summary reporting.
**Scope boundary** (inherited from `reproduce-page-basic`): figures become placeholder boxes with prose descriptions; citations stay as literal `[N]` markers; output uses standard `article` class; not pixel-perfect; no BibTeX; no scanned PDFs.
## When to use this skill vs. the single-page variants
| If you want… | Use |
|---|---|
| A single page, `.tex` + compiled PDF + viewer | `reproduce-page-basic` |
| A single page, `.tex` only | `reproduce-page-basic-tex` |
| **A contiguous range of pages, `.tex` only, validated + batched** | **`reproduce-multiple-pages-basic-tex`** (this skill) |
| A non-contiguous subset (e.g., pages 3, 7, 11) | Call `reproduce-page-basic-tex` three times, or use a custom shell loop |
| Pixel-perfect publisher layout | None of the current skills — out of scope |
## Arguments
- `<pdf_path>` — absolute path to the source PDF (must have a text layer)
- `<p_start>` — 1-indexed starting page number (inclusive)
- `<p_end>` — 1-indexed ending page number (inclusive)
- `[<out_dir>]` — optional; defaults to the current working directory
## Pipeline (execute these steps in order, autonomously)
**Execute the whole pipeline without pausing for permission between pages.** If an individual page fails, apply the failure semantics below (continue-and-report by default) — do not ask "should I continue with the next page?" between iterations.
### Step 1 — Validate the range
Run the skill's validation helper first. It uses `pdfinfo` to read the PDF's total page count and checks whether `[p_start, p_end]` is sensible.
```bash
python3 ~/.claude/skills/reproduce-multiple-pages-basic-tex/helpers/validate_page_range.py \
<pdf_path> <p_start> <p_end>
```
- **Exit code 0** → range is valid; proceed to Step 2. The stdout line reports the PDF's total page count for your log.
- **Exit code 1** → range is invalid. Report the stderr message to the user verbatim and STOP. Do not fall back to guessing a "reasonable" range.
- **Exit code 2** → usage error (missing PDF, non-integer arg, pdfinfo failure). Report and STOP.
**Do NOT skip validation**, even if you think you know the page count from earlier in the conversation. The PDF is the source of truth and file state may have changed.
### Step 2 — Loop the single-page pipeline
For each integer page `N` in `[p_start, p_end]` (inclusive, ascending order), execute the **full** `reproduce-page-basic-tex` pipeline — steps 1, 2, and 3 from that skill's SKILL.md:
1. Extract prose verbatim via `helpers/extract_pdf_text.py <pdf_path> --page N`, writing to `<out_dir>/<stem>_page<N>_raw.txt`.
2. Read the page visually with `Read(<pdf_path>, pages: "<N>")`.
3. Write `<out_dir>/<stem>_page<N>.tex` combining cleaned prose + hand-transcribed equations + figure/table placeholders + layout cues, following all the rules in `NOTES.md` (symlinked in this skill).
The per-page contract is **identical** to `reproduce-page-basic-tex`:
- Use the stable preamble from `preamble_stable.tex`.
- Footer convention `\cfoot{\small <PRINTED_PAGE> $\to$ \arabic{page}}` + `\setcounter{page}{1}`.
- Set `\setcounter{equation}{M}` where M is the last equation from page `N-1` (skip if no equations on the page).
- Apply all prose cleanup rules from `NOTES.md §6`.
- Preserve typesetting anomalies verbatim (`NOTES.md §5`).
- Preserve cut-off sentences at page boundaries — do NOT stitch prose from neighboring pages.
**Equation-counter continuity across pages in the loop**: since you are reproducing consecutive pages in one run, you already know the last equation number from page `N-1` because you just wrote it. Use that value directly for page `N`'s `\setcounter{equation}{M}`. This is strictly better than guessing from memory, which is the usual single-page invocation pattern.
### Step 3 — Report summary
After the loop finishes (whether all pages succeeded or some failed), print a compact summary to the user:
```
Reproduced <K>/<N_TOTAL> pages from <pdf_stem> into <out_dir>:
page <p_start> ✓ <stem>_page<p_start>.tex
page <p_start+1> ✓ <stem>_page<p_start+1>.tex
page <p_start+2> ✗ <one-line reason>
...
```
List every page in the range, mark successes with `✓` and failures with `✗` plus a one-line reason. Follow with the list of `_raw.txt` scratch files the user can delete.
### Step 4 — STOP
- Do NOT run `pdflatex` on any of the produced files.
- Do NOT run `xdg-open` or any viewer.
- Do NOT append notes to `NOTES.md` (it is a symlink to the base skill; this skill is a pure consumer).
- Do NOT ask "should I compile them now?" or "want me to merge the PDFs?". The user invoked this skill specifically to avoid those follow-ups.
## Failure semantics: continue-and-report
If the single-page pipeline fails on page `N` (e.g., PDF has no text layer on that page, pdftotext raises, the visual Read fails, Write is denied), treat it as a **recoverable per-page failure**:
1. Capture the one-line reason for the failure.
2. Mark page `N` as `✗` in the summary with that reason.
3. **Continue** with page `N+1`. Do not abort the whole range.
4. If *every* page in the range fails, escalate to the user at the end with the aggregated diagnostic — the PDF is probably unreadable and they should know.
Rationale: batch tools that abort on first failure are frustrating for long ranges. A 22-page paper where page 11 happens to have a weird glyph should still produce 21 good `.tex` files, not 10.
## Idempotency: `.bak` rule inherited from the base
If `<stem>_page<N>.tex` already exists in `<out_dir>`, rename the existing file to `<stem>_page<N>.tex.bak` BEFORE writing the new version. If a `.bak` file already exists, overwrite the `.bak` (rolling single backup) — the user's working copy is always the newest `.tex`, and the second-newest is in `.bak`.
This matches the base skill's "NEVER overwrite without first renaming" rule. The multi-page variant just applies it in a loop.
## Composition with other tools
Because this skill still has no side effects beyond writing files, it composes cleanly with downstream workflows:
```bash
# 1. Generate all 22 pages of a paper
/reproduce-multiple-pages-basic-tex paper.pdf 1 22
# 2. Compile them all in a separate pass
for f in *_page*.tex; do pdflatex -interaction=nonstopmode "$f"; done
# 3. Concatenate a chapter
pdfunite paper_page0{5,6,7,8}.pdf paper_methods.pdf
```
You can also use it for targeted chunks: `/reproduce-multiple-pages-basic-tex paper.pdf 8 11` for just the methods section, then work with those four `.tex` files interactively.
## Resources in this skill
- **`NOTES.md`** (symlink → base `reproduce-page-basic/NOTES.md`) — judgment-call reference. Same file the single-page skills use.
- **`preamble_stable.tex`** (symlink → base) — the stable LaTeX preamble.
- **`helpers/`** (real directory) — contains symlinks to the four base helpers (`extract_pdf_text.py`, `clean_soft_hyphens.py`, `reflow_paragraphs.py`, `escape_latex.py`) plus one **skill-local** helper:
- **`validate_page_range.py`** — new; validates `[p_start, p_end]` against the PDF's `pdfinfo`-reported total page count. Required by Step 1. See the file header for its CLI contract.
- **`examples/`** (symlink → base `reproduce-page-basic/examples`) — 11 worked Wei-page reconstructions. Consult per-page-type as usual.
## Do-not-touch rules
- NEVER modify the input PDF. It is read-only.
- NEVER skip the Step 1 validation. The user's range may be outside the PDF's bounds.
- NEVER silently truncate or clamp the range to "make it work" — report and stop on invalid input.
- NEVER overwrite an existing `<stem>_page<N>.tex` without first renaming the existing file to `.bak`.
- NEVER abort the whole batch on a single-page failure — apply continue-and-report.
- NEVER "fix" typesetting anomalies in the source paper. Reproduce verbatim.
- NEVER retype prose from memory. It must come from `pdftotext` output.
- NEVER compile or open any `.tex`/`.pdf`. That is the base `reproduce-page-basic` skill's job, not this one's.