Skip to content

fix: give raster figures the same \parskip as paragraphs and pspictures - #37

Merged
pyramation merged 2 commits into
mainfrom
fix/figure-parskip
Aug 25, 2026
Merged

fix: give raster figures the same \parskip as paragraphs and pspictures#37
pyramation merged 2 commits into
mainfrom
fix/figure-parskip

Conversation

@pyramation

Copy link
Copy Markdown
Collaborator

Summary

\img and \youtube were the only block-level things the renderer emits with no vertical spacing of their own — the wrapper carried an inline style and nothing else:

-<div style="width: 100%;text-align: center;"><img src="...">
+<div class="latex2js-figure"><img src="...">
.latex2js-figure {
  margin: var(--latex2js-parskip) auto;
  text-align: center;
}

That worked on the old mathapedia only by accident: images were inline there, so the line box's leading (~21px at line-height: 20px) happened to look like a paragraph gap. Any consumer running a modern CSS reset loses it — Tailwind's preflight sets img { display: block } — and a figure ends up flush against the following paragraph. Measured on mathapedia.com's rewrite, the gap below the figure on /books/31/sections/153/338 was 0px where production shows 21px; with this change it's 22.4px, i.e. the same 1.6em \parskip that .math > p.para and .pspicture already use.

So the spacing lands where the rest of the document rhythm already lives — one variable in latex2js.css — rather than in a consumer stylesheet. width: 100% from the inline style is dropped because a block div is already full width. No img rule is added: whether images are block or inline is the consuming site's reset to decide, and this fix holds either way.

bundle/latex2js.css and bundle/latex2html5.bundle.js are the tracked build outputs, regenerated.

Link to Devin session: https://app.devin.ai/sessions/e51e8ecb94d241bd8d89e65e642c3e43
Requested by: @pyramation

@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit eeb062c into main Aug 25, 2026
4 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.

1 participant