I'm writing a package and already added two options with \DeclareOption
. Then with \ExecuteOptions
I set the default option. This works really well, but now I have to add a second option type and this does not seem to work.
Let me explain what I mean by option type. The first couple of options (remember, those that worked well) defined a language (I made custom translations using the translations
package and this option passes the language to the translations package and to babel), so only one of them was passed, e.g. \usepackage[en]{myPackage}
. What I try to do now is passing a second option to my package, where there are also two possibilities of choosing (whether the bibliography is sorted by name or by appearance), so the usepackage command should look like this: \usepackage[en, bib-by-appearance]{myPackage}
.
What I've done is the following:
\DeclareOption{de}{%
% Some Code
}
\DeclareOption{en}{%
% Some Code
}
\DeclareOption{bib-by-name}{%
\bibliographystyle{abbrvnat}%
}
\DeclareOption{bib-by-appearance}{%
\bibliographystyle{template-files/custom-abbrvnat}%
}
\ExecuteOptions{en, bib-by-appearance}
\ProcessOptions\relax
This does not seem to work. How am I supposed to define the options to get my result?
Update
I was asked to deliver an MWE and I normally also do post one, but I am unable to reproduce this behaving... I normally do my MWE's with ShareLaTeX because I find it more simple to set up a small document, well I now ended up uploading my whole project and compiling it. With ShareLaTeX it works well, while it doesn't on my machine. My computer says
Package natbib: Citation 'FooBar' on page 1 undefined.
while it should be defined (and it also does like the ShareLaTeX example shows). I also tested to simply use \bibliographystyle{template-files/custom-abbrvnat}
without selecting it via an option. This also works well. So it seems that my computer has trouble to do his job if the bibstyle is set by an option.
The fail happens if I change \ExecuteOptions{en}
to \ExecuteOptions{en, bib-by-appearance}
. So I am able to \DefineOption
the two possibilities, I am also able to use both bibstyles if called directly (without the option) but I fail when setting the default value of my package to be en, bib-by-appearance
.
Update 2
I now also tested what would happen if I directly set the language, without using the options, so the \ExecuteOptions
would only contain the bib-by-appearance
and this works. So I think I've located the issue. Now my question is:
Why isn't it working with the two options? How can I make it work?
Feel free to shout out any guess that comes in your mind, I'm happy to try them out. If I can deliver anything else than an MWE, let me know.
bib-by-appearance
but used\usepackage[english, by-appearance]{myPackage}
without thebib-
prefix.% some code
stuff is fine, but this is not a working code snippet. Could you please create a compilable minimal working example?latexmk: Failure in some part of making files.
and several:Package natbib: Citation
FooBar` on page 1 undefined.`. Again, this does not happen on ShareLaTeX.