Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem using color and graphicx in plain TeX

134 views
Skip to first unread message

Julian Aguirre

unread,
Nov 17, 2005, 11:42:23 AM11/17/05
to
I put pictures in plain TeX documents using

\input graphicx
\includegraphics{MyPicture}
\bye

I can also color text with

\input color
\textcolor{red}{bbb}
\bye

But I am not able two get both color AND pictures. The following example

\input color
\input graphicx
\bye

produces the error message

! Use of \@ doesn't match its definition.
l.27 \@m
akeother\"%
Changing the order of the \input's produces a different message:

! Undefined control sequence.
<argument> \@notdefinable

\@secondoftwo #1#2->#2

l.72 ...nextchar[\@undeclaredcolor\@declaredcolor}

I am using pdftex in MacOS X 10.4.3 ( Gerben Wierda's installation) and
TeXshop. From the log window:

This is pdfeTeX, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5)

How can I make the two packages work together?
Thank you in advance,

Julian Aguirre
Universidad del Pais Vasco

Dan

unread,
Nov 17, 2005, 6:55:27 PM11/17/05
to

Julian Aguirre wrote:
> I put pictures in plain TeX documents using
>
> \input graphicx
> \includegraphics{MyPicture}
> \bye
>
> I can also color text with
>
> \input color
> \textcolor{red}{bbb}
> \bye
>
> But I am not able two get both color AND pictures. The following example
>
> \input color
> \input graphicx
> \bye
>

This:
\input color
\makeatletter
\input graphicx
\bye

seems to work.

When I need graphics or color in plain tex, I use the following code in
a personal
macro file:

\input miniltx
\makeatletter
\ifx\Gin@driver\undefined
\def\Gin@driver{dvips.def}
\fi
\input graphicx.sty
\resetatcatcode

And a similar set of commands for inputting color.sty. The little \ifx
test is so that I can change the driver by defining \Gin@driver before
inputting these macros.


Dan

Julian Aguirre

unread,
Nov 18, 2005, 4:37:53 AM11/18/05
to
Dan wrote:
>
> Julian Aguirre wrote:
>> I put pictures in plain TeX documents using
>>
>> \input graphicx
>> \includegraphics{MyPicture}
>> \bye
>>
>> I can also color text with
>>
>> \input color
>> \textcolor{red}{bbb}
>> \bye
>>
>> But I am not able two get both color AND pictures. The following example
>>
>> \input color
>> \input graphicx
>> \bye
>>
> This:
> \input color
> \makeatletter
> \input graphicx
> \bye
>
> seems to work.

Thank you for your answer, but things are getting more misterious (at
least to me).

\input color
\makeatletter
\input graphicx

\includegraphics[width=.4\hsize]{LogoUned}
\bye

works as expected BUT

\input color
\makeatletter
\input graphicx

\textcolor{red}{Hola}
\bye

produces no output (it seems like if TeX stopped processing inmediatly
after reading the \textcolor command).

Dan

unread,
Nov 18, 2005, 3:23:40 PM11/18/05
to

Julian Aguirre wrote:

> Dan wrote:
> > This:
> > \input color
> > \makeatletter
> > \input graphicx
> > \bye
> >
> > seems to work.
>
> Thank you for your answer, but things are getting more misterious (at
> least to me).
>
> \input color
> \makeatletter
> \input graphicx
> \includegraphics[width=.4\hsize]{LogoUned}
> \bye
>
> works as expected BUT
>
> \input color
> \makeatletter
> \input graphicx
> \textcolor{red}{Hola}
> \bye

I just realized you are using pdftex. You must use tex+dvips with
graphicx.tex and color.tex as they are written. They explicitly set the
driver file to dvips.def. Some versions of graphics.cfg and color.cfg
will override that, but even if it is changed to pdftex.def, there are
problems: as you say \textcolor seems to hang.

I'll try to diagnose this and see if a work-around can be found.
However, pdftex and support files change frequently and miniltx perhaps
hasn't kept up.


Dan

Dan

unread,
Nov 18, 2005, 4:28:38 PM11/18/05
to

Dan wrote:
>
> I just realized you are using pdftex. You must use tex+dvips with
> graphicx.tex and color.tex as they are written. They explicitly set the
> driver file to dvips.def. Some versions of graphics.cfg and color.cfg
> will override that, but even if it is changed to pdftex.def, there are
> problems: as you say \textcolor seems to hang.
>
> I'll try to diagnose this and see if a work-around can be found.
> However, pdftex and support files change frequently and miniltx perhaps
> hasn't kept up.

The diagnosis: it appears that pdftex.def is loaded twice. I believe
LaTeX prevents that from happening. In that file there is code that
saves the ``current'' definition of \color in \@ldc@l@r and redefines
\color to <something>\@ldc@l@r. However, the second time through, the
current definition is the same as this one, so \color is defined in
terms of itself producing infinite recursion (resulting in TeX
hanging).

The perfect solution would be to modify pdftex.def so it detects its
second loading and exits. Alternatively, perhaps the plain graphics
package could be modified to prevent
this. More later if I can figure something out.


Dan

Dan

unread,
Nov 18, 2005, 5:03:51 PM11/18/05
to

The following works in my plain TeX file:

\input miniltx
\makeatletter
\def\Gin@driver{pdftex.def}
\input color.sty
\@namedef{v...@pdftex.def}{}
\input graphicx.sty
\resetatcatcode

\textcolor{red}{Hola}
\includegraphics[width=.4\hsize]{image2.pdf}

\bye

The 5th line defines \v...@pdftex.def. The existence of a definition for
this is used by graphicx.sty to determine whether the file has already
been loaded. LaTeX's \ProvidesFile command, issued at the start of
every LaTeX input file, defines this command, but miniltx skips that
part in its substitute \def of \ProvidesFile.


Dan

Dan

unread,
Nov 18, 2005, 5:21:32 PM11/18/05
to

Dan wrote:

>
> The following works in my plain TeX file:
>
> \input miniltx
> \makeatletter
> \def\Gin@driver{pdftex.def}
> \input color.sty
> \@namedef{v...@pdftex.def}{}
> \input graphicx.sty
> \resetatcatcode
>
> \textcolor{red}{Hola}
> \includegraphics[width=.4\hsize]{image2.pdf}
>
> \bye
>
> The 5th line defines \v...@pdftex.def. The existence of a definition for
> this is used by graphicx.sty to determine whether the file has already
> been loaded. LaTeX's \ProvidesFile command, issued at the start of
> every LaTeX input file, defines this command, but miniltx skips that
> part in its substitute \def of \ProvidesFile.

This modification of miniltx.tex works in simple cases:
Change:
\def\ProvidesPackage#1{\@ifnextchar[%
{\@pr@videpackage{#1}}{\@pr@videpackage#1[]}}
\def\@pr@videpackage#1[#2]{\wlog{#1: #2}}
\let\ProvidesFile\ProvidesPackage

to:
\def\ProvidesFile#1{\@ifnextchar[%
{\@pr@videfile{#1}}{\@pr@videfile#1[]}}
\def\@pr@videfile#1[#2]{\wlog{#1: #2}\@namedef{ver@#1}{#2}}
\def\ProvidesPackage#1{\ProvidesFile{#1.sty}}


Dan

Karl Berry

unread,
Nov 19, 2005, 12:20:43 PM11/19/05
to
BTW, it is possible to load color and graphicx in Eplain now. (And a
few other miniltx-compatible packages.) http://tug.org/eplain

The code would look like this:
\ilet\primitiveinput=\input
\input eplain
\beginpackages
\usepackage{color}
\usepackage{graphics}
\endpackages
\let\input=\primitiveinput

(The \input stuff is because miniltx redefines \input to be as in
LaTeX, which is unlikely to be what plain users want. The next version
of Eplain might do it automatically.)

HTH,
karl

Oleg Katsitadze

unread,
Nov 19, 2005, 1:24:59 PM11/19/05
to
Karl Berry wrote:
> BTW, it is possible to load color and graphicx in Eplain now.

It also supports (hopefully) all package options for color and
graphic{s,x}, and detects pdftex automatically. One option that does
not yet work is `draft'; to use it, add the following after `\input
eplain' and before the packages:

\makeatletter
\let\ttfamily\ttfam
\def\strip@prefix#1>{}
\makeatother

This should be fixed in the next version, too.

Julian Aguirre

unread,
Nov 21, 2005, 9:04:36 AM11/21/05
to
Thanks to all who contributed to this thread. I cannot follow most of the
technical discussion, but Dan's solution below works OK.

Julian Aguirre

0 new messages