Walt Mankowski on Fri, 8 Dec 2000 23:47:52 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] texsters: shading text background


On Fri, Dec 08, 2000 at 11:22:19AM -0600, MaD dUCK wrote:
> i basically want a section head line to be background shaded with
> 15-20% black with the text overlaying the shading. i wasn't able to
> find pure tex methods to do so and i don't feel like creating .eps
> files for each section head, so i am looking for a way - any way - to
> create tex code inline which will do that.

I'm certainly not an expert, but after a little digging around this
seems to work.

First, use the color package:

    \usepackage{color}

Then, define a color for the shade of gray you want to use:

    \definecolor{lightgray}{gray}{.75}

Once you've done that, you can use the \colorbox command to write text
with a lightgray background:

    \colorbox{lightgray}{Hello, world}

You can use \newcommand to create a new command that displays section
headings with a gray background:

    \newcommand{\graysection}[1]{\section{\colorbox{lightgray}{#1}}}

    \graysection{First Section}

One caveat is that xdvi doesn't support colors, at least not as of
version 22.05d-k which is the latest I have.  Xdvi will show all your
colorboxes as solid black rectangles.  But dvips handles them just
fine so your document will print correctly.  You can also use dvips to
convert your dvi file to postscript:

    dvips -f <foo.dvi >foo.ps

and then view the document with gv.

Walt


______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug