Skip to content

MathJax 4, and diagram colours written in LaTeX both engines agree on - #1

Open
pyramation wants to merge 2 commits into
mainfrom
fix/latex-valid-colours-and-mathjax4
Open

MathJax 4, and diagram colours written in LaTeX both engines agree on#1
pyramation wants to merge 2 commits into
mainfrom
fix/latex-valid-colours-and-mathjax4

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Two things: the bundle moves to MathJax 4, and the arrow demos are rewritten in LaTeX a reader could actually compile.

Depends on LaTeX2JS#31 — the pages now use \definecolor, which that PR adds. Merge it first; the bundle here is built from it.

The colours

The arrow demos named colours that mean different things in LaTeX and in a browser, and one LaTeX does not define at all — so the snippets shown as source could not be compiled by anyone who copied them.

was why it changed
purple crimson #BF0040 in xcolor the diagram wants #800080, which xcolor calls violet
lightblue not a LaTeX colour ! Package xcolor Error: Undefined color 'lightblue'.

lightblue is now declared:

\definecolor{lightblue}{RGB}{173,216,230}

Same shade, in a line LaTeX accepts.

Also fixes a typo carried in both the live picture and the listing beneath it — (0,0)(2,2)(sin(x)}{-y} opened the head function with a paren instead of a brace. The renderer tolerated it; LaTeX would not.

The verbatim listings are updated alongside the pictures they document, so copying from the page gives source that compiles.

Verified both directions

  • LaTeX: the snippet compiles through latex → dvips → ps2pdf → gs with zero errors and draws the intended colours.
  • Browser: strokes come out rgb(128, 0, 128) and rgb(173, 216, 230) — the exact colours the pages had before.

The bundle

Carries MathJax 4.1.3 and the \rput label-centring fix that goes with it. v4 needed no config migration. Both pages checked warm and on a cold load with the MathJax fetch throttled to 900ms:

figures formulas labels off-centre JS errors
/index.html 5 33 25 0 0
/examples/index.html 13 50 49 0 0

Worth knowing: v4's payload is larger, so on a genuinely cold connection labels stay hidden about 4s before appearing correctly (415ms warm). Adding <link rel="preconnect" href="https://cdn.jsdelivr.net"> to the <head> would claw some of that back — happy to add it if you want.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HBYcp3Go9naDWgFThChaDf

The arrow demos on both pages named colours that mean different things in
LaTeX and in a browser, and one that LaTeX does not define at all — so the
snippets shown as source could not be compiled by a reader who copied them.

  purple     xcolor's purple is crimson (#BF0040); the colour the diagram
             wants is xcolor's violet (#800080), which is also what CSS calls
             purple. Renamed, so it draws the same shade in both engines.

  lightblue  a browser colour name. Real LaTeX rejects it outright:
             `! Package xcolor Error: Undefined color 'lightblue'.`
             Now declared with \definecolor{lightblue}{RGB}{173,216,230},
             which names the exact same shade in a line LaTeX accepts.

Also fixes a typo carried in both the live picture and the listing beneath it:
`(0,0)(2,2)(sin(x)}{-y}` opened the head function with a paren instead of a
brace. The renderer tolerated it; LaTeX would not.

The verbatim listings are updated alongside the pictures they document, so a
reader copying from the page gets source that compiles.

Verified in both directions rather than by inspection. The snippet now
compiles through latex -> dvips -> ps2pdf -> gs with zero errors and draws the
intended colours; in the browser the strokes come out rgb(128,0,128) and
rgb(173,216,230), the exact colours the pages had before.

The bundle carries the MathJax 4.1.3 upgrade and the label-centring fix that
goes with it. Both pages were checked warm and on a cold load with the MathJax
fetch throttled: 33 and 50 formulas typeset, 25 and 49 labels, none off-centre,
no console errors.
Text is grouped into real paragraphs now rather than separated by one <br>
per blank line, so the gap between them is a style the sheet can set —
--latex2js-parskip — instead of however many times the author pressed return.
A figure takes the same value, so a picture and a paragraph sit apart by the
same amount.

The stylesheet here was an older copy of the one in the package; it is brought
up to date wholesale. The diff is additions only, so nothing site-specific was
carried in it.
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