Skip to content

One caption per diagram, and picture and diagram widths - #132

Merged
markbac merged 2 commits into
mainfrom
claude/gracious-ride-1x1cpi
Oct 14, 2026
Merged

markbac merged 2 commits into
mainfrom
claude/gracious-ride-1x1cpi

Conversation

@markbac

@markbac markbac commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Summary

One caption per diagram

A [[CAPTION:Figure]] line next to a diagram gave it two captions, because pandoc also made one from the picture's alt text:

Caption line Word before HTML / PDF before After, every format
none alt text alt text alt text
above 2 captions 1 the line's
below 2 captions alt-text caption, plus the line as a loose paragraph the line's
  • Word: a diagram with a caption line directly above or below is written so that pandoc does not make it a figure (a no-break space after the picture). [[CAPTION:Table]] lines are not counted, so they still go to their table.
  • HTML, PDF and PowerPoint (markers.lua): a caption line below a diagram now captions the figure inside the diagram's centred div.

Picture and diagram widths

  • [](a.png){width=50%} now works in Word too. pandoc's Word writer ignores %, so the new widths.lua converts it to cm of the template's text width (page width less margins), which the engine reads from the reference document. With no page set in the template it uses 14.82 cm, the widest pandoc makes a picture then. HTML and PDF already honoured %.
  • Diagram fences take width="100%" (or cm, mm, in, px) after the language. Any other value stops the build with the file and line.

Docs and example

The writing guide and examples/ show [[PAGEBREAK]] (03_operations.md), a diagram captioned below, and diagrams at 100% and 60% (02_design.md).

Testing

  • Rebased on main after Docker start-up wait, [[PAGEBREAK]], one caption per diagram, picture widths #130 and Support the [[PAGEBREAK]] directive #131.
  • New tests: one caption per diagram for none/above/below in Word, HTML and PowerPoint (2 fail on the old code); % widths for a diagram and a picture against a template with a 17 cm text width in Word and HTML; a bad width is an error.
  • Full suite passes except tests/test_examples.py, whose 7 failures also occur on main in this environment because Graphviz, Mermaid and PlantUML are not installed here. py-doc lint is clean on examples/docs and docs/guide; ruff check is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ket2UPXgz46XKSUqpuPixk


Generated by Claude Code

A [[CAPTION:]] line next to a diagram gave it two captions: pandoc made
one from the picture's alt text, and the marker made another. In Word,
a diagram with a caption line above or below it is no longer made a
figure by pandoc. In HTML, PDF and PowerPoint a caption line below a
diagram now captions it, as one above already did, instead of being
left as a paragraph beside pandoc's caption. A diagram with no caption
line keeps the alt text as its caption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ket2UPXgz46XKSUqpuPixk
- Word: pandoc ignores a width in %, so widths.lua turns {width=50%}
  into cm of the template's text width (page less margins), which the
  engine reads from the reference document. HTML and PDF already
  honoured %.
- Diagrams take width="100%" (or cm, mm, in, px) after the language,
  passed on to the picture; anything else stops the build with the
  file and line.
- Guide and example project: [[PAGEBREAK]], a diagram captioned below,
  and full-width and 60% diagrams.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ket2UPXgz46XKSUqpuPixk
@markbac
markbac merged commit bdde775 into main Oct 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants