Document ClassesTesting for which class is being used

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
User avatar
bev
Posts: 20
Joined: Wed Nov 10, 2010 10:02 am

Testing for which class is being used

Post by bev »

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
Last edited by bev on Tue Nov 16, 2010 11:20 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Testing for which class is being used

Post by localghost »

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.

Code: Select all

texdoc source2e
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
User avatar
bev
Posts: 20
Joined: Wed Nov 10, 2010 10:02 am

Re: Testing for which class is being used

Post by bev »

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
User avatar
bev
Posts: 20
Joined: Wed Nov 10, 2010 10:02 am

Re: Testing for which class is being used

Post by bev »

Thorsten,
Thanks again for your help. I've confirmed that your solution works.
Post Reply