# If document class is equal to something then do not use package

I am trying to create a file which includes common packages and macros I use. It is something like this.

commonDefinitions.tex

 \interdisplaylinepenalty=2500
\usepackage{algorithmic}

\usepackage{cite}
\usepackage{appendix}
... other packages and macros


But some packages clash with each other in combinations. For example when I try to use

 \documentclass[journal]{IEEEtran}
\usepackage{appendix}


It gives error since IEEEtran already created command appendix.

I would like to get some solution to this problem something like below.

if document class is not IEEEtran
\usepackage{appendix}
end if

-

A way is

\makeatletter
\makeatother


But I believe that documents written for submission should not have any reference to conflicting packages (and so tricks like this one). How would you use the commands provided by appendix if the document class is IEEEtran?

-
I do not plan to use appendix commands in this conference submission , but I use that commands in my thesis. –  Atilla Ozgur Feb 29 '12 at 10:51

I was advised once to test on functionality rather than on class name. The problem is that both appendix.sty and IEEEtran.cls defines \appendices. So only load the appendix package if there isn't already a command \appendices defined. Here is a working example:

\documentclass{IEEEtran}
\title{Test of conditional use of the appendix package}
\usepackage{lipsum} % just for dummy text
\ifcsname appendices\endcsname
% do nothing
\else
\usepackage{appendix}
\fi

\begin{document}
\maketitle

\section{Foo}

\lipsum

\section{Bar}

\lipsum

\appendix

\section{Appendix}

\lipsum

\end{document}


\ifcsame is available on all e-TeX builds and is documented (along with other ways to check if a command is defined) here.

-
This will do nothing for all classes that define \appendix, including article, report, book, memoir. –  egreg Feb 29 '12 at 22:23
@Matthew: Please something is wrong with your use of \ifcsname! –  Ahmed Musa Mar 1 '12 at 2:22
@egreg: I thought that's what the OP wanted. He said the problem was the existence of the command \appendix. After creating a MWE I see that's not the problem: it's the existence of the command \appendices. I've updated my answer so that appendix.sty is loaded in article.cls, etc. –  Matthew Leingang Mar 10 '12 at 12:32
@AhmedMusa: Yes, I was missing \endcsname. Thanks for noticing. –  Matthew Leingang Mar 10 '12 at 12:32