[XeTeX] includegraphics works in XeTeX?

Bruno Voisin bvoisin at mac.com
Sun Feb 6 22:48:55 CET 2005


Le 1 févr. 05, à 10:40, Jonathan Kew a écrit :

> I think you need to specify the [xetex] option to the LaTeX graphics 
> package: something like
>
> 	\usepackage[xetex]{graphicx}
>
> If you check the list archives, I think someone (Ross? Bruno? Will?) 
> has described how to make this happen automatically, by adding a test 
> to the .sty files. But you should be able to specify it manually, at 
> least to get started.

I'm just finding this after coming back from a few days of holiday.

What I did is putting in ~/Library/texmf/tex/xetex/config/ slightly 
modified versions of color.cfg and graphics.cfg, as follows:

- For graphics.cfg:

> \ProvidesFile{graphics.cfg}%
>   [2001/08/31 v1.1 graphics configuration of teTeX/TeXLive]
>
> % Select an appropriate default driver
> \begingroup
>   \chardef\x=0 %
>   % check pdfTeX
>   \@ifundefined{pdfoutput}{}{%
>     \ifcase\pdfoutput
>     \else
>       \chardef\x=1 %
>     \fi
>   }%
>   % check VTeX
>   \@ifundefined{OpMode}{}{%
>     \chardef\x=2 %
>   }%
>   % check XeTeX
>   \@ifundefined{XeTeXversion}{}{%
>     \chardef\x=3 %
>   }%
> \expandafter\endgroup
> \ifcase\x
>   % default case
>   \ExecuteOptions{dvips}%
> \or
>   % pdfTeX is running in pdf mode
>   \ExecuteOptions{pdftex}%
> \or
>   % VTeX is running
>   \ExecuteOptions{vtex}%
> \else
>   % XeTeX is running
>   \ExecuteOptions{xetex}%
> \fi
>
> % Fix for dvips and xdvi versions that can uncompress
> % graphic files without an explicite call of gunzip.
> % (The fix is not applied for miniltx.tex, because
> % \AtEndOfPackage is not available in plainTeX.)
> \begingroup\expandafter\expandafter\expandafter\endgroup
> \expandafter\ifx\csname AtEndOfPackage\endcsname\relax
> \else
>   \AtEndOfPackage{%
>     \begingroup
>     \@ifundefined{DeclareGraphicsRule}{%
>       \endgroup
>     }{%
>       \def\x{dvips.def}%
>       \expandafter\endgroup
>       \ifx\x\Gin at driver
>         \DeclareGraphicsRule{.pz}{eps}{.bb}{}%
>         \DeclareGraphicsRule{.eps.Z}{eps}{.eps.bb}{}%
>         \DeclareGraphicsRule{.ps.Z}{eps}{.ps.bb}{}%
>         \DeclareGraphicsRule{.ps.gz}{eps}{.ps.bb}{}%
>         \DeclareGraphicsRule{.eps.gz}{eps}{.eps.bb}{}%
>       \fi
>     }%
>   }%
> \fi
> \endinput

- For color.cfg:

> \ProvidesFile{color.cfg}%
>   [2001/08/31 v1.1 color configuration of teTeX/TeXLive]
>
> % Select an appropriate default driver
> \begingroup
>   \chardef\x=0 %
>   % check pdfTeX
>   \@ifundefined{pdfoutput}{}{%
>     \ifcase\pdfoutput
>     \else
>       \chardef\x=1 %
>     \fi
>   }%
>   % check VTeX
>   \@ifundefined{OpMode}{}{%
>     \chardef\x=2 %
>   }%
>   % check XeTeX
>   \@ifundefined{XeTeXversion}{}{%
>     \chardef\x=3 %
>   }%
> \expandafter\endgroup
> \ifcase\x
>   % default case
>   \ExecuteOptions{dvips}%
> \or
>   % pdfTeX is running in pdf mode
>   \ExecuteOptions{pdftex}%
> \or
>   % VTeX is running
>   \ExecuteOptions{vtex}%
> \else
>   % XeTeX is running
>   \ExecuteOptions{xetex}%
> \fi
> \endinput

This is especially useful for packages that load automatically the 
color and/or graphics packages, without letting the user specify the 
option explicitly. (The beamer class might do this, if I remember well 
-- not sure though.)

That said, given the texmf/tex/xetex directory is, I think, only 
searched when using XeTeX, the above is probably unnecessary and you 
only need to create files ~/Library/texmf/tex/xetex/config/color.cfg 
and ~/Library/texmf/tex/xetex/config/graphics.cfg containing the single 
line:

> \ExecuteOptions{xetex}

What indicates that texmf/tex/xetex is only searched when using XeTeX? 
The lines (edited for clarity)

> % Plain TeX.
> TEXINPUTS.tex = .;$TEXMF/tex/{plain,generic,}//
>
> % LaTeX 2e.
> TEXINPUTS.latex = .;$TEXMF/tex/{latex,generic,}//
>
> % e-TeX.
> TEXINPUTS.elatex   = .;$TEXMF/{etex,tex}/{latex,generic,}//
> TEXINPUTS.etex     = .;$TEXMF/{etex,tex}/{plain,generic,}//
>
> % pdfTeX.
> TEXINPUTS.pdflatex = .;$TEXMF/{pdftex,tex}/{latex,generic,}//
> TEXINPUTS.pdftex   = .;$TEXMF/{pdftex,tex}/{plain,generic,}//
>
> % pdfeTeX.
> TEXINPUTS.pdfelatex = 
> .;$TEXMF/{pdfetex,pdftex,etex,tex}/{latex,generic,}//
> TEXINPUTS.pdfetex   = 
> .;$TEXMF/{pdfetex,pdftex,etex,tex}/{plain,generic,}//
>
> % XeTeX
> TEXINPUTS.xelatex =	.;$TEXMF/{xetex,tex}/{xetex,latex,generic,}//
> TEXINPUTS.xetex   =	.;$TEXMF/{xetex,tex}/{xetex,plain,generic,}//

in /usr/local/teTeX/share/texmf/web2c/texmf.cnf.

Bruno Voisin



More information about the XeTeX mailing list