10

I thought that loading a package twice with the same options cannot lead to option clash, still I get a clash in the following simple example:

\documentclass{article}
\RequirePackage[patch]{kvoptions}
\RequirePackage[patch]{kvoptions}
\begin{document}
Hello World!
\end{document}

This is a MnWE, what I really want to achieve is to create two dependent classes like this:

myclass.cls

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{myclass}[2012/05/24 v1.0 My Class]

\RequirePackage[patch]{kvoptions}

\endinput

anotherclass.cls

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{anotherclass}[2012/05/24 v1.0 Another Class]

\RequirePackage[patch]{kvoptions}

% I need to use some features of `kvoptions` here

\LoadClass{myclass}

\endinput

test.tex

\documentclass{anotherclass}
\begin{document}
Hello World!
\end{document}

Version information

  • It works properly with LaTeX2e <2005/12/01> (TeXLive installed 2009)
  • It does not work with LaTeX2e <2011/06/27> (TeXLive installed 2012)
3
  • your MWE works for me - no clash Jun 2, 2012 at 11:03
  • It works in my old TeXlive2009. But it does not work with a TeXlive that I installed 2 days ago from the web...
    – yo'
    Jun 2, 2012 at 11:28
  • strange ... it does here ... (c:/texlive/2011/texmf-dist/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (c:/texlive/2011/texmf-dist/tex/latex/base/size10.clo)) (c:/texlive/2011/texmf-dist/tex/latex/oberdiek/kvoptions.sty (c:/texlive/2011/texmf-dist/tex/latex/graphics/keyval.sty) (c:/texlive/2011/texmf-dist/tex/generic/oberdiek/ltxcmds.sty) ... So looks like it also worked with TL2011 but not with the current version from the web Jun 2, 2012 at 11:41

2 Answers 2

7

use

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{myclass}[2012/05/24 v1.0 My Class]

\PassOptionsToPackage{patch}{kvoptions}
\RequirePackage{kvoptions}

\endinput

and the same for your example:

\PassOptionsToPackage{patch}{kvoptions}
\documentclass{article}
\RequirePackage{kvoptions}
\RequirePackage{kvoptions}
\begin{document}
Hello World!
\end{document}
2
  • 1
    What is the exact difference of latex's treatment of \RequirePackage[<put_options_here>]{package} and \PassOptionsToPackage{<put_options_here>]{package}? I don't see why there should be any difference...
    – yo'
    Jun 2, 2012 at 11:27
  • It seems to work, still I'm interested why the difference...
    – yo'
    Jun 2, 2012 at 11:36
6

The documentation of kvoptions says, on page 12

• Since 2008/10/18 v3.0 package kvoptions-patch is available. Before option patch of package kvoptions must be used instead. I think, the solution as standalone package kvoptions-patch is cleaner and avoids option clashes.

So use

\RequirePackage{kvoptions-patch}
\RequirePackage{kvoptions}
3
  • still where is the class in the original MWE? Jun 2, 2012 at 11:06
  • @egreg It is nice that kvoptions has an alternative and thanks for it, but the problem is more general in my opinion.
    – yo'
    Jun 2, 2012 at 11:25
  • 1
    @tohecz You have to call both packages: it's kvoptions that defines \DeclareVoidOption.
    – egreg
    Jun 2, 2012 at 12:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .