3

Synopsis: add macro to set page-background in TeX + OPmac


Out of http://petr.olsak.net/opmac-tricks-e.html#coltext ...the OPmac tips and tricks additional macro listing to the core opmac.tex macro package:

The below code suggested as a way to change color within the document conflicts with \input color the TeX way to integrate the color package into the available macrocode to a document to be set in TeX.

\def\color#1{\localcolor\colorA#1\relax}
\def\colorA#1#2\relax{\uppercase{\csname#1}#2\endcsname\ignorespaces}

Although OPmac provides color, it contains no macro to set the page color of the document, referring to color all pages of the document to a certain background color, defining the right box would solve this ... beyond my humble skills of yet, thus the occurrence to \input color, the latter being mostly redundant since OPmac provides color capability in all, including above macro to change color/colored background locally on the fly.

The question: can anyone provide a short additional macro that defines the right 'box' and an additional user command to set the page background. Since color is implemented.

Justification: Petr has provided a package that focusses on functionality, not on styling, the above is a request for additional user functionality. Secondly, including color.tex macro file to just add background color, and commenting out the above OPmac-tricks macro to solve the conflict is tit for tat, thirdly the philosophy of Petr to have a minimal solid code-base is smothered by including al of the color.tex code for just the above.

Personal justification: background coloring and text coloring for proof reading is a serious benefit to any author/programmer, the black on white of most printed pdfs' makes for eye burden switching between source (vim-solarized), and pdf-output. To homogenize the back and forth between both, we all spend part of our lives 'on screen', is not a minor. Comes printing time, since the rest of the formatting is identical, compiling to black and white for print, is as simple as \input opmacmodified_to_proofread_onscreen to \input opmac_modified_to_print or a conditional or two added to opmac_modified.tex .

Simplified question: additional macro to easily set page background in TeX + OPmac

Delving further into the matter, the color.tex macros regardless of using floats or a simple \lipsum[2-10] text, running a few pages, gives "bleeds", second page on, to the left and bottom/top of the page.

Then there is absolute silence in any documentation regarding color(s) and their use with regard to page background coloring. It is supposed "color" means text coloring, locally or globally, and "background" coloring is a local matter, coloring a "box".

With hindsight, the theoretical capability should be there, after all latex is built on top of the tex primitives, the easiness latex colors backgrounds of pages cannot be pulled from the sky, again an OPmac macro can easily render back-ground color locally.

It can be argued that typesetting is done solely for print, making the issue a trivial one, then, typesetting as a process requires jumping from source to compilation onscreen, enough a reason to adapt, during the process of authoring, the background to the one of the source(in case vim-solarized) for useability. Not so trivial after all.

It would be highly satisfactory to discuss the capability of page coloring in tex in a principled way, and to the other end being convinced of the non-essentiality of it, then the pertinent explicit, need.

  • Is there any way, to set background color, page-color in plain TeX that is functional, experimenting further with the color.tex macro, within the graphics package, and useable in plain tex. '\input color' regardless of having floats or not, even a plain \lipsum[2-10] text over more then one page leaves a non-coloured back-ground area, according to the geometry of the page to the left and top, or the left and bottom of the second page on. – m___ Feb 16 '16 at 9:20
  • If I understand well your question, you are looking for the solution described in the second part of the OPmac trick 0021 petr.olsak.net/opmac-tricks-e.html#podklad – wipet Feb 16 '16 at 10:19
  • The issue with setting background color of pages is solved by using an OPmac native macro, and leaving out the color.tex macro code, that was creating conflicts with some OPmac color definitions and more. More precisely macro (0021) -- P. O. 08. 2013 on the petr.olsak.net/opmac-tricks-e.html#coltext public page was all the compact code needed to flawlessly creating page-background color document-wide. The question should be marked as irrelevant. This additional macro to the plain tex code takes perfectly well care of page backgrounds without recurrence to an additional LaTeX layer. – m___ Feb 16 '16 at 22:11
  • In this site you are allowed to answer your own question—or delete it altogether. – errekak Feb 16 '16 at 22:13
2

The issue with setting background color of pages was solved by using an OPmac native macro, and leaving out the color.tex macro code, that was creating conflicts with some OPmac color definitions and more. The second bonus was the element of compactness, coding should be well documented one, and be compact two. Both conditions were met.

Macro (0021) -- P. O. 08. 2013 on the petr.olsak.net/opmac-tricks-e.html#coltext public page was all the compact code needed to flawlessly creating page-background color document-wide.

Petr Olsak, himself referenced to the macro available on his public web page, within the first day of posting the question.

Here is the code sample: all it takes to have page coloring:

    \def\prepghook{\pdfliteral{q \bgcolor\space k -0.996264 0 0 0.996264 -72 72 cm
  \nopt{\hoffset} \nopt{\voffset} -\nopt{\pdfpagewidth} -\nopt{\pdfpageheight} re f Q}}
\def\nopt#1{\expandafter\ignorept\the#1}

\def\setbasecolor#1{#1\expandafter\setbasecolorA#1\pdfblackcolor}
\def\setbgcolor#1{\expandafter\setbasecolorA#1\bgcolor}
\def\setbasecolorA#1#2#3{\def#3{#2}}

As an example:

\setbasecolor\Yellow
\setbgcolor\Blue
|improve this answer|||||
  • 2
    IIUC, the format of this website requires you to include the code that solved your problem, not only a reference to the manual/bag-of-tricks that solves the issue. In other words, include the incantation, not only the reference to the sorcery book. – errekak Feb 16 '16 at 23:06
  • New user, many pardons? – m___ Feb 17 '16 at 13:34
  • No hay problema. I just tried to introduce you to the way this system works. Cheers, – errekak Feb 17 '16 at 20:40
  • correct me if I am wrong, but this piece of code assumes the use of pdfTeX as engine; i.e. no drivers for dvips, etc. Correct? – errekak Feb 17 '16 at 23:26
  • `` no dvips'', assume that when tex outputs to pdf, it certainly can digest the code to output to dvips. But... this is a guess. For certain: pdftex, pdfcsplain(reverts to pdftex mostly), xetex all understand the macro. – m___ Feb 20 '16 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.