科研 Skill
Markdown文档渲染为PDF
render-pdf-doc
Renders a Markdown document to PDF via pandoc and xelatex with CJK fonts. Use when a proposal or cover letter needs PDF layout without a bibliography.
SKILL.md
Render-PDF-Doc Skill
This skill handles layout only (CJK fonts, table column widths) with raw pandoc + xelatex — no
Quarto, whose tbl-colwidths has reported PDF regressions (issues 6089/9200). Not for: a
manuscript with a bibliography (/manage-refs scripts/render_pandoc.sh), an institutional .docx
form (/fill-protocol), the ICMJE COI form (/fill-icmje-coi), figures or PPTX (/make-figures,
/present-paper).
Dependencies
Python 3 is required by the wrapper. FontTools is optional for the font-file
coverage check (python3 -m pip install fonttools).
# macOS
brew install pandoc
brew install --cask mactex-no-gui # xelatex + xeCJK (~5 GB)
# Linux
sudo apt-get install pandoc texlive-xetex texlive-lang-cjk fonts-noto-cjk
# Windows (PowerShell) — run in Git Bash afterwards
winget install --id JohnMacFarlane.Pandoc
winget install --id MiKTeX.MiKTeX # xelatex; installs missing LaTeX packages on demand
# No CJK font download needed: Malgun Gothic ships with Windows 7+ and is the default here.
Detection:
bash scripts/check_deps.sh
On Windows / Git Bash, MiKTeX's bin directory
(%LOCALAPPDATA%\Programs\MiKTeX\miktex\bin\x64) is often not on PATH; both check_deps.sh
and render_pdf.sh probe it. If xelatex still reads [MISS], add that directory to PATH.
Workflow
Step 1 — Author markdown with frontmatter
---
title: "Paper 2 Calibration Anchor — Q&A Grid"
author: "<Author Group>"
date: "2026-05-01"
mainfont: "Apple SD Gothic Neo" # macOS default
CJKmainfont: "Apple SD Gothic Neo"
geometry: "margin=0.85in"
fontsize: 11pt
linestretch: 1.25
colorlinks: true
---
- Set both
mainfontandCJKmainfont: withoutCJKmainfont, Hangul falls back to Times New Roman (broken glyphs or blanks). UseNoto Sans CJK KRon Linux/CI andMalgun Gothicon Windows; the render script auto-detects the per-OS default when the fields are absent. - Read every number in a table from the source CSV or analysis output. Do not retype a number from prose or carry one forward from an earlier draft — a table correct in v3 is not evidence it is correct in v4.
- A circulation PDF carries no change history, internal version numbers (e.g. v3.2.2) or PI
attribution: put them in a separate circulation file or a supplementary. Keep the received
primary source (the
.docxor.emla co-author sent) unmodified as its own artifact — the PDF is a derivative, and the next round is diffed against the source. If that source was AI-drafted by a collaborator, re-derive every number, denominator and author-year in it from the underlying paper or analysis output before it reaches the PDF.
Step 2 — Infer column widths
Never split pipe-table columns equally: a column holding only short labels then gets the same width as the data columns, which cramps them. Size from content instead:
python3 scripts/infer_colwidths.py input.md > input.colwidths.md
For each pipe table it computes per-column display width = max(len(header), max(len(cell)))
(CJK = 2 cells, ASCII = 1) and rewrites the separator row with proportional dash counts. To set
widths by hand, write the separator dashes yourself and render without --infer-colwidths.
Step 3 — Render
bash scripts/render_pdf.sh -i input.colwidths.md -o output.pdf
Or one-shot:
bash scripts/render_pdf.sh -i input.md -o output.pdf --infer-colwidths
Frontmatter wins over wrapper defaults, including --font / --cjk-font.
Missing fields use the wrapper or OS defaults. This also applies to geometry,
fontsize, linestretch and colorlinks (including false). Explicit pandoc
-V / -M arguments after -- still override frontmatter; for example,
-- -V fontsize=10pt. The wrapper logs font fallbacks, not the final fonts.
The standard article class honours only 10pt, 11pt and 12pt and silently
ignores any other size. When the effective fontsize is anything else and no
documentclass is set, the wrapper switches to KOMA-Script scrartcl (pandoc's
documented route), adds classoption: fontsize=<size> when you set no
classoption (KOMA reads a fractional size such as 8.5pt only that way), and
logs the switch. Set documentclass yourself to override it.
xeCJK's defaults are set for Chinese: they delete the space after curly quotes and en/em dashes, and insert one wherever Latin letters or digits meet Hangul:
typed: “no difference” and AI를 썼다 3개
printed: “no difference”and AI 를 썼다 3 개
The wrapper turns both off (scripts/xecjk_korean.tex) so the PDF keeps the spaces you typed. It is
appended to your header-includes; if you pass -H after -- (which replaces
header-includes), the file is added as one more -H. Headers given another way (a --defaults
file with include-in-header, or -V header-includes=...) override the appended one, so pass
-H "scripts/xecjk_korean.tex" alongside them. --xecjk-defaults keeps
xeCJK's own spacing, e.g. for Chinese or Japanese text. Check with
pdftotext -layout out.pdf - | grep -cE '[”’][A-Za-z]' (0 apart from possessives).
Step 3.5 — Scientific-symbol + CJK glyph scan (before render)
xelatex can finish successfully with missing glyphs. render_pdf.sh counts the
Missing character warnings pandoc relays: if there are any, it lists each glyph
(code point, count, font) and exits 4 — the PDF is written but incomplete. It reads them from
pandoc's JSON --log (yours if you pass one after --), so a pass-through --quiet does not
hide them.
--allow-missing-glyphs prints the same list and exits 0. Academic markdown
routinely carries glyphs a default Latin font misses: transition arrows (→ ↑ ↓),
math operators (− ≤ ≥ ± √ ∪ × ≈ ≠), stats Greek (κ μ σ β), bullets/marks (• ★ ✓),
and CJK. Scan the source first so a silent drop is caught before it ships:
python3 scripts/scan_glyph_coverage.py input.md --strict
# real cmap check when you have the font file + fonttools:
python3 scripts/scan_glyph_coverage.py input.md --font "/path/to/body.otf" --strict
# TTC/OTC collections require the zero-based face index used by the renderer:
python3 scripts/scan_glyph_coverage.py input.md --font "/path/to/body.ttc" --font-index 0 --strict --json glyphs.json
Without --font it groups the risky glyphs by class (advisory); with --font + fonttools it
checks every non-ASCII character of the source that the font is asked to draw — not only the
five classes, so °, µ, ², ‰, ∞ and – are covered too — and reports which are absent
from one face's preferred Unicode cmap (format characters such as a BOM or zero-width joiner, and
the no-break spaces and … that pandoc writes as ASCII TeX, are not looked up), never combining coverage across
collection faces — choose the face (index and PostScript name are in the report) that matches the
rendered font. A missing dependency, unreadable font, missing face selection or invalid index is
reported as font_checked: false with a reason in font_check; an empty missing_in_font list
then means unverified, not full coverage. Default mode exits 0; --strict exits 1 when risky
glyphs are unverified or missing (ASCII-only input still exits 0). The scan does not verify
shaping, fallback fonts, math fonts or final PDF glyphs.
If risky glyphs are present, make sure mainfont/CJKmainfont cover them — a CJK-capable font
such as Apple SD Gothic Neo / Noto Sans CJK usually covers arrows and Hangul but can still
miss the true-minus − U+2212 and ★. The DOCX is authoritative; the PDF is a convenience
copy — never let a PDF render drop a glyph the document needs.
Step 4 — Visual verify
Open the PDF and check:
- First-column labels stay on one line; data columns have enough width.
- No broken Korean glyphs (a Times New Roman fallback means
CJKmainfontwas not applied). - No missing scientific symbols (arrows, −, ≤, ±, √) — the Step 3.5 scan flags candidates.
- No change history or internal version numbers exposed.
Read references/known_pitfalls.md when a render still looks wrong (em-dash overflow, smart
quotes under CJKmainfont, | inside a cell), and references/pandoc_korean_cheatsheet.md for
Korean frontmatter and font patterns.
Templates
Starter markdown in templates/ (English default; a Korean variant *_ko.md ships alongside
each), with slots marked <!-- TODO: -->:
anchor-doc.md— Q&A gridproposal-cover.md— research-proposal cover pagebriefing-handout.md— meeting brief (1-page)reference-table.md— comparison-table format
示例提示词
帮我把这份中文研究计划Markdown渲染成带表格的PDF。
所属插件
安装该插件会一并获得同领域的 58 个 Skill / MCP。
同插件的其他科研 Skill
- 医学AI论文检索优化Optimizes a medical AI paper’s title, abstract and metadata for AI search engines. Use when a paper should be findable and citable by RAG tools and AI search.
- 临床数据统计分析与建模Generates reproducible Python or R code for clinical statistics and tables. Use when collected data needs Table 1, regression, survival or agreement analysis.
- 作者发表记录与策略分析Analyzes a PubMed author record to classify study types and authorship patterns. Use when planning a publication strategy from a researcher’s track record.
- 批量队列暴露结局分析Generates one cohort-analysis script per exposure-outcome pair from one template. Use when a validated method must run across many variable combinations at once.
- 样本量估算与检验效能Walks a decision tree to the right test and computes sample size with IRB text. Use when planning how many patients a study needs before data collection.
- 因果推断方法设计Runs DAG-based, instrumental-variable, difference-in-differences or RD analyses. Use when an association in observational data must support a causal claim.
- 报告规范逐条核查Audits a manuscript item by item against 49 reporting and risk-of-bias checklists. Use when checking a draft against STROBE, CONSORT, TRIPOD or similar guidelines.
- 临床数据清洗与画像Profiles a clinical dataset and generates cleaning code in staged, approved steps. Use when a CSV or Excel dataset needs missing-value and outlier checks before analysis.
- 跨国队列数据协调对比Harmonizes variables and runs parallel weighted analyses across national surveys like KNHANES and NHANES. Use when comparing one exposure-outcome link across countries.
- 变量定义与截断值溯源Maps exposure, outcome and covariate definitions to a cited guideline and DB columns. Use when variable cutoffs need a citable basis before the study protocol.
- 本地化临床数据脱敏Runs a local, network-free script that detects and removes identifiers from clinical data. Use when data may contain PHI and must be de-identified before LLM analysis.
- AI对标专家基准研究设计Plans the arms, rubrics, calibration probes and reviewer panel for an AI-vs-expert benchmark. Use before data collection when designing an AI-vs-human rating study.
- 放射影像AI研究设计审查Reviews a study’s analysis unit, cohort logic, leakage risk and reporting-guideline fit. Use when checking a clinical or medical-AI study design before drafting.
- 传染病仓室模型拟合Builds and fits SIR, SEIR and SEIHR compartmental models with Rt estimation. Use when an outbreak or epidemic’s spread needs mathematical modeling in Python.
- ICMJE利益冲突声明填写Clones a pre-filled synthetic ICMJE COI form, replacing only date, name and title. Use when each author on a submission needs a disclosure form filled quickly.
- 机构Word表单内容填充Fills an institutional Word form, such as an IRB protocol, without breaking its layout. Use when drafted content must be rendered into a CJK-aware .docx template.
- 队列数据库选题挖掘Profiles a longitudinal cohort database and ranks research-topic proposals with gap evidence. Use when looking for a question an available cohort or registry can answer.
- 投稿期刊匹配推荐Matches a manuscript abstract against curated journal profiles and ranks candidates. Use when choosing where to submit, or re-targeting after a rejection.
- DOI全文批量获取Batch-downloads open-access PDFs for a list of DOIs via Unpaywall, PMC and OpenAlex. Use when full texts are needed for a screening set such as a meta-analysis.
- 数据集编码本自动生成Profiles every variable in a tabular dataset into a structured, citable codebook. Use when a CSV, Excel or Stata dataset needs a data dictionary before analysis.
- 全球卫生数据获取分析Accesses and analyzes global health data from WHO GHO, IHME GBD and Our World in Data. Use when DALYs, age-standardized rates or choropleth maps are needed.
- 医学AI项目基金申请书撰写Structures a grant proposal’s significance, innovation, approach, aims and milestones. Use when drafting a research funding proposal, including a Korean grant plan.
- 卫生经济学评价建模Builds Markov cohort models with QALYs, PSA and cost-effectiveness planes. Use when a health intervention needs a formal cost-effectiveness evaluation.
- AI写作痕迹识别改写Scans a manuscript for AI writing patterns and rewrites flagged passages carefully. Use when a draft or response letter reads as obviously AI-written.
常见问题
Markdown文档渲染为PDF能做什么?
Renders a Markdown document to PDF via pandoc and xelatex with CJK fonts. Use when a proposal or cover letter needs PDF layout without a bibliography。
如何安装Markdown文档渲染为PDF?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「Markdown文档渲染为PDF」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
Markdown文档渲染为PDF需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
Markdown文档渲染为PDF经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。