# conditional commands in .sty file, conditional on \documentclass [duplicate]

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}%
{\normalfont\Large}}

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

-

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

@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

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.

\documentclass{article}

% THIS IS THE CODE YOU NEED
\makeatletter
\def\IfClass#1#2#3{\@ifundefined{opt@#1.cls}{#3}{#2}}
\makeatother
% END OF THE CODE

\begin{document}

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

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

\end{document}
-