0

In order to have iso dates on my class-generated title page, I would have to load isodate before calling \AtBeginDocument since this MVE

\documentclass{scrartcl}
                                  % good position for isodate
\AtBeginDocument{\today}
\usepackage[ngerman,iso]{isodate} % bad position for isodate

\begin{document}
\par\today
\end{document}

generates this undesirable output

enter image description here

However, my corporate style class does not load isodate by default and I would like to leave this up to the user of my class in case they want iso dates -- which produces the situation shown.

I understand that the order of package loading and defining commands sometimes is crucial. I would like to know if there is any way to circumvent this problem. Can I do anything to load isodate after using \AtBeginDocument?

  • The cheap way out is to add an option to your class to load isodate. If the user wants ISO dates she sets the option, isodate is loaded before \AtBeginDocument, everything is fine. If she doesn't want ISO dates, she doesn't set the option, no isodate is loaded (and the user has no reason to load isodate later manually), everything is fine again. Of course that requires documentation (if you want ISO dates, use the option, don't google stuff and use that), but might be better than nothing. – moewe Jan 15 at 10:32
  • 1
    In this case the issue is that isodate does its own setup in \AtBeginDocument and depending on the order you come in before that or too late. You could of course try to start there and try to manipulate the hook (similar to say tex.stackexchange.com/q/464682/35864). Or you could try to detect if the package has been loaded after your \AtBeginDocument hook and try to salvage the situation then. But all that is probably going to get really messy. – moewe Jan 15 at 10:49
2

You can tell users to load the package before the class:

\RequirePackage[ngerman,iso]{isodate}
\documentclass{scrartcl}

\AtBeginDocument{\today}


\begin{document}
\par\today
\end{document}

But adding a date option to the class would be better, if that is a possibility.

  • +1 for the option. – moewe Jan 15 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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