2

I've recently written my own personal package (let's call it mypkg), which contains all the math macros I use on a regular basis. I would like to get this package to work with beamer. My package loads amsthm and then proceeds to define several theorem environments, e.g. theorem, lemma, corollary, etc. However, this clashes with beamer, since beamer defines these environments internally as well. Consequently, I get errors when trying to load mypkg in a beamer document.

What I would like to do is define a beamer option in mypkg, and then I can call \usepackage[beamer]{mypkg} when using mypkg in a beamer document. I see there is a \DeclareOption command which allows you to define certain things if the specified option is declared when calling the package. What I would like to do is the opposite; define those theorem environments only if the beamer option is not entered. How can I do this?

Bonus points if there is a way to automatically feed the documentclass to mypkg and have it do such things as required.

  • 2
    Use a \provideenvironment to define environments only if necessary: https://tex.stackexchange.com/a/20691/193767 –  Apr 16 '20 at 04:13
  • @JairoADelRio nice solution for environments. What about for calling packages inside mypkg that are incompatible with beamer, e.g. enumitem? Or defining other commands. – Jordan Mitchell Barrett Apr 16 '20 at 04:58
  • 1
    You can set a boolean in \DeclareOption and then do something depending on its value later. But for testing the class it is easiest to do \@ifclassloaded{beamer}{stuff only for beamer}{stuff not for beamer} – Ulrike Fischer Apr 16 '20 at 11:52
  • Did the above comments help you solve your problem ? – BambOo May 13 '20 at 11:18

0 Answers0