papper 0.6.6__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. pandoc_manuscript/__init__.py +49 -0
  2. pandoc_manuscript/_template/.agents/bib-metadata-rebuild/SKILL.md +228 -0
  3. pandoc_manuscript/_template/.agents/manuscript-review/SKILL.md +114 -0
  4. pandoc_manuscript/_template/.agents/manuscript-syntax.md +659 -0
  5. pandoc_manuscript/_template/.agents/reviewer-guided-manuscript-revision/SKILL.md +100 -0
  6. pandoc_manuscript/_template/.agents/reviewer-reply-writing/SKILL.md +203 -0
  7. pandoc_manuscript/_template/.agents/word-manuscript-fix/SKILL.md +36 -0
  8. pandoc_manuscript/_template/.agents/word-manuscript-fix/scripts/unescape_latex.py +87 -0
  9. pandoc_manuscript/_template/.agents//321/204/342/225/225/320/220/321/204/342/225/221/320/253/321/205/342/225/225/342/225/225/321/207/320/244/320/270/321/207/320/252/320/224/321/206/320/237/320/240/321/207/320/264/342/225/221/321/210/320/277/320/235/321/207/320/231/320/227/321/206/320/276/342/225/241.md +125 -0
  10. pandoc_manuscript/_template/.gitignore +254 -0
  11. pandoc_manuscript/_template/.vscode/extensions.json +5 -0
  12. pandoc_manuscript/_template/AGENTS.md +128 -0
  13. pandoc_manuscript/_template/CLAUDE.md +104 -0
  14. pandoc_manuscript/_template/examples/images/example.svg +87 -0
  15. pandoc_manuscript/_template/examples/images/single-figure-example.png +0 -0
  16. pandoc_manuscript/_template/examples/images/subfigure-a-example.png +0 -0
  17. pandoc_manuscript/_template/examples/images/subfigure-b-example.png +0 -0
  18. pandoc_manuscript/_template/examples/images/subfigure-svg-layout-example.svg +30 -0
  19. pandoc_manuscript/_template/examples/references/paper-specific-example.bib +889 -0
  20. pandoc_manuscript/_template/examples/references/sample-references.bib +76 -0
  21. pandoc_manuscript/_template/manuscript.md +217 -0
  22. pandoc_manuscript/_template/reply_to_reviewers.md +243 -0
  23. pandoc_manuscript/_template/style.yml +106 -0
  24. pandoc_manuscript/cli.py +93 -0
  25. pandoc_manuscript/commands/__init__.py +1 -0
  26. pandoc_manuscript/commands/build.py +713 -0
  27. pandoc_manuscript/commands/build_reply/__init__.py +115 -0
  28. pandoc_manuscript/commands/build_reply/command.py +78 -0
  29. pandoc_manuscript/commands/build_reply/line_source.py +542 -0
  30. pandoc_manuscript/commands/build_reply/output.py +346 -0
  31. pandoc_manuscript/commands/build_reply/resolve.py +724 -0
  32. pandoc_manuscript/commands/build_reply/settings.py +75 -0
  33. pandoc_manuscript/commands/clean.py +112 -0
  34. pandoc_manuscript/commands/common.py +119 -0
  35. pandoc_manuscript/commands/doctor.py +87 -0
  36. pandoc_manuscript/commands/init.py +186 -0
  37. pandoc_manuscript/commands/setup/__init__.py +21 -0
  38. pandoc_manuscript/commands/setup/command.py +33 -0
  39. pandoc_manuscript/commands/setup/pandoc_tools.py +503 -0
  40. pandoc_manuscript/docx/__init__.py +1 -0
  41. pandoc_manuscript/docx/compare_word_com.py +720 -0
  42. pandoc_manuscript/docx/equation_layout.py +146 -0
  43. pandoc_manuscript/docx/page_margins.py +139 -0
  44. pandoc_manuscript/docx/postprocess/__init__.py +5 -0
  45. pandoc_manuscript/docx/postprocess/autofit_tables.py +252 -0
  46. pandoc_manuscript/docx/postprocess/clear_subfigure_table_format.py +199 -0
  47. pandoc_manuscript/docx/postprocess/common.py +157 -0
  48. pandoc_manuscript/docx/postprocess/docx_style.py +591 -0
  49. pandoc_manuscript/docx/postprocess/final_docx_syntax_check.py +234 -0
  50. pandoc_manuscript/docx/postprocess/format_equation_layout_tables.py +473 -0
  51. pandoc_manuscript/docx/postprocess/inline_math_spacing.py +139 -0
  52. pandoc_manuscript/docx/postprocess/insert_author_info.py +540 -0
  53. pandoc_manuscript/docx/postprocess/line_numbers.py +183 -0
  54. pandoc_manuscript/docx/postprocess/merge_table_cells.py +223 -0
  55. pandoc_manuscript/docx/postprocess/orchestrator.py +376 -0
  56. pandoc_manuscript/docx/postprocess/page_margins.py +64 -0
  57. pandoc_manuscript/docx/postprocess/page_numbers.py +182 -0
  58. pandoc_manuscript/docx/postprocess/para_after_table_style.py +162 -0
  59. pandoc_manuscript/docx/postprocess/para_equation_style.py +155 -0
  60. pandoc_manuscript/docx/postprocess/process_equation_metadata.py +176 -0
  61. pandoc_manuscript/docx/postprocess/process_table_metadata.py +547 -0
  62. pandoc_manuscript/docx/postprocess/reply_blue_italic_style.py +168 -0
  63. pandoc_manuscript/docx/postprocess/table_text_style.py +253 -0
  64. pandoc_manuscript/docx/postprocess/where_paragraph_style.py +277 -0
  65. pandoc_manuscript/docx/svg_filters.py +160 -0
  66. pandoc_manuscript/mathtype/Times+Symbol 12.eqp +58 -0
  67. pandoc_manuscript/mathtype/__init__.py +1 -0
  68. pandoc_manuscript/mathtype/bin/MITEX-APACHE-2.0.txt +176 -0
  69. pandoc_manuscript/mathtype/bin/XITS-NOTICE.txt +14 -0
  70. pandoc_manuscript/mathtype/bin/XITS-OFL.txt +98 -0
  71. pandoc_manuscript/mathtype/bin/XITS-README.txt +15 -0
  72. pandoc_manuscript/mathtype/bin/mathtype_rust.dll +4 -0
  73. pandoc_manuscript/mathtype/compound_file.py +123 -0
  74. pandoc_manuscript/mathtype/convert_marked_docx.py +68 -0
  75. pandoc_manuscript/mathtype/docx_ole.py +405 -0
  76. pandoc_manuscript/mathtype/marked_docx.py +460 -0
  77. pandoc_manuscript/mathtype/native.py +121 -0
  78. pandoc_manuscript/mathtype/ole_helper/bin/Release/net48/MathTypeOleHelper.exe +0 -0
  79. pandoc_manuscript/mathtype/ole_parts.py +1444 -0
  80. pandoc_manuscript/mathtype/preflight.py +94 -0
  81. pandoc_manuscript/mathtype/probe_replace.py +46 -0
  82. pandoc_manuscript/pandoc/csl/elsevier-vancouver.csl +169 -0
  83. pandoc_manuscript/pandoc/csl/engineering-applications-of-artificial-intelligence.csl +14 -0
  84. pandoc_manuscript/pandoc/csl/sage-vancouver-brackets.csl +210 -0
  85. pandoc_manuscript/pandoc/csl/sage-vancouver.csl +203 -0
  86. pandoc_manuscript/pandoc/filters/captionless_image_style.lua +51 -0
  87. pandoc_manuscript/pandoc/filters/citation_number_range_delimiter.lua +118 -0
  88. pandoc_manuscript/pandoc/filters/docx_metadata.lua +148 -0
  89. pandoc_manuscript/pandoc/filters/emf_to_pdf.py +26 -0
  90. pandoc_manuscript/pandoc/filters/equation_revision_attr.lua +94 -0
  91. pandoc_manuscript/pandoc/filters/italic_to_emphasis_style.lua +11 -0
  92. pandoc_manuscript/pandoc/filters/mathtype_markers.lua +67 -0
  93. pandoc_manuscript/pandoc/filters/path_filter.py +176 -0
  94. pandoc_manuscript/pandoc/filters/resource_move.py +140 -0
  95. pandoc_manuscript/pandoc/filters/svg_embed_images.py +416 -0
  96. pandoc_manuscript/pandoc/filters/svg_to_png.py +582 -0
  97. pandoc_manuscript/pandoc/filters/table_convert.py +501 -0
  98. pandoc_manuscript/pandoc/filters/to_mathbfit.py +90 -0
  99. pandoc_manuscript/pandoc/manuscript-template/.github/workflows/update-pandoc-reference.yml +53 -0
  100. pandoc_manuscript/pandoc/manuscript-template/.gitignore +2 -0
  101. pandoc_manuscript/pandoc/manuscript-template/COPYING +339 -0
  102. pandoc_manuscript/pandoc/manuscript-template/README.md +1 -0
  103. pandoc_manuscript/pandoc/manuscript-template/apply-reference-doc-edits.ps1 +82 -0
  104. pandoc_manuscript/pandoc/manuscript-template/compile.ps1 +49 -0
  105. pandoc_manuscript/pandoc/manuscript-template/edit-reference-doc.ps1 +51 -0
  106. pandoc_manuscript/pandoc/manuscript-template/format-openxml.ps1 +128 -0
  107. pandoc_manuscript/pandoc/manuscript-template/reference-doc/[Content_Types].xml +17 -0
  108. pandoc_manuscript/pandoc/manuscript-template/reference-doc/_rels/.rels +7 -0
  109. pandoc_manuscript/pandoc/manuscript-template/reference-doc/docProps/app.xml +20 -0
  110. pandoc_manuscript/pandoc/manuscript-template/reference-doc/docProps/core.xml +13 -0
  111. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/_rels/document.xml.rels +13 -0
  112. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/document.xml +546 -0
  113. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/endnotes.xml +59 -0
  114. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/fontTable.xml +73 -0
  115. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/footnotes.xml +77 -0
  116. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/numbering.xml +266 -0
  117. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/settings.xml +51 -0
  118. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/styles.xml +1070 -0
  119. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/theme/theme1.xml +294 -0
  120. pandoc_manuscript/pandoc/manuscript-template/reference-doc/word/webSettings.xml +17 -0
  121. pandoc_manuscript/pandoc/manuscript-template/reference-doc.docx +0 -0
  122. pandoc_manuscript/pandoc/manuscript-template/template.openxml +85 -0
  123. pandoc_manuscript/pandoc/pandoc-docx.yml +24 -0
  124. pandoc_manuscript/pandoc/pandoc-latex.yml +19 -0
  125. pandoc_manuscript/pandoc/templates/common.latex +263 -0
  126. pandoc_manuscript/pandoc/templates/default.latex +145 -0
  127. pandoc_manuscript/pandoc/templates/default.xml +80 -0
  128. pandoc_manuscript/pandoc/templates/fonts.latex +1 -0
  129. pandoc_manuscript/pandoc/templates-elsewier/default.xml +80 -0
  130. pandoc_manuscript/pandoc/templates-willy/common.latex +263 -0
  131. pandoc_manuscript/pandoc/templates-willy/default.latex +145 -0
  132. pandoc_manuscript/pandoc/templates-willy/fonts.latex +1 -0
  133. pandoc_manuscript/runtime/__init__.py +1 -0
  134. pandoc_manuscript/runtime/logging.py +161 -0
  135. pandoc_manuscript/runtime/metadata.py +564 -0
  136. pandoc_manuscript/runtime/paths.py +27 -0
  137. pandoc_manuscript/runtime/resources.py +68 -0
  138. pandoc_manuscript/runtime/update_check.py +208 -0
  139. papper-0.6.6.dist-info/METADATA +364 -0
  140. papper-0.6.6.dist-info/RECORD +143 -0
  141. papper-0.6.6.dist-info/WHEEL +4 -0
  142. papper-0.6.6.dist-info/entry_points.txt +3 -0
  143. papper-0.6.6.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,659 @@
1
+ # Manuscript Syntax
2
+
3
+ This document separates manuscript content syntax from style metadata. Use the
4
+ `Manuscript Syntax` section for content written in `manuscript.md`, and the
5
+ `Style Metadata` section for style-related defaults in `style.yml`.
6
+
7
+ ## Author Metadata
8
+
9
+ The DOCX post-processing step reads author information from the YAML header in `manuscript.md` and inserts formatted author names, affiliations, and the corresponding-author footnote after the title. Use `authors` as the preferred field name. The singular alias `author` is also accepted by the post-processor for compatibility.
10
+
11
+ Each author must be written as a YAML mapping with at least a `name` field. Optional fields are:
12
+
13
+ - `affiliation`: A single affiliation key or a single inline affiliation string.
14
+ - `affiliations`: One affiliation key/string or a list of affiliation keys/strings.
15
+ - `email`: Used in the generated corresponding-author footnote.
16
+ - `title`: Added in parentheses in the generated corresponding-author footnote.
17
+ - `corresponding`: Use `true` to generate the default correspondence footnote, or provide a string to use as the complete footnote text.
18
+
19
+ Affiliations can be written inline under each author, or defined once in a top-level `affiliations` map and then referenced by key. The singular top-level alias `affiliation` is also accepted when using keyed affiliations.
20
+
21
+ ### Format 1: Inline Single Affiliation
22
+
23
+ This is the simplest format and matches the default `manuscript.md` template:
24
+
25
+ ```yaml
26
+ authors:
27
+ - name: First Author
28
+ email: first.author@university.edu
29
+ affiliation: Department of Example, University Name, City, Country
30
+
31
+ - name: Second Author
32
+ email: second.author@university.edu
33
+ affiliation: Department of Example, University Name, City, Country
34
+ corresponding: true
35
+ ```
36
+
37
+ ### Format 2: Inline Multiple Affiliations
38
+
39
+ Use `affiliations` as a list when an author has more than one affiliation. Repeated affiliation text is automatically assigned the same superscript label.
40
+
41
+ ```yaml
42
+ authors:
43
+ - name: First Author
44
+ affiliations:
45
+ - Department of Example, University Name, City, Country
46
+ - Research Center, Institute Name, City, Country
47
+
48
+ - name: Second Author
49
+ affiliations:
50
+ - Department of Example, University Name, City, Country
51
+ - Research Center, Institute Name, City, Country
52
+ corresponding: true
53
+ email: second.author@university.edu
54
+ ```
55
+
56
+ ### Format 3: Keyed Affiliations
57
+
58
+ Use a top-level `affiliations` map when several authors share the same institutions. Author entries can reference one key with `affiliation`, or several keys with `affiliations`.
59
+
60
+ ```yaml
61
+ authors:
62
+ - name: First Author
63
+ affiliations: [a, b]
64
+
65
+ - name: Second Author
66
+ affiliation: a
67
+ corresponding: true
68
+ email: second.author@university.edu
69
+ title: Professor
70
+
71
+ affiliations:
72
+ a: Department of Example, University Name, City, Country
73
+ b: Research Center, Institute Name, City, Country
74
+ ```
75
+
76
+ ### Format 4: Custom Corresponding-Author Footnote
77
+
78
+ Set `corresponding` to a string when the journal requires custom wording. The string is used as the complete footnote text.
79
+
80
+ ```yaml
81
+ authors:
82
+ - name: First Author
83
+ affiliation: a
84
+
85
+ - name: Second Author
86
+ affiliation: a
87
+ corresponding: "Correspondence concerning this article should be addressed to Second Author, Department of Example, University Name. Email: second.author@university.edu."
88
+
89
+ affiliations:
90
+ a: Department of Example, University Name, City, Country
91
+ ```
92
+
93
+ Avoid Pandoc's compact string-only author syntax, such as `author: [First Author, Second Author]`, when you need this template's DOCX author formatting. The post-processing script expects each author to be a mapping so it can read affiliations and correspondence metadata.
94
+
95
+ ## Optional LaTeX Source Configuration
96
+
97
+ The primary workflow is DOCX generation. If you also generate LaTeX source, you can edit the YAML header in `manuscript.md` for document-class-specific output:
98
+
99
+ ### Example 1: Elsevier Journal
100
+
101
+ Uncomment and customize this section in `manuscript.md`:
102
+
103
+ ````yaml
104
+ documentclass: elsarticle
105
+ classoption: [preprint, 3p, authoryear]
106
+ header-includes:
107
+ - |
108
+ ```{=latex}
109
+ \journal{Journal of Example Research}
110
+ ```
111
+ ````
112
+
113
+ ### Example 2: Springer Journal
114
+
115
+ ```yaml
116
+ documentclass: svjour3
117
+ classoption: [smallextended]
118
+ ```
119
+
120
+ ### Example 3: Wiley Journal (e.g., Computer-Aided Civil Engineering)
121
+
122
+ ````yaml
123
+ documentclass: WileyNJDv5
124
+ classoption: [HARVARD, Times2COL]
125
+ header-includes:
126
+ - |
127
+ ```{=latex}
128
+ \journal{Comput Aided Civ Inf.}
129
+ \volume{00}
130
+ \copyyear{2025}
131
+ \startpage{1}
132
+ \articletype{RESEARCH ARTICLE}
133
+ ```
134
+ ````
135
+
136
+ ### Example 4: IEEE Journal
137
+
138
+ ```yaml
139
+ documentclass: IEEEtran
140
+ classoption: [journal]
141
+ ```
142
+
143
+ ## Cross-References
144
+
145
+ The template uses [pandoc-crossref](https://github.com/lierdakil/pandoc-crossref) for automatic numbering:
146
+
147
+ - **Figures**: `![Caption](image.png){#fig:label}` -> Reference with `@fig:label`
148
+ - **Tables**: `Table: Caption {#tbl:label}` -> Reference with `@tbl:label`
149
+ - **Equations**: `$$ equation $$ {#eq:label}` -> Reference with `@eq:label`
150
+ - **Sections**: `# Section {#sec:label}` -> Reference with `@sec:label`
151
+
152
+ Example:
153
+ ```markdown
154
+ See @fig:results for details. As shown in @tbl:comparison and @eq:model...
155
+ ```
156
+
157
+ When a formula needs both `\hat{...}` and a style macro such as `\mathbf{...}`,
158
+ write the hat inside the style macro, for example `\mathbf{\hat{C}}` rather
159
+ than `\hat{\mathbf{C}}`. When a DOCX build actually starts MathType conversion,
160
+ `papper build` and `papper build-reply` warn about the latter form because
161
+ MathType-exported PDFs may hide the hat.
162
+
163
+ Set `mathtypeConversionMethod` in `style.yml` to choose the MathType backend:
164
+ `rust` is cross-platform and combines LaTeX -> `mathtype-rust` -> OLE/MTEF
165
+ with LaTeX -> SVG -> `latex2wmf` -> WMF/JSON. `set-data` uses MathType's
166
+ Windows-only TeX input OLE path. `rust-sdk` preserves the older two-stage path:
167
+ `mathtype-rust` generates OLE/MTEF, then the prebuilt MathType helper runs
168
+ `sdk-xform-ole` to generate WMF/JSON. On Windows, when MathType is available,
169
+ `auto` tries `set-data`, then `rust-sdk`, then `rust`; if MathType is unavailable,
170
+ it uses `rust` directly. On non-Windows systems, `auto` always uses `rust`. The
171
+ `both` mode is Windows-only: it generates the `rust` and `set-data` backends,
172
+ compares only the MTEF formula data streams extracted from OLE and warns if they differ.
173
+ WMF previews and JSON metadata are excluded from comparison. The DOCX uses the
174
+ `set-data` output. Runtime
175
+ conversion never builds the .NET helper; Windows wheels contain its executable.
176
+
177
+ Set `mathtypeSvgBackend` to choose how the cross-platform `rust` path produces
178
+ formula SVG. `ratex` (the default) parses LaTeX directly, embeds glyph outlines,
179
+ and reports its exact layout depth for Word baseline placement. `typst` converts
180
+ LaTeX math with the pinned MiTeX 0.2.7 Rust converter and evaluates it against
181
+ the matching complete official MiTeX Typst scope embedded in the executable.
182
+ It renders the result with the bundled XITS Math font,
183
+ reads the labelled formula frame's actual descent before page composition drops
184
+ child baselines, and expands the transparent canvas to include glyph ink that
185
+ overhangs that frame. Both backends reject SVG features outside the formula vector
186
+ subset instead of silently rasterizing them.
187
+ `pmt` also preserves whether Pandoc marked each formula as inline or display:
188
+ RaTeX uses text style for inline formulas and display style for display formulas,
189
+ so fractions, large operators, and limits keep the layout expected in prose.
190
+ The RaTeX path treats `0.02em` as the minimum safety margin for glyph overshoot.
191
+ It expands only transparent canvas space until the width and both baseline-side
192
+ extents land on Word's half-point grid; the Typst path starts with the same rule.
193
+ After Typst's adaptive WMF clipping protection, inline previews receive any
194
+ remaining bottom whitespace needed to put the final baseline depth back on that
195
+ grid. Formula paths are not moved, rescaled, or trimmed by this final step, so
196
+ Word's run position needs no rounding compensation. Display previews skip it.
197
+
198
+ ## Subfigure Layouts
199
+
200
+ For most multi-panel figures, prefer creating one SVG layout file that
201
+ references the child image files. The Markdown manuscript then inserts that SVG
202
+ as a normal figure. This approach makes the final layout explicit: panel
203
+ positions, labels such as `(a)` and `(b)`, and shared spacing are controlled in
204
+ one editable source file rather than inferred from a Word table layout.
205
+
206
+ Recommended file structure:
207
+
208
+ ```text
209
+ manuscript.md
210
+ figures/
211
+ model-comparison.svg
212
+ model-comparison-a.png
213
+ model-comparison-b.png
214
+ ```
215
+
216
+ Example SVG layout (`figures/model-comparison.svg`):
217
+
218
+ ```xml
219
+ <svg xmlns="http://www.w3.org/2000/svg"
220
+ xmlns:xlink="http://www.w3.org/1999/xlink"
221
+ width="160mm"
222
+ height="78mm"
223
+ viewBox="0 0 1600 780">
224
+ <style>
225
+ text {
226
+ font-family: Times New Roman, Times, serif;
227
+ font-size: 42px;
228
+ fill: #000000;
229
+ }
230
+ .panel-label {
231
+ font-weight: bold;
232
+ }
233
+ </style>
234
+
235
+ <rect x="0" y="0" width="1600" height="780" fill="#ffffff"/>
236
+
237
+ <image href="model-comparison-a.png"
238
+ xlink:href="model-comparison-a.png"
239
+ x="40" y="40" width="720" height="560"
240
+ preserveAspectRatio="xMidYMid meet"/>
241
+ <image href="model-comparison-b.png"
242
+ xlink:href="model-comparison-b.png"
243
+ x="840" y="40" width="720" height="560"
244
+ preserveAspectRatio="xMidYMid meet"/>
245
+
246
+ <text x="400" y="710" text-anchor="middle">(a) Baseline setting</text>
247
+ <text x="1200" y="710" text-anchor="middle">(b) Proposed setting</text>
248
+ </svg>
249
+ ```
250
+
251
+ Reference the composed layout from `manuscript.md` as one figure:
252
+
253
+ ```markdown
254
+ @fig:model-comparison compares the baseline setting with the proposed setting.
255
+
256
+ ![Comparison of baseline and proposed model behavior across two experimental settings.](figures/model-comparison.svg){#fig:model-comparison width=90%}
257
+ ```
258
+
259
+ Keep the child image paths in the SVG relative to the SVG file itself. In the
260
+ example above, `model-comparison-a.png` and `model-comparison-b.png` sit beside
261
+ `model-comparison.svg` under `figures/`. This is important for reproducible DOCX
262
+ builds because the SVG child-image embedding filter resolves local resources
263
+ from the SVG file location.
264
+
265
+ For DOCX builds that use linked child images inside SVG files, keep child-image
266
+ embedding enabled in `style.yml`:
267
+
268
+ ```yaml
269
+ docxEmbedSvgImages: true
270
+ ```
271
+
272
+ With this option, `papper build docx` converts local Markdown image references such
273
+ as `figures/model-comparison.svg` to cached self-contained SVG files under
274
+ `.pmt/cache/svg-embedded/`. The linked child panels are embedded into the cached
275
+ SVG as data URIs, while SVG text and vector elements remain SVG. The source
276
+ Markdown and SVG files are not rewritten. If `docxConvertSvgToPng: true` is
277
+ enabled, `docxEmbedSvgImages` is automatically disabled because the full SVG is
278
+ rasterized instead. If a linked child image is itself an SVG, the DOCX pipeline
279
+ automatically converts the composed parent SVG to PNG even when
280
+ `docxConvertSvgToPng` is false, because Word cannot render an SVG data URI nested
281
+ inside another SVG.
282
+
283
+ If one SVG must be rasterized for a specific submission target, add
284
+ `to-png=true` to that image. Add `to-png-scale=2` on the same image when it
285
+ needs a higher PNG scale than the global default. To rasterize every SVG image
286
+ in the DOCX build, enable the global option in `style.yml`. Use at most one
287
+ global sizing control: `docxSvgToPngWidth`, `docxSvgToPngDpi`, or
288
+ `docxSvgToPngScale`.
289
+
290
+ ```yaml
291
+ docxConvertSvgToPng: true
292
+ docxSvgToPngWidth: 1600
293
+ ```
294
+
295
+ This SVG-based pattern gives the composed figure one cross-reference label,
296
+ `@fig:model-comparison`. The panel markers `(a)` and `(b)` are visual labels
297
+ inside the SVG, not separate Pandoc figure labels. If the manuscript must cite
298
+ individual child panels with separate references such as `@fig:model-a` and
299
+ `@fig:model-b`, use the built-in `subfigGrid` form instead:
300
+
301
+ ```markdown
302
+ <div id="fig:model-comparison-grid">
303
+ ![Baseline setting.](figures/model-comparison-a.png){#fig:model-a width=49%}
304
+ ![Proposed setting.](figures/model-comparison-b.png){#fig:model-b width=49%}
305
+
306
+ Comparison of baseline and proposed model behavior.
307
+ </div>
308
+ ```
309
+
310
+ ## Marking Revisions in Red
311
+
312
+ Use Pandoc custom styles to mark substantive manuscript revisions in generated DOCX files. The default reference DOCX includes a character style named `Revision Char`, so revised inline text can be written as a bracketed span:
313
+
314
+ ```markdown
315
+ The proposed workflow improves [the adaptive sampling stage]{custom-style="Revision Char"} while keeping the original preprocessing steps unchanged.
316
+ ```
317
+
318
+ Recommended revision-marking rules:
319
+
320
+ - Use `Revision Char` only for modified or newly added words, phrases, sentences, or paragraphs that need to appear in red.
321
+ - Do not mark very small edits within one sentence, such as changes under three words.
322
+ - When old text is replaced, omit the deleted wording and mark only the new or modified surviving text.
323
+ - For heavily revised existing paragraphs, mark only the changed parts. Mark a whole paragraph only when the entire paragraph is newly added.
324
+ - Keep cross-reference tokens such as `@fig:result` or `@tbl:comparison` outside the styled span unless the reference text itself is substantively changed.
325
+
326
+ For a modified or newly added figure, mark the caption rather than the image path. Size-only figure changes do not need revision markup.
327
+
328
+ ```markdown
329
+ ![[Updated model comparison under the same evaluation protocol.]{custom-style="Revision Char"}](figures/model-comparison.png){#fig:model-comparison}
330
+ ```
331
+
332
+ For tables, use revision attributes on the table caption. Use `revision-rows="*"` for a newly added table. For a modified table, list changed or added 1-based row or column numbers with `revision-rows="..."` and `revision-columns="..."`; row numbers include the table header row.
333
+
334
+ ```markdown
335
+ | **Method** | **Accuracy (%)** | **Runtime (s)** |
336
+ |:----------:|:----------------:|:---------------:|
337
+ | Baseline | 78.3 | 12.4 |
338
+ | Proposed | 92.4 | 10.1 |
339
+
340
+ : Performance comparison. {#tbl:performance revision-columns="2,3" revision-rows="3"}
341
+ ```
342
+
343
+ The underscore forms `revision_rows` and `revision_columns` are equivalent and are documented with the other DOCX table attributes below.
344
+
345
+ For native Word display equations, add `revision=true` in the equation attribute list. `papper build docx` strips that custom attribute before `pandoc-crossref` runs, keeps labels such as `#eq:model`, and then colors the generated Word equation red during DOCX post-processing.
346
+
347
+ ```markdown
348
+ $$
349
+ \mathbf{y} = \mathbf{A}\mathbf{x} + \mathbf{b}
350
+ $$ {#eq:linear-model revision=true}
351
+ ```
352
+
353
+ This revision coloring currently targets native Word equations only. If the DOCX build later converts equations to MathType OLE objects, this equation-level red coloring is not preserved.
354
+
355
+ ## Writing Pseudocode
356
+
357
+ For method or workflow descriptions, the recommended pattern is to write pseudocode as a one-column pipe table. This format is easy to edit in Markdown and stays visually stable after DOCX conversion.
358
+
359
+ **Recommended conventions**:
360
+
361
+ - Use a bold first row for the algorithm title, for example `| **Algorithm: ...** |`.
362
+ - Use bold label rows such as `**Input:**`, `**Output:**`, and `**Step 1 ...:**` to separate major blocks.
363
+ - Put one operation in each table row so the procedure stays readable in both Markdown and DOCX.
364
+ - Write control keywords in bold, such as `**for**`, `**if**`, `**else**`, `**end for**`, and `**end if**`.
365
+ - Use inline math with `$...$` for symbols and variables, and use `@eq:label` when the pseudocode refers to numbered equations in the manuscript.
366
+ - Inside table cells, use escaped spaces such as `\ \ ` to show nesting. This is useful because ordinary leading spaces in Markdown tables may collapse during rendering.
367
+ - If line numbers are needed, prefix each operation row with `1.\ \`, `2.\ \`, and so on. For nested operations, add more escaped spaces after the line number, for example `4.\ \ \ \ Train ...`.
368
+
369
+ Example:
370
+
371
+ ```markdown
372
+ | **Algorithm: Library book borrowing workflow** |
373
+ |---|
374
+ | **Input:** |
375
+ | Borrow request list $R=\{r_i \mid i=1,\cdots,N\}$ and catalog records $C$ |
376
+ | **Output:** |
377
+ | Updated borrowing log $L$ |
378
+ | **Step 1 Validation:** |
379
+ | Read the next request $r_i$ and extract the member ID and book ID |
380
+ | Check whether the member account is active |
381
+ | **Step 2 Availability check:** |
382
+ | **for** each request $r_i$ in $R$ **do** |
383
+ | \ \ Search the catalog record for the requested book |
384
+ | \ \ **if** a copy is available **then** |
385
+ | \ \ \ \ Mark the copy as borrowed |
386
+ | \ \ \ \ Set the due date according to the lending policy |
387
+ | \ \ **else** |
388
+ | \ \ \ \ Add the request to the waiting list |
389
+ | \ \ **end if** |
390
+ | **end for** |
391
+ | **Step 3 Logging:** |
392
+ | Write the transaction result to the borrowing log $L$ |
393
+ | **if** an overdue fine is triggered **then** |
394
+ | \ \ Notify the member and update the account balance |
395
+ | **end if** |
396
+ ```
397
+
398
+ Numbered pseudocode rows use the same one-column table format:
399
+
400
+ ```markdown
401
+ | **Algorithm: Dataset preparation and model evaluation workflow** |
402
+ |---|
403
+ | **Input:** Raw dataset $D$, model family $M$, evaluation metric $s$ |
404
+ | **Output:** Trained model $\hat{m}$ and evaluation score $\hat{s}$ |
405
+ | 1.\ \ Clean and normalize all records in $D$ |
406
+ | 2.\ \ Split $D$ into training, validation, and test subsets |
407
+ | 3.\ \ **for** each candidate model $m \in M$ **do** |
408
+ | 4.\ \ \ \ Train $m$ on the training subset |
409
+ | 5.\ \ \ \ Tune hyperparameters using the validation subset |
410
+ | 6.\ \ **end for** |
411
+ | 7.\ \ Select the best model $\hat{m}$ according to validation performance |
412
+ | 8.\ \ Compute $\hat{s}$ for $\hat{m}$ on the test subset |
413
+ | 9.\ \ **return** $\hat{m}$ and $\hat{s}$ |
414
+ ```
415
+
416
+ This pseudocode style is currently implemented as a normal table, not as a dedicated `algorithm` float. As a result, the template does not currently support cross-references.
417
+
418
+ ## Citations
419
+
420
+ Use standard Pandoc citation syntax:
421
+
422
+ - Single citation: `[@smith2023]`
423
+ - Multiple citations: `[@smith2023; @jones2024]`
424
+ - Narrative citation: `@smith2023 showed that...`
425
+ - With page numbers: `[@smith2023, p. 42]`
426
+
427
+ ## Advanced Table Formatting (DOCX Post-Processing)
428
+
429
+ When generating DOCX output, three post-processing scripts automatically enhance table formatting:
430
+
431
+ ### 1. Table Attributes
432
+
433
+ Add standard Pandoc attributes to table captions to control DOCX table properties. Pandoc does not preserve arbitrary table attributes in the generated DOCX, so `papper build docx` runs a Lua filter that embeds a hidden WordprocessingML marker before conversion. The DOCX post-processor reads the marker, applies the settings, and removes it before saving the final document.
434
+
435
+ **Syntax**: Add attributes at the end of the Pandoc table caption.
436
+ For tables that should not have a visible caption, use an attribute-only caption line such as `: {revision_rows="*"}`.
437
+
438
+ **Available attribute keys**:
439
+ - `cell_margin="0.10cm"` - Set all cell margins (supports cm, mm, in, pt)
440
+ - `cell_margin_top="0.10cm"`, `cell_margin_bottom="0.10cm"`, `cell_margin_left="0.10cm"`, `cell_margin_right="0.10cm"` - Individual margins
441
+ - `cell_spacing="0pt"` - Spacing between cells
442
+ - `row_height="0.5cm"` - Set row height for all rows
443
+ - `revision_rows="1,2,3"` - Mark changed or added 1-based rows in red text
444
+ - `revision_columns="6,7"` - Mark changed or added 1-based columns in red text
445
+ - `revision_rows="*"` or `revision_columns="*"` - Mark the entire table and its caption in red text
446
+ - `alignment="center"` - Table alignment (left, center, right)
447
+ - `autofit="window"` - Autofit behavior (fixed, content, window)
448
+
449
+ Revision row and column numbers are 1-based and include the table header row.
450
+
451
+ Hyphenated aliases such as `cell-margin="0.10cm"` and `revision-columns="6,7"` are also accepted.
452
+
453
+ **Example**:
454
+ ```markdown
455
+ | **Method** | **Accuracy (%)** |
456
+ |:----------:|:----------------:|
457
+ | Baseline | 78.3 |
458
+ | Proposed | 92.4 |
459
+
460
+ : Performance comparison. {#tbl:results cell_margin="0.10cm" autofit="window" alignment="center" revision_rows="*"}
461
+ ```
462
+
463
+ The attributes are applied to the DOCX table without appearing in the final caption.
464
+
465
+ ### 2. Cell Merging
466
+
467
+ Use special markers to merge table cells in the generated DOCX:
468
+
469
+ - `!<!` - Merge with the cell to the left
470
+ - `!^!` - Merge with the cell above
471
+
472
+ **Example**:
473
+ ```markdown
474
+ | **Category** | **Subcategory** | **Value** |
475
+ |:------------:|:---------------:|:---------:|
476
+ | Group A | Item 1 | 10 |
477
+ | !^! | Item 2 | 20 |
478
+ | Group B | Item 3 | 30 |
479
+
480
+ : Table with merged cells. {#tbl:merged}
481
+ ```
482
+
483
+ In this example, "Group A" will span two rows (merging with the cell below containing `!^!`).
484
+
485
+ **Important notes**:
486
+ - Markers are processed and removed during DOCX generation
487
+ - Left merges (`!<!`) are processed first, then up merges (`!^!`)
488
+ - The marker cell must be empty except for the marker itself
489
+
490
+ ### 3. Auto-fit Tables
491
+
492
+ All tables are automatically fitted to window width and centered. This can be overridden using the `autofit` or `alignment` table attributes.
493
+
494
+ **Post-processing modules location**: `src/pandoc_manuscript/postprocess/`
495
+ - `process_table_metadata.py` - Applies metadata collected from Pandoc table attributes
496
+ - `merge_table_cells.py` - Merges cells based on markers
497
+ - `autofit_tables.py` - Auto-fits tables to window
498
+
499
+ These modules run automatically during `papper build docx` and `papper build-reply` when DOCX post-processing is enabled.
500
+
501
+ # Style Metadata
502
+
503
+ This section describes style-related defaults in `style.yml`. Keep paper
504
+ content and manuscript-specific metadata in `manuscript.md`; keep reusable
505
+ formatting, citation, cross-reference, and DOCX style defaults here.
506
+
507
+ ## Output Style Metadata
508
+
509
+ `style.yml` separates two configuration domains. Its top-level Papper settings control
510
+ build behavior such as MathType conversion, SVG handling, page margins, line
511
+ numbers, and DOCX styles. Metadata consumed by Pandoc, citeproc, or
512
+ pandoc-crossref belongs under `pandocMetadata`, including CSL, reference titles,
513
+ cross-reference labels and prefixes, numbering, and subfigure layout.
514
+
515
+ The YAML header in `manuscript.md` is manuscript/Pandoc metadata. It recursively
516
+ overrides `style.yml:pandocMetadata`, but it does not override Papper-owned top-level
517
+ settings. The optional `reply:` section can override both Papper settings and its own
518
+ `reply.pandocMetadata` for `papper build-reply`.
519
+
520
+ Older projects may still keep Pandoc keys at the top level of `style.yml`. Papper
521
+ continues to load those keys and prints a deprecation warning, but new and updated
522
+ projects should move them under `pandocMetadata`. Papper never rewrites the source
523
+ `style.yml`; generated Pandoc-only metadata is written under `.pmt/work/`.
524
+
525
+ In reviewer replies, `papper build-reply` resolves `@fig:...`, `@tbl:...`, `@sec:...`, and `@eq:...` references from the manuscript before writing the reply output. When a copied figure or table keeps its manuscript label, such as `![Caption](image.png){#fig:model}` or `: Caption {#tbl:results}`, the reply build automatically prefixes its caption with the matching manuscript number. DOCX output is selected with an `.docx` output path. A labeled display equation copied into the reply, for example `$$ ... $$ {#eq:model}`, is assigned the matching manuscript equation number and rewritten to the DOCX tab-stop equation layout. If a figure, table, or equation label cannot be resolved from the manuscript, the original Markdown is left unchanged so the missing mapping remains visible.
526
+
527
+ TXT reply output is selected with an `.txt` output path, for example `papper build-reply reply.md -o output/txt/reply.txt`. It keeps Markdown syntax for `**bold**`, `_emphasis_`, tables, and formulas, replaces images with `[Image: ...]` placeholders, resolves ``(Line `regex`)`` placeholders and manuscript cross-references, removes trailing `{#eq:...}`, `{#fig:...}`, and `{#tbl:...}` label attributes from formulas, images, and tables, strips reply-only `::: {custom-style="Reply to Reviewers"}` wrappers plus `<br>` tags, collapses the resulting extra blank lines to at most one blank line, and restores escaped ordered-list markers such as `1\.` to `1.`.
528
+
529
+ Collapsed numeric citation ranges can use a journal-specific delimiter after Pandoc citeproc renders them. This is a Papper filter setting rather than Pandoc metadata, so configure it at the top level of `style.yml`:
530
+
531
+ ```yaml
532
+ citationNumberRangeDelimiter: "-" # [1-3]
533
+ ```
534
+
535
+ Papper passes this value to its Lua filter through the
536
+ `PMT_CITATION_NUMBER_RANGE_DELIMITER` environment variable; it is not written
537
+ into generated Pandoc metadata and cannot be overridden from manuscript YAML.
538
+
539
+ To add a space after commas between non-consecutive numeric citations, edit the active CSL file's citation layout delimiter. For example, in `pandoc/csl/elsevier-vancouver.csl`, change:
540
+
541
+ ```xml
542
+ <layout prefix="[" suffix="]" delimiter=",">
543
+ ```
544
+
545
+ to:
546
+
547
+ ```xml
548
+ <layout prefix="[" suffix="]" delimiter=", ">
549
+ ```
550
+
551
+ This changes citations such as `[1,3]` to `[1, 3]`. It does not control collapsed ranges such as `[1-3]`, which are handled by `citationNumberRangeDelimiter`.
552
+
553
+ When SVG files reference local child images with paths, enable DOCX-only
554
+ child-image embedding in `style.yml`. This writes cached self-contained SVG
555
+ files for DOCX output while keeping SVG text and vector elements sharp:
556
+
557
+ ```yaml
558
+ docxEmbedSvgImages: true
559
+ ```
560
+
561
+ For journal submission systems that reject SVG image files entirely, enable
562
+ DOCX-only SVG rasterization instead. If only one SVG needs rasterization, add
563
+ `to-png=true` to that Markdown image instead of enabling the global option. Use
564
+ `to-png-scale=2` on the same image to override the global PNG scale:
565
+
566
+ ```yaml
567
+ docxConvertSvgToPng: true
568
+ # Optional rasterization control; enable at most one:
569
+ docxSvgToPngWidth: 1600
570
+ # docxSvgToPngDpi: 300
571
+ # docxSvgToPngScale: 1
572
+ ```
573
+
574
+ During `papper build docx`, self-contained SVG cache files are written under
575
+ `.pmt/cache/svg-embedded/`, and PNG rasterization outputs are written under
576
+ `.pmt/cache/svg-png/`. The original Markdown and SVG files are not rewritten.
577
+ The PNG converter uses the Python `resvg-py` dependency.
578
+
579
+ The DOCX post-processing step can update paragraph styles from Papper settings. Add style names under the top-level `docxStyle`; each key is matched against an existing DOCX style name, and missing styles are reported as warnings without stopping the build. The default template uses a two-character first-line indent and no spacing before or after body paragraphs:
580
+
581
+ Set DOCX page margins under `docxPageMargins`. The values are written into the
582
+ reference DOCX before Pandoc conversion, so Pandoc calculates image widths from
583
+ the same writable page width that Word will use. Omit a side to keep the
584
+ reference DOCX value for that side unchanged:
585
+
586
+ ```yaml
587
+ docxPageMargins:
588
+ top: 2.54cm
589
+ bottom: 2.54cm
590
+ left: 3.17cm
591
+ right: 3.17cm
592
+ ```
593
+
594
+ To control automatic page numbers in DOCX footers, set `docxShowPageNumbers`.
595
+ `true` adds a Word `PAGE` field to each defined footer using the reference
596
+ DOCX's `page number` character style; `false` removes `PAGE` fields while
597
+ retaining any other footer text. Papper does not request a document-wide field
598
+ update when Word opens the file. If the setting is omitted, Papper leaves the
599
+ reference DOCX footer unchanged:
600
+
601
+ ```yaml
602
+ docxShowPageNumbers: true
603
+ ```
604
+
605
+ For DOCX builds, `pmt` derives the pandoc-crossref equation layout automatically;
606
+ do not add `tableEqns`, `eqnBlockTemplate`, or `eqnBlockInlineMath` to
607
+ `pandocMetadata`. When MathType conversion is active, Papper uses an inline
608
+ OpenXML tab-stop template and derives its two `w:pos` values from the left/right
609
+ margins. When MathType conversion is inactive or unavailable, Papper uses the
610
+ three-column table template so native Word display equations remain centered
611
+ with their numbers right-aligned.
612
+
613
+ For a one-off DOCX build, the command line can override the top-level
614
+ `mathtype` setting without editing `style.yml`:
615
+
616
+ ```powershell
617
+ papper build docx --mathtype
618
+ papper build docx --no-mathtype
619
+ ```
620
+
621
+ The command-line value has higher priority than `style.yml`. These flags apply
622
+ only to `papper build docx`.
623
+
624
+ Common Chinese built-in names such as `标题 1`, `正文文本`, and `正文` are automatically mapped to the corresponding Word built-in style names like `Heading 1`, `Body Text`, and `Normal`. Custom styles still need to use their exact DOCX style names.
625
+
626
+ ```yaml
627
+ docxStyle:
628
+ 正文文本:
629
+ firstLineIndentChars: 2
630
+ paragraphSpacing:
631
+ before: 0pt
632
+ after: 0pt
633
+ ```
634
+
635
+ Use point values for paragraph spacing, such as `6pt`. The first-line indent is written as a Word character-based indent, so `2` means two characters rather than a fixed centimeter or inch value. Fields that are omitted from a style block are left unchanged in the DOCX style.
636
+
637
+ Common style fields under `docxStyle` include:
638
+
639
+ - `fontSize`: font size such as `10.5pt` or Chinese Word sizes like `小五` and `四号`
640
+ - `fontColor`: font color such as `#000000` or `rgb(0, 0, 0)`
641
+ - `lineSpacing`: paragraph line spacing such as `1.5` or `18pt`
642
+ - `alignment`: `left`, `center`, `right`, or `justify`
643
+ - `firstLineIndentChars`: Word character-based first-line indent
644
+ - `indentation`: length-based `left`, `right`, `firstLine`, or `hanging` indent values such as `0.5cm`
645
+ - `paragraphSpacing`: `before` and `after` spacing values such as `6pt`
646
+
647
+ ## Changing Citation Styles
648
+
649
+ 1. **Browse styles**: Visit [Zotero Style Repository](https://www.zotero.org/styles)
650
+ 2. **Download CSL file**: Save to `pandoc/` directory
651
+ 3. **Update `style.yml`**:
652
+ ```yaml
653
+ pandocMetadata:
654
+ csl: pandoc/your-style.csl
655
+ ```
656
+
657
+ Common styles included:
658
+ - `elsevier-vancouver.csl`: Numeric citations (Vancouver style)
659
+ - `engineering-applications-of-artificial-intelligence.csl`: EA-AI journal style