I wrote a small package that I used to typeset a book. Now, I'd like to reuse it for smaller documents. The package uses tcolorbox
and defines a box like this:
\newtcblisting[auto counter,
number within=chapter,
crefname={Lis.}{Lis.},
...
The only thing I need to change when writing shorter documents is to remove the line number within=chapter
.
I'm not sure how to achieve that. What's the best way:
- Use an
if
to somehow test if counterchapter
is defined? - Use an
if
to somehow test the document class (e.g.,book
vsarticle
)? - Add an option to the package and test it to include/exclude
number within
?
I have very little experience developing packages, and I'll welcome any help on this question.
Thanks in advance.