[pdftex] color package in pdfTeX under plain TeX
Heiko Oberdiek
oberdiek at uni-freiburg.de
Wed Aug 3 01:03:30 CEST 2005
On Tue, Aug 02, 2005 at 09:23:55PM +0300, geolsoft at mail.ru wrote:
> Dear list members,
>
> I am trying to use color package of graphics bundle with
> pdftex and plain TeX. According to
>
> http://pdftex-def.berlios.de/
>
> `questions regarding the usage of pdftex.def ... should be
> directed to the pdfTeX list', so here it goes.
>
> Version of pdftex.cfg I use is 0.03m, the latest I could
> find. pdfTeX is
>
> This is pdfTeX, Version 3.14159-1.10b (Web2C 7.4.5)
>
>
> Question 1.
>
> First off, I don't know what is the proper way to select
> pdftex driver, or any other driver different from the
> default `dvips'. The code I used at the top of the attached
> test file `grfcolor.tex' was adapted from
> $TEXMF/tex/latex/graphics/color.tex. Is this the way to do
> it?
\input miniltx
\input color.sty
or just
\input color
Assuming an intelligent color.cfg file.
Example for color.cfg (teTeX/TeXLive):
%%% cut %%% color.cfg %%% cut %%%
\ProvidesFile{color.cfg}%
[2005/02/03 v1.3 color configuration of teTeX/TeXLive]
% Select an appropriate default driver
\begingroup
\chardef\x=0\relax
% check pdfTeX
\@ifundefined{pdfoutput}{}{%
\ifcase\pdfoutput
\else
\chardef\x=1\relax
\fi
}%
% check VTeX
\@ifundefined{OpMode}{}{%
\chardef\x=2\relax
}%
\expandafter\endgroup
\ifcase\x
% default case
\def\Gin at driver{dvips.def}%
\ExecuteOptions{dvips}%
\or
% pdfTeX is running in pdf mode
\def\Gin at driver{pdftex.def}%
\ExecuteOptions{pdftex}%
\else
% VTeX is running
\def\Gin at driver{vtex.def}%
\ExecuteOptions{vtex}%
\fi
\endinput
%%% cut %%% color.cfg %%% cut %%%
Without a color.cfg that detects pdfTeX and sets the
right driver, you can use:
\input miniltx
\input ifpdf
\ifpdf
\def\Gin at driver{pdftex.def}
\else
\def\Gin at driver{dvips.def}
\fi
\input color.sty
\resetatcatcode
> Question 2.
>
> Next, I have the following problem when using \pagecolor
> command. For every page of output, I get this kind of
> error:
>
> ! Output routine didn't use all of \box255.
>
> and no headline/footline, only main body of a page. See the
> same test file `grfcolor.tex', compile command is at the
> bottom (compile-command line).
>
> The patch I send fixes the problem for plain TeX, but I
> don't know whether this solution is compatible with LaTeX,
> most probably not.
>
> The problem as I see it is as follows:
>
> \shipout is (re)defined by pdftex.def as
>
> \gdef\shipout{%
> \afterassignment\GPT at shipout
> \global\setbox\@cclv=%
> }%
>
> and plain TeX defines its output routine as
>
> \output{\plainoutput}
>
> where \plainoutput is
>
> \def\plainoutput{\shipout\vbox{\makeheadline\pagebody\makefootline}%
> \advancepageno
> \ifnum\outputpenalty>-\@MM \else\dosupereject\fi}
>
> \afterassignment\GPT at shipout in the (re)definition of
> \shipout above causes \GPT at shipout to be expanded after the
> `{' of `\shipout\vbox' in the \plainoutput (and not after
> the `}'). Therefore, the `real' primitive \shipout happens
> at the beginning of that \vbox, shipping out \box255,
> without headline, footline or any insertions. After that
> \box255 becomes void, and the headline, footline and any
> insertions go into \box255, causing the `Output routine...'
> error message.
\shipout is called as:
\shipout\vbox{...}
The definition of shipout:
\gdef\shipout{%
\afterassignment\GPT at shipout
\global\setbox\@cclv=%
}%
Thus you are right, \GPT at shipout is called at the
beginning of \vbox:
\gdef\GPT at shipout{%
\ifvoid\@cclv\relax
\aftergroup\GPT@@shipout
\GPT at pageliteral
\else
\GPTorg at shipout\vbox{%
\GPT at pageliteral
\box\@cclv
}%
\fi
}%
But then, the idea of the code was to have a void
box 255. It's true in LaTeX, but not in plain.
> --- pdftex.def.orig 2005-08-02 19:32:15.000000000 +0300
> +++ pdftex.def 2005-08-02 19:35:44.000000000 +0300
> @@ -216,15 +216,18 @@
> \aftergroup\GPT@@shipout
> \GPT at pageliteral
> \else
> - \GPTorg at shipout\vbox{%
> - \GPT at pageliteral
> - \box\@cclv
> - }%
> + \aftergroup\GPT@@@shipout
However you cannot use \aftergroup, eg. there is no group:
\shipout\box255
The solution would be a separate box register to ensure
a void one in order to distinguish between:
\shipout\vbox{...} and \shipout\box...
Test file:
\input miniltx
\input color.sty
\def\set at page@color{%
\@ifundefined{GPT at outputbox}{%
% \newbox is outer in plain
\csname newbox\endcsname\GPT at outputbox
}{}%
\global\let\current at page@color\current at color
\@ifundefined{GPTorg at shipout}{%
\global\let\GPTorg at shipout\shipout
\gdef\shipout{%
\afterassignment\GPT at shipout
\global\setbox\GPT at outputbox=%
}%
\gdef\GPT at shipout{%
\ifvoid\GPT at outputbox\relax
\aftergroup\GPT@@shipout
\GPT at pageliteral
\else
\GPTorg at shipout\vbox{%
\GPT at pageliteral
\box\GPT at outputbox
}%
\fi
}%
\gdef\GPT@@shipout{%
\GPTorg at shipout\box\GPT at outputbox\relax
}%
\gdef\GPT at pageliteral{%
\pdfliteral direct{%
q % gsave
\current at page@color\space
n % newpath
0 0 \strip at pt\pdfpagewidth\space
\strip at pt\pdfpageheight\space re % rectangle
% there is no need to convert to bp
f % fill
Q% grestore
}%
}%
}{}%
}
\resetatcatcode
\pagecolor{yellow}
\begingroup
\color{blue}
Hello World
\endgroup
\vfill\break
Second page.
\bye
(This would apply to everyshi.sty also.)
If would be nice, if someone could confirm the analysis or
find errors.
Yours sincerely
Heiko <oberdiek at uni-freiburg.de>
--
More information about the pdftex
mailing list