Lets say you are writing a package, which has the usual pair of draft
and final
-mode.
But how should I handle, if this package gets the global option final
and the local draft
?
Consider the following ex.sty:
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{ex}[2014/07/26 v1.00 This is just an example]
\DeclareOption{draft}{\newcommand\@draftmode{true}}
\DeclareOption{final}{\let\@draftmode=\@undefined}
\ProcessOptions\relax
\ifdefined\@draftmode
\newcommand\example{%
an example text, only visible in draft mode}
\else
\let\example=\relax
\fi
Using that in the following main.tex:
\documentclass[final]{article}
\usepackage[draft]{ex}
\begin{document}
some example text and eventually some more text: \example.
\end{document}
Results in the output “some example text and eventually some more text: .”. If I swap the \DeclareOption
(final
first, then draft
), then at least I have the output of \example
. But then it wouldn't work if I swap the options in the main.tex…
So what is the LaTeX way to handle this?
- Check if both options are set and then fire an error? (and how to check for both options?)
- Check if both options are set and then fire a warning?
- Prefer global option over local option? (how to check if a given option is global or local?)
- Prefer local option over global option?
- Just do it as I have and live with its problems? (how to decide which order might be more sens?)
- Use a package that I haven't found yet but really helps with such stuff?