I would like to have an option to switch to "dark mode" in my pdf, say, using a button in the document. Using the xcolor and pagecolor packages, I can change the background color and/or text color of the document using
\pagecolor{black}
\color{white}
This post even explains how I can change the background color of each individual page.
If my document has a white background with black text, it may be that the pdf-reader used has a dark-mode option, which inverts the colors in some way. However, the result of this may not be good at all, as this example (from Foxit Reader night-mode) shows:
The problem is that different pdf-readers might use different inversions, and so the resulting figures may look good in one reader, but horrible in another.
Since I can change the background color of each individual page, one solution to this problem is to copy the entire document, append it to itself, and have the first half in a bright-theme, and the second-half in a dark-theme. With this approach, I can put a hyperlink on each page that links to the corresponding page with opposite color (in the opposite half of the document).
The drawback with this approach is that the document will have 2x the size of the original document. It would be nice if there was a way to change from bright-mode to dark-mode, in such a way that each image in the document is replaced by a dark-counterpart image (so that I have full control over how the document looks like after swithcing mode, as opposed to what we get in the reader).
For an example, is there a simple way I can create a hyperlink, that changes the background (and text) color between white and black, upon click? (This may not be too difficult in html, css, javascript, but I find latex very convenient when writing math documents, and I want the document to be a pdf).
Note: This is not a question about changing to a dark-mode setting in the latex editor or in a pdf-reader, but how to make the document have these capabilities.
