[texhax] dotfill leaders on first line of paragraph only ?

Heiko Oberdiek heiko.oberdiek at googlemail.com
Wed Dec 7 22:29:49 CET 2011


On Wed, Dec 07, 2011 at 06:46:59PM +0000, Philip TAYLOR wrote:

> Philip TAYLOR wrote:
> 
> >OK, thank you William : in that case it is presumably necessary only
> >to redefine the font selectors so that when I (for example) use
> >\normalfont in my document, this does not resolve to a simple
> >font selector but rather to a macro that expands to
> >\concealednormalfont \special {...}.
> 
> Unfortunately not as simple as I had hoped.
> Now, given :
> 
> 	\let \Font = \font
> 	\def \font #1= #2 at #3 pt
> 		{
> 			\message {Loading font \string #1 = #2 at #3 pt}
> 			\expandafter \Font \csname font:\string #1\endcsname = #2 at #3 pt \relax
> 			\edef #1{\csname font:\string #1\endcsname \special {color cmyk 0 0 0 1}}
> 		}
> 
> (i.???, initially mapping all fonts to black)
> 
> I get
> 
> >** WARNING ** You've mistakenly made a global color change within nested colors.
> >** WARNING ** You've mistakenly made a global color change within nested colors.
> >** WARNING ** You've mistakenly made a global color change within nested colors.
> 
> (repeated many many times).

You are reinventing the wheel.

Study color.sty, xetex.def and the color stuff of latex.ltx
to learn how colors can be handled.

To get TeX group working with colors, the colorstack
is useful:

\def\ResetColor{\special{color pop}}
\def\SetColor#1{\color{color push #1}\aftergroup\ResetColor}

Then you can add a color e.g. cyan as \SetColor{cmyk 1 0 0 0} to your font
command.

Care is needed with \setbox, it needs an additional grouping level to avoid
a wrong placement of the \special by \ResetColor that is called via
\aftergroup, e.g.:

\setbox0=\hbox{\begingroup ...\SetColor{cmyk 1 0 0 0}...\endgroup}

Yours sincerely
  Heiko Oberdiek


More information about the texhax mailing list