$npx -y skills add WILLOSCAR/research-units-pipeline-skills --skill latex-scaffoldScaffold a LaTeX project (latex/main.tex, optional bibliography wiring, structure) from an existing Markdown draft. Trigger: latex scaffold, md→tex, LaTeX 项目骨架, 生成 main.tex. Use when: 需要 LaTeX/PDF 交付(例如 arxiv-survey-latex pipeline),且 draft 已生成/已进入写作阶段。
| 1 | # LaTeX Scaffold |
| 2 | |
| 3 | Convert the approved Markdown draft into a minimal, buildable LaTeX project. |
| 4 | |
| 5 | This is a deterministic conversion step; prose quality should already be addressed in `output/DRAFT.md`. |
| 6 | |
| 7 | ## Inputs |
| 8 | |
| 9 | - `output/DRAFT.md` or `output/TUTORIAL.md` |
| 10 | - optional: `citations/ref.bib` |
| 11 | |
| 12 | ## Outputs |
| 13 | |
| 14 | - `latex/main.tex` (and any required LaTeX support files) |
| 15 | |
| 16 | ## Workflow |
| 17 | |
| 18 | 1. Create `latex/` directory if missing. |
| 19 | 2. Create `latex/main.tex` with sections matching the outline. |
| 20 | 3. Wire bibliography to `citations/ref.bib` when that file exists. |
| 21 | |
| 22 | ## Quality checklist |
| 23 | |
| 24 | - [ ] `latex/main.tex` exists. |
| 25 | - [ ] If `citations/ref.bib` exists, `latex/main.tex` references it. |
| 26 | |
| 27 | ## Script |
| 28 | |
| 29 | ### Quick Start |
| 30 | |
| 31 | - `uv run python .codex/skills/latex-scaffold/scripts/run.py --help` |
| 32 | - `uv run python .codex/skills/latex-scaffold/scripts/run.py --workspace <workspace>` |
| 33 | |
| 34 | ### All Options |
| 35 | |
| 36 | - See `--help` (inputs/outputs are taken from the unit runner when used via pipeline) |
| 37 | |
| 38 | ### Examples |
| 39 | |
| 40 | - Build `latex/main.tex` from `output/DRAFT.md` or `output/TUTORIAL.md`: |
| 41 | - `uv run python .codex/skills/latex-scaffold/scripts/run.py --workspace <workspace>` |
| 42 | |
| 43 | ### Notes |
| 44 | |
| 45 | - The generated `latex/main.tex` includes a table of contents (tocdepth=2) for readability. |
| 46 | - Language default: the scaffold uses `article` (English-looking front matter). If the draft contains CJK characters, it switches to `ctexart` so the PDF renders correctly. |
| 47 | - Conversion rules (high level): |
| 48 | - Headings `##/###/####` → `\section/\subsection/\subsubsection` (strips leading numeric prefixes like `1.2`). |
| 49 | - Headings starting with `Appendix` / `附录` trigger `\appendix` once, then render as appendix sections. |
| 50 | - Bold caption lines like `**Table 1. ...**` / `**Appendix Table A1. ...**` immediately before a Markdown table become a LaTeX `table` float with `\caption{...}` and a stable `\label{tab:...}`. |
| 51 | - `## Abstract` → `abstract` environment. |
| 52 | - `[@Key]` or `[@Key1; @Key2]` → `\citep{Key}` / `\citep{Key1,Key2}`. |
| 53 | - Inline markdown `**bold**` / `*italic*` / `` `code` `` → `\textbf{}` / `\emph{}` / `\texttt{}`. |
| 54 | |
| 55 | ## Troubleshooting |
| 56 | |
| 57 | ### Issue: the generated `latex/main.tex` still contains Markdown markers |
| 58 | |
| 59 | **Fix**: |
| 60 | - Re-run `latex-scaffold` and ensure the input `output/DRAFT.md` is clean (no `##`, no `**`, no `[@...]` syntax that isn""t handled). |
| 61 | |
| 62 | ### Issue: citations are missing in LaTeX |
| 63 | |
| 64 | **Fix**: |
| 65 | - Ensure `citations/ref.bib` exists and the scaffold points bibliography to it; then compile with `latex-compile-qa`. |