images in dark mode

15 views
Skip to first unread message

David Farmer

unread,
Oct 9, 2026, 2:01:35 PM (13 days ago) Oct 9
to prete...@googlegroups.com
Someone showed me that they have MyOpenMath working
well in dark mode, including graphs that have a dark background
with the axes, numbers, and curves becoming light.

Can we do something like that for other graphics (such as
those from PreFigure)?

Regards,

David

Cameron Bishop

unread,
Oct 9, 2026, 2:11:28 PM (13 days ago) Oct 9
to PreTeXt development
Hello, everyone! This is the way that I have been able to make MyOpenMath exercises show up nicely in dark mode in a PreTeXt project:

@media (prefers-color-scheme: dark) {
  /* Only invert iframes that are descendants of a PreTeXt MyOpenMath block */
  :root.dark-mode iframe[src*="myopenmath.com"] {
    filter: invert(1) hue-rotate(180deg);
  }
}

 It feels a little hacky, but it has worked well so far and it flips nicely between light and dark modes.

-Cameron Bishop

Andrew Scholer

unread,
Oct 9, 2026, 2:48:03 PM (13 days ago) Oct 9
to prete...@googlegroups.com
David - 

Are you envisioning some kind of automatic conversion? Or better handling for explicitly authored light/dark versions of diagrams?

The css filter for invert isn't going to be foolproof. Any references to colors ("the blue dot represents...") may or may not remain intelligible.

Furthermore, diagrams that are more complex than lines/shapes may significantly change during inversion. Opinions may differ, but if the diagram below was in my book, I would want the original displayed, even in dark mode, than the auto-inverted version.
image.png
image.png


We could provide a switch to allow authors to specify "apply an automatic inversion" to this image. @invert-in-darkmode? Perhaps with a book level default that could be overridden on individual images?

Side note, I don't know that the media query is needed there. We check the prefers-color-scheme when deciding what mode to start the user in. But they might switch to using dark mode just for the book. In that case, the browser would still indicate prefers-color-scheme: light.

Andrew

--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/7805385d-8e36-4652-b119-f3efa1001756n%40googlegroups.com.

David Farmer

unread,
Oct 9, 2026, 3:10:56 PM (13 days ago) Oct 9
to prete...@googlegroups.com
We definitely need to allow authors to specify what should or should not be inverted.

How about a docinfo option indicating the default for that document, and a new
optional attribute on an image/figure saying whether to invert it?

So, a calculus book with lots of graphs/figures, would indicate that the default
is to invert.  Then for the occasional photograph or diagram with some particular
feature, the markup would indicate to not invert?

If the css selector refers to the new attribute, then initially nothing would be inverted.
An author would have to make some choices and then rebuild.

It was news to me that this could be possible without two versions of an image,
so I can't claim to have thought about it carefully.

Regards,

David



Rob Beezer

unread,
Oct 9, 2026, 3:58:15 PM (13 days ago) Oct 9
to prete...@googlegroups.com
On 10/9/26 12:10 PM, David Farmer wrote:
> How about a docinfo option indicating the default for that document, and a new
> optional attribute on an image/figure saying whether to invert it?
>
> So, a calculus book with lots of graphs/figures, would indicate that the default
> is to invert.  Then for the occasional photograph or diagram with some particular
> feature, the markup would indicate to not invert?

Yes.

* Let's discuss markup choices (names!) here before forming a PR.

* EPUB readers have this choice, too. Not sure how it works. Now might be the
time to dig into that since now markup is being added into source, so we should
consider every place this new markup should be interpreted. Before, light/dark
was an HTML interface decision (in EPUB lingo, "the reading system").

Andrew Scholer

unread,
Oct 9, 2026, 4:41:27 PM (13 days ago) Oct 9
to prete...@googlegroups.com
Tacking on to Rob's list of considerations:

* An author might reasonably want different defaults for different image types. e.g. invert pretext, leave png alone.
* Some "images" become iframes. There is already a hook that enables passing on what mode PreTeXt is using for the root page to the inner html of iframes. That might need to be included/extended.



--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages