render-chinese-math-pdf
Trigger Boundary
Use this skill when the requested deliverable is a readable PDF from Chinese,
mixed Chinese/English, or math-heavy Markdown/LaTeX, especially when the likely
failure mode is CJK font setup, Unicode math, Pandoc/XeLaTeX behavior, tables,
citations, or PDF text readability.
Do not use this skill for general PDF text extraction, image-only OCR, or
non-CJK documents unless the user specifically asks for this rendering QA
workflow.
Default Architecture
The default renderer is strictly:
Markdown -> Pandoc -> XeLaTeX -> PDF
The production entrypoint is the current host's
render_resources/chinese_math_pdf/scripts/render_markdown_pdf.sh.
The resource root is resolved in this order:
- An explicit project-local resource root, when a project command provides one.
CHINESE_MATH_PDF_RESOURCE_DIRS, split on :.
- The current namespace override at
CODEX_NAMESPACE_ROOT/.config/ai-skills/local-overrides.toml.
- The global/home override at
$HOME/.config/ai-skills/local-overrides.toml;
helpers also check the configured CODEX_GLOBAL_HOME boundary when present.
- Generic ancestor discovery for
render_resources/chinese_math_pdf.
Host-specific resource roots belong only in repo-external local override files
or one-off environment variables. Do not hardcode a private absolute path into
the reusable skill source, references, or scripts. Once the root is found, run
its local scripts from that root.
Font Policy
The default PDF fonts must come from bundle-local font files, not fontconfig or
Windows mounts:
- Latin main: TeX Gyre Termes regular, bold, italic, and bold italic from
fonts/texgyre-termes/.
- Math: TeX Gyre Termes Math from
fonts/texgyre-termes-math/.
- Math calligraphic alphabets: New Computer Modern Math from
fonts/newcomputermodern/, loaded only for unicode-math ranges
cal,bfcal.
- CJK serif: Noto Serif SC regular and bold from
texmf/fonts/opentype/public/noto-cjk/.
- CJK sans: Noto Sans SC regular and bold from
texmf/fonts/opentype/public/noto-cjk/.
Do not use Times New Roman, Windows font mounts, fontconfig Times lookup,
DejaVu, Liberation, or Fandol as default font sources. Fandol may remain in the
bundle only as a legacy or emergency manual fallback.
Workflow
- Locate the source document and the active resource root before compiling.
- Probe the environment:
python scripts/probe_pdf_render_env.py --root <project-root> --pretty
when the script is available, plus pandoc --version, xelatex --version,
and kpsewhich checks when needed.
- Compile Markdown through the resource script:
<resource-root>/scripts/render_markdown_pdf.sh input.md output.pdf
- For
.tex sources, use XeLaTeX directly with the same TEXMFHOME,
TEXMFVAR, TEXMFCONFIG, TEXMFCACHE, and OSFONTDIR strategy used by
render_markdown_pdf.sh.
- If XeLaTeX or a required package/font is missing, report
blocked_missing_dependency with the exact missing dependency. Do not
silently switch to Chromium.
- If Pandoc + XeLaTeX fails, inspect the generated header/source or
.log and
report the real LaTeX failure. Do not present a Chromium PDF as a successful
LaTeX build.
- Validate the produced PDF, not only the command exit code:
pdfinfo for page count when available.
pdffonts for embedded/subset TeX Gyre Termes, TeX Gyre Termes Math,
Noto Serif SC, and Noto Sans SC usage.
pdftotext -layout for extractable Chinese, English, formulas, and table
row survival.
pdftoppm or scripts/validate_pdf.sh for a first-page PNG preview.
- Treat the task as incomplete if Chinese glyphs, formulas, table layout, or
text extraction fail.
Completion States
complete: PDF rendered through Pandoc + XeLaTeX and passed command,
page-count, font, text-extraction, and first-page visual checks.
partial_complete: PDF rendered, but non-critical warnings or limited QA
remain and are reported with next steps.
blocked_missing_dependency: no safe Pandoc + XeLaTeX route exists; report
the missing command/package/font and attempted route.
qa_failed: a PDF was produced but readability, glyphs, pagination, or text
extraction failed.
References
- Read
references/portable-rendering.md when setting up a new repo, replacing
a host-local override path, or handling missing TeX/font dependencies.
- Read
references/citation-cleanup.md when source text contains AI citation
handles, private-use marker characters, broken bibliography tokens, or
generated reference placeholders.
- Read
references/checklists.md before final PDF QA.
- Read
references/source-notes.md only when you need provenance for why this
skill avoids host-specific assumptions.
1---2name: render-chinese-math-pdf3description: Render and validate Chinese or mixed Chinese/English mathematical Markdown/LaTeX as PDF. Use for CJK text, Unicode math, equations, tables, Pandoc/XeLaTeX, TeX font/cache failures, citation cleanup, or readable PDF QA.4---5# render-chinese-math-pdf67## Trigger Boundary89Use this skill when the requested deliverable is a readable PDF from Chinese,10mixed Chinese/English, or math-heavy Markdown/LaTeX, especially when the likely11failure mode is CJK font setup, Unicode math, Pandoc/XeLaTeX behavior, tables,12citations, or PDF text readability.1314Do not use this skill for general PDF text extraction, image-only OCR, or15non-CJK documents unless the user specifically asks for this rendering QA16workflow.1718## Default Architecture1920The default renderer is strictly:2122```text23Markdown -> Pandoc -> XeLaTeX -> PDF24```2526The production entrypoint is the current host's27`render_resources/chinese_math_pdf/scripts/render_markdown_pdf.sh`.2829The resource root is resolved in this order:30311. An explicit project-local resource root, when a project command provides one.322. `CHINESE_MATH_PDF_RESOURCE_DIRS`, split on `:`.333. The current namespace override at34 `CODEX_NAMESPACE_ROOT/.config/ai-skills/local-overrides.toml`.354. The global/home override at `$HOME/.config/ai-skills/local-overrides.toml`;36 helpers also check the configured `CODEX_GLOBAL_HOME` boundary when present.375. Generic ancestor discovery for `render_resources/chinese_math_pdf`.3839Host-specific resource roots belong only in repo-external local override files40or one-off environment variables. Do not hardcode a private absolute path into41the reusable skill source, references, or scripts. Once the root is found, run42its local scripts from that root.4344## Font Policy4546The default PDF fonts must come from bundle-local font files, not fontconfig or47Windows mounts:4849- Latin main: TeX Gyre Termes regular, bold, italic, and bold italic from50 `fonts/texgyre-termes/`.51- Math: TeX Gyre Termes Math from `fonts/texgyre-termes-math/`.52- Math calligraphic alphabets: New Computer Modern Math from53 `fonts/newcomputermodern/`, loaded only for `unicode-math` ranges54 `cal,bfcal`.55- CJK serif: Noto Serif SC regular and bold from56 `texmf/fonts/opentype/public/noto-cjk/`.57- CJK sans: Noto Sans SC regular and bold from58 `texmf/fonts/opentype/public/noto-cjk/`.5960Do not use Times New Roman, Windows font mounts, fontconfig Times lookup,61DejaVu, Liberation, or Fandol as default font sources. Fandol may remain in the62bundle only as a legacy or emergency manual fallback.6364## Workflow65661. Locate the source document and the active resource root before compiling.672. Probe the environment:68 `python scripts/probe_pdf_render_env.py --root <project-root> --pretty`69 when the script is available, plus `pandoc --version`, `xelatex --version`,70 and `kpsewhich` checks when needed.713. Compile Markdown through the resource script:7273```bash74<resource-root>/scripts/render_markdown_pdf.sh input.md output.pdf75```76774. For `.tex` sources, use XeLaTeX directly with the same `TEXMFHOME`,78 `TEXMFVAR`, `TEXMFCONFIG`, `TEXMFCACHE`, and `OSFONTDIR` strategy used by79 `render_markdown_pdf.sh`.805. If XeLaTeX or a required package/font is missing, report81 `blocked_missing_dependency` with the exact missing dependency. Do not82 silently switch to Chromium.836. If Pandoc + XeLaTeX fails, inspect the generated header/source or `.log` and84 report the real LaTeX failure. Do not present a Chromium PDF as a successful85 LaTeX build.867. Validate the produced PDF, not only the command exit code:87 - `pdfinfo` for page count when available.88 - `pdffonts` for embedded/subset TeX Gyre Termes, TeX Gyre Termes Math,89 Noto Serif SC, and Noto Sans SC usage.90 - `pdftotext -layout` for extractable Chinese, English, formulas, and table91 row survival.92 - `pdftoppm` or `scripts/validate_pdf.sh` for a first-page PNG preview.938. Treat the task as incomplete if Chinese glyphs, formulas, table layout, or94 text extraction fail.9596## Completion States9798- `complete`: PDF rendered through Pandoc + XeLaTeX and passed command,99 page-count, font, text-extraction, and first-page visual checks.100- `partial_complete`: PDF rendered, but non-critical warnings or limited QA101 remain and are reported with next steps.102- `blocked_missing_dependency`: no safe Pandoc + XeLaTeX route exists; report103 the missing command/package/font and attempted route.104- `qa_failed`: a PDF was produced but readability, glyphs, pagination, or text105 extraction failed.106107## References108109- Read `references/portable-rendering.md` when setting up a new repo, replacing110 a host-local override path, or handling missing TeX/font dependencies.111- Read `references/citation-cleanup.md` when source text contains AI citation112 handles, private-use marker characters, broken bibliography tokens, or113 generated reference placeholders.114- Read `references/checklists.md` before final PDF QA.115- Read `references/source-notes.md` only when you need provenance for why this116 skill avoids host-specific assumptions.