[luatex] Change background color for Plain TeX using LuaTeX?

Henri Menke henrimenke at gmail.com
Sun Nov 25 03:30:30 CET 2018

On 11/25/18 2:56 PM, Steve Litt wrote:
> This regards Plain TeX. I know there are ways to easily do it in
> LaTeX.
> Is there something I can put within \directlua{} or anywhere else
> to change the background color of a series of letters or a series of
> lines?

You can change the backgroundcolor of the page like shown below.  You
can easily adapt the code for only a single box.



\pdfextension literal page {
  q % push current graphics state onto the stack
  0 0 1 rg % RGB color for non-stroking operation
  0 0 1 RG % RGB color for stroking operation
  n % end the current path object without filling or stroking
  0 0 \withoutpt{\the\pagewidth} \withoutpt{\the\pageheight} re %
construct rectangle
  f % fill the path
  Q % pop previous graphics state off the stack

Hello World!


> Thanks,
> SteveT
> Steve Litt
> November 2018 featured book: Manager's Guide to Technical
> Troubleshooting Brand new, second edition
> http://www.troubleshooters.com/mgr

More information about the luatex mailing list