[lltx] fontspec/keyval clash

Heiko Oberdiek heiko.oberdiek at googlemail.com
Fri Dec 28 09:44:27 CET 2012


On Fri, Dec 28, 2012 at 04:23:39AM +0100, Reinhard Kotucha wrote:

> the following works with LuaTeX:
> 
>  \documentclass{minimal}
>  \RequirePackage[final]{graphicx}
>  \RequirePackage{fontspec}
>  \stop
> 
> However, if load fontspec before graphicx 
> 
>  \documentclass{minimal}
>  \RequirePackage{fontspec}
>  \RequirePackage[final]{graphicx}
>  \stop
> 
> I get
> 
>   ! LaTeX Error: Option clash for package graphicx.
> 
> It seems that fontspec screws up the keyval package somehow.

It's unrelated to package `keyval'.

Package `fontspec' loads package `xunicode' and the latter package
requires `graphicx'. Then, if LaTeX gets another package loading request
of a package that is already loaded, then it checks the options. The
specified options must be a subset of the options that are present at
loading time. Otherwise LaTeX throws the option clash error.

  \RequirePackage{graphicx}
  \RequirePackage[final]{graphicx}% --> error

Solution: The first loading of the package needs all options:

  \RequirePackage[final]{graphicx}
  \RequirePackage{graphicx}% --> ok

Or in this case, \PassOptionsToPackage helps:

  \PassOptionsToPackage{final}{graphicx}
  \RequirePackage{graphicx}% inside fontspec/xunicode
  \RequirePackage[final]{graphicx}% --> now ok

Yours sincerely
  Heiko Oberdiek


More information about the lualatex-dev mailing list