Install
openclaw skills install @wang-shuanglin/docx-report-figuresAdd data-grounded tables and figures to an existing Chinese/English research report or paper in DOCX, keeping every number traceable to the source text. Use when the user uploads a .docx report and asks to 补充图表 / 插入表格 / 配图 / 数据可视化 / "看看哪里可以加图表", or asks to turn passages with statistics into 三线表 or matplotlib charts. Covers planning which passages deserve exhibits, designing three-line tables, drawing publication-style charts with exact values from the text, inserting captions/notes/in-text references, and verifying pagination. Do NOT use for rewriting text or for generating illustrative photos (that is an image-generation task).
openclaw skills install @wang-shuanglin/docx-report-figuresInsert tables and data figures into an existing report without altering its text, so that every number in every exhibit can be traced back to a sentence in the report. The deliverable is the original document plus exhibits, not a rewritten document.
(见表1), inserted before the final 。 of the paragraph that the exhibit supports.python scripts/extract_report.py report.docx --out dump.txt
Read the dump (paragraph index, style, text; page setup; existing tables and images). Read the whole report before planning anything — the exhibits must follow the argument, not decorate it.
python scripts/inspect_format.py report.docx --out format.txt
Record: page size and margins, usable text width, body font/size/line spacing/first-line indent, how section headings are formatted, how existing figure captions look, whether a table style exists. All inserted content must match these numbers.
Walk the report section by section and list candidate passages that contain: multi-country or multi-year comparisons, quantitative targets vs. actuals, price/tariff structures, capacity or grid statistics, financing terms, or a mechanism described as a chain/cycle. For each candidate decide:
Write the plan as JSON (schema in references/plan-schema.md), and for each exhibit keep a one-line provenance note: 表1 ← P4“23%…15.75%…15.63 GW…4.37 万 MW…”. If you cannot cite the source paragraph, drop the exhibit.
Copy every anchor character-for-character out of dump.txt. Do not retype it and do not add spaces: Chinese reports usually write 截至2025年6月底, and the gap you see on screen is Word's automatic CJK–Latin spacing, not a space. A wrong anchor aborts the build.
Charts go to figs/, width exactly the usable text width (typically 14.5 cm ≈ 5.71 in at 1× scale), matplotlib rcParams with a Times New Roman + SimSun fallback so digits and Chinese both look right. Follow references/sci-report-style.md for sizes, colors, axis and label conventions. Compute derived values in the script and print them, so the numbers in the note can be checked.
python scripts/build_figures.py plan.json
The builder copies the source file, inserts in-text references, then each table (caption above, three-line borders, 9 pt body, header repeat, rows that do not split) and each figure (image + caption below + 9 pt note), and finally normalizes oversized legacy images to the text width when asked. It never edits existing text.
Export a PDF (Word COM on Windows, else soffice --convert-to pdf) and render pages:
# Windows + Word
powershell -File scripts/export_pdf.ps1 -Source preview.docx -Pdf preview.pdf
python scripts/verify_layout.py preview.pdf --pages-dir pages --out pages.txt
Then look at the page images for every exhibit: caption on the same page as its table/figure, table not split across pages, no overlong cell wraps (country names must not break mid-word), no text overlapping in charts, numbering in order, references present. Fix and rebuild until clean. Do not deliver unseen output.
Deliver the DOCX and a PDF preview. List each exhibit with its number, placement, and the paragraph values it came from; call out every derived number and its arithmetic. State what you did not add (e.g. no generative photos for data) and why.
| Script | Purpose |
|---|---|
scripts/extract_report.py | Dump indexed paragraphs, sections, tables, images, page setup to a UTF-8 text file |
scripts/inspect_format.py | Report fonts, spacing, indents, caption style, table borders, image widths |
scripts/build_figures.py | Apply a JSON plan: refs, tables, figures |
scripts/fig_style.py | matplotlib publication style, palette, save(), value labels |
scripts/verify_layout.py | Render PDF pages to PNG and map captions to pages |
scripts/export_pdf.ps1 | Windows: Word COM export to PDF (tolerates the Close() RPC error) |
references/plan-schema.md — JSON plan format with a complete examplereferences/sci-report-style.md — table/figure typography, chart design, caption and note wording