LaTeX Scaffold
Convert the approved Markdown draft into a minimal, buildable LaTeX project.
This is a deterministic conversion step; prose quality should already be addressed in output/DRAFT.md.
Inputs
output/DRAFT.mdoroutput/TUTORIAL.md- optional:
citations/ref.bib
Outputs
latex/main.tex(and any required LaTeX support files)
Layout policy
The machine-readable layout contract lives in assets/layout_profiles.json.
The default profile uses a 1in A4 margin, includes a table of contents, and may
split large tables. The bounded course_paper profile uses a documented 0.9in
A4 margin, omits the table of contents, keeps a compact table whole when
possible, and sets only the bibliography in \small. Body text remains 11pt.
This profile is intended to respect an explicit page range, not to manufacture
substantive completeness by shrinking the paper.
Workflow
- Create
latex/directory if missing. - Create
latex/main.texwith sections matching the outline. - Wire bibliography to
citations/ref.bibwhen that file exists.
Quality checklist
- [ ]
latex/main.texexists. - [ ] If
citations/ref.bibexists,latex/main.texreferences it.
Script
Quick Start
uv run python .codex/skills/latex-scaffold/scripts/run.py --helpuv run python .codex/skills/latex-scaffold/scripts/run.py --workspace <workspace>
All Options
- See
--help(inputs/outputs are taken from the unit runner when used via pipeline)
Examples
- Build
latex/main.texfromoutput/DRAFT.mdoroutput/TUTORIAL.md:uv run python .codex/skills/latex-scaffold/scripts/run.py --workspace <workspace>
Notes
- The generated
latex/main.texincludes a table of contents (tocdepth=2) for readability. - The
course_paperprofile omits that table of contents according toassets/layout_profiles.json; other profiles include it by default. - Language default: the scaffold uses
article(English-looking front matter). If the draft contains CJK characters, it switches toctexartso the PDF renders correctly. - Conversion rules (high level):
- Headings
##/###/####→\section/\subsection/\subsubsection(strips leading numeric prefixes like1.2). - Headings starting with
Appendix/附录trigger\appendixonce, then render as appendix sections. - Bold caption lines like
**Table 1. ...**/**Appendix Table A1. ...**immediately before a Markdown table become a LaTeXtablefloat with\caption{...}and a stable\label{tab:...}. ## Abstract→abstractenvironment.[@Key]or[@Key1; @Key2]→\citep{Key}/\citep{Key1,Key2}.- Inline markdown
**bold**/*italic*/`code`→\textbf{}/\emph{}/\texttt{}.
- Headings
Troubleshooting
Issue: the generated latex/main.tex still contains Markdown markers
Fix:
- Re-run
latex-scaffoldand ensure the inputoutput/DRAFT.mdis clean (no##, no**, no[@...]syntax that isn""t handled).
Issue: citations are missing in LaTeX
Fix:
- Ensure
citations/ref.bibexists and the scaffold points bibliography to it; then compile withlatex-compile-qa.