Welcome to the UK List of
TeX Frequently Asked Questions
on the Web

Searching

The index of Frequently Asked Questions about TeX is searchable.

Please enter your keyword here:   then press here: ,    or:
Google

Package reports “command already defined”

You load a pair of packages, and the second reports that one of the commands it defines is already present. For example, both the txfonts and amsmath define a command \iint (and \iiint and so on); so

...
\usepackage{txfonts}
\usepackage{amsmath}

produces a string of error messages of the form:

! LaTeX Error: Command \iint already defined.
               Or name \end... illegal, see p.192 of the manual.

As a general rule, things that amsmath defines, it defines well; however, there is a good case for using the txfonts version of \iint — the associated tx fonts have a double integral symbol that doesn’t need to be “faked” in the way amsmath does. In the case that you are loading several symbol packages, every one of which defines the same symbol, you are likely to experience the problem in a big way (\euro is a common victim).

There are similar cases where one package redefines another’s command, but no error occurs because the redefining package doesn’t use \newcommand. Often, in such a case, you only notice the change because you assume the definition given by the first package. The amsmathtxfonts packages are just such a pair; txfonts doesn’t provoke errors.

You may deal with the problem by saving and restoring the command. Macro programmers may care to do this for themselves; for the rest of us, there’s the package savesym. The sequence:

\usepackage{savesym}
\usepackage{amsmath}
\savesymbol{iint}
\usepackage{txfonts}
\restoresymbol{TXF}{iint}

does the job; restoring the amsmath version of the command, and making the txfonts version of the command available as \TXFiint.

Documentation of savesym doesn’t amount to much: the only commands are \savesymbol and \restoresymbol, as noted above.

amsmath.sty
Part of macros/latex/required/amslatex (or browse the directory); catalogue entry
savesym.sty
macros/latex/contrib/savesym/savesym.sty; catalogue entry
txfonts.sty
Part of fonts/txfonts (or browse the directory); catalogue entry


Go to previous question, or next question

Go to FAQ home.

URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=alreadydef

Comments, suggestions, or error reports? - see “how to improve the FAQ”.

This is FAQ version 3.27, released on 2013-06-07.