I'm writing a package that will need to know whether the document is using memoir, report, or article class. This is because memoir uses array.sty which doesn't allow variables to be used in some places where report and article do.
Does anyone know of a way to test which class is being used for a document? I could test whether a certain variable is set, but I'd rather see whether one can test for a class.
TIA
Document Classes ⇒ Testing for which class is being used
Testing for which class is being used
Last edited by bev on Tue Nov 16, 2010 11:20 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Testing for which class is being used
The \@ifclassloaded command from the LaTeX kernel is your friend. It can be found in the file »latex.ltx« and should be documented in source2e. You can access the documentation via command line on your local machine.
I'm pretty sure that some packages use this command but at the moment I can't name any of them. Their sources could give you more information.
Best regards and welcome to the board
Thorsten
Code: Select all
texdoc source2e
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Testing for which class is being used
Thorsten,
Thanks for the welcome, and thanks for the help
. I haven't had a chance to try your solution yet, but I will first thing tomorrow. It seems like just what I'm looking for. After I confirm that it solves my problem, I'll post here.
best,
Bev
Thanks for the welcome, and thanks for the help

best,
Bev
Re: Testing for which class is being used
Thorsten,
Thanks again for your help. I've confirmed that your solution works.
Thanks again for your help. I've confirmed that your solution works.