Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

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 –  tohecz 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

1 Answer 1

up vote 0 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.

\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}
share|improve this answer

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