20

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 
1

2 Answers 2

20

A way is

\makeatletter \@ifclassloaded{IEEEtran}{}{\usepackage{appendix}} \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?

1
  • 1
    I do not plan to use appendix commands in this conference submission , but I use that commands in my thesis. Commented Feb 29, 2012 at 10:51
3

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.

4
  • This will do nothing for all classes that define \appendix, including article, report, book, memoir. Commented Feb 29, 2012 at 22:23
  • @Matthew: Please something is wrong with your use of \ifcsname! Commented Mar 1, 2012 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. Commented Mar 10, 2012 at 12:32
  • @AhmedMusa: Yes, I was missing \endcsname. Thanks for noticing. Commented Mar 10, 2012 at 12:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.