TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Which document class is being used?

I'd like to include conditional formatting in a .sty file, conditional on the document class of the document that invokes it.

For example, I'd like to redefine the \section command like this for all article, letter, and book document classes, but have no special formatting for documents making use of the beamer class.

\renewcommand*\section{\@startsection {section}{1}{\z@}%
                               {-3.5ex \@plus -1ex \@minus -.2ex}%
                               {2.3ex \@plus.2ex}%

I'd appreciate any help on how to do this.

share|improve this question

marked as duplicate by lockstep, Andrey Vihrov, Mike Renfro, egreg, Marco Daniel Feb 5 '12 at 22:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@lockstep you are true and my answer below provides moreorless the exact copy of the macro \@ifclassloaded – yo' Feb 5 '12 at 22:04
Consider writing custom document classes based off of article, book, letter, and putting the section-formatting commands in each class instead. I normally put specific formatting into a class file instead of a generic style file. – Mike Renfro Feb 5 '12 at 22:06
up vote 1 down vote accepted

Edit: the same macro as I provide below is a part of LaTeX core. It is called \@ifclassloaded and has the exactly same usage as my \IfClass below, which is therefore useless.




\IfClass{article}{ARTICLE YES}{ARTICLE NO}

\IfClass{report}{REPORT YES}{REPORT NO}

share|improve this answer

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