[XeTeX] How may I get colored background on text?

Ron Aaron ron at ronware.org
Tue Feb 21 11:58:29 CET 2012


> See the dvipdfm documentation: texdoc dvipdfm.

That's not actually helpful.

There is no direct way to accomplish this; however, it is possible to
create a "rule" as big as an enclosing box, and position a text box over
it.  Example code:

\def\pdfliteral#1{\special{pdf: literal #1}}

\def\greyline#1{
    \setbox1\hbox to \hsize{#1}
    \setbox0\vbox{
        \pdfliteral{0.8 0.8 0.8 rg}
        \hrule width \hsize height \ht0 depth \dp0
        \pdfliteral{0 0 0 rg}
    }
    \wd0=0bp
    \hbox{\box0\box1}
}


More information about the XeTeX mailing list