My question is very simple: is it possible to use \pagecolor
from xcolor
(or related packages) to change the background color of a document generated by the preview
package?
I've tried to add \pagecolor{cyan}
to the preamble, to the document body, and within the different preview
environments, with little success. I've also tried digging into the internals of both the preview
and the xcolor
packages — I suspect that when a page is built by preview
, it interferes with xcolor
changing the background color, but I haven't been able to pinpoint where the color suppression happens…
I'll keep searching in the following days and keep you updated. In the meantime, if anyone is also willing to look into this, I'll be extremely grateful!
Here is my M-non-WE
, tested on Overleaf
using pdfLaTeX
and running TeXLive 2020
:
\documentclass{standalone} % changed to `standalone because cropping wasn't good
\usepackage{mwe}
\usepackage[active]{preview}
\usepackage{xcolor}
\pagecolor{cyan} % Doesn't change the preview page color.
% (I wouldn't expect it to, since it's not inside a `preview` environment.)
\begin{document}
%% The following isn't typeset, since `preview` is active.
\pagecolor{cyan} % Doesn't change the preview page color either.
% (Again, this is expected.)
\lipsum[1]
%% What's inside of `preview` environments gets typeset when `preview` is active.
\begin{preview}
\pagecolor{cyan} % Still doesn't change the preview page color...
% I would expect this one to work :-/
\lipsum[2]
\pdftexbanner
\end{preview}
\end{document}
With the following output:
Edit:
I tried running the same code using XeLaTeX
and the page color was in cyan! Unfortunately, due to restrictions on my side, I cannot use something other than pdfLaTeX
.
My question now becomes: is it possible to do this consistently using any of pdfLaTeX
, XeLaTeX
and LuaLaTeX
?