Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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)
share|improve this question
    
your MWE works for me - no clash –  Frank Mittelbach Jun 2 '12 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... –  tohecz Jun 2 '12 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 –  Frank Mittelbach Jun 2 '12 at 11:41

2 Answers 2

up vote 5 down vote accepted

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}
share|improve this answer
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... –  tohecz Jun 2 '12 at 11:27
    
It seems to work, still I'm interested why the difference... –  tohecz Jun 2 '12 at 11:36

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}
share|improve this answer
    
still where is the class in the original MWE? –  Frank Mittelbach Jun 2 '12 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. –  tohecz Jun 2 '12 at 11:25
1  
@tohecz You have to call both packages: it's kvoptions that defines \DeclareVoidOption. –  egreg Jun 2 '12 at 12:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.