LaTeX Error: Command \<name> already defined.

\newcommand or a package tried to define a name that already exists. Pick another name, use \renewcommand, or drop the clashing package.

Help centre › LaTeX errors › Commands and packages · Error: the build stops or the output is wrong

What the log says

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

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

Also printed as: LaTeX Error: Command `\<name>' already defined.; Or name \end... illegal, see p.192 of the manual.

What it means

\newcommand and \newenvironment refuse to overwrite a name that is already in use, so that you do not silently break a command LaTeX or a package relies on. The name in the message is taken: by LaTeX itself, by a package, or by an earlier definition in your own preamble. The second line, about \end..., is a fixed part of the message and applies only to names beginning with end.

Causes and fixes

Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.

1. Your \newcommand uses a name LaTeX already has

Short names are often taken: \d (an accent), \c, \b, \v, \H, \L, \P, \S. Choose another name (\dd, \diff). Use \renewcommand only if you are sure the original is not needed anywhere, including in packages.

Fails
\documentclass{article}
\newcommand{\d}{\mathrm{d}}
\begin{document}
$\int f(x) \d x$
\end{document}
Fixed
\documentclass{article}
\newcommand{\dd}{\mathrm{d}}
\begin{document}
$\int f(x) \dd x$
\end{document}

2. A new environment with the name of an existing one

\newenvironment{proof} with amsthm loaded (or with a class that defines proof) reports Command \proof already defined. Use the existing environment, or give yours another name.

Fails
\documentclass{article}
\usepackage{amsthm}
\newenvironment{proof}{\textit{Proof.}}{}
\begin{document}
\begin{proof} Trivial. \end{proof}
\end{document}
Fixed
\documentclass{article}
\usepackage{amsthm}
\begin{document}
\begin{proof} Trivial. \end{proof}
\end{document}

3. Two packages define the same symbol

Font packages such as newtxmath, mathptmx-style Times fonts or mathabx already provide the AMS symbols, and loading amssymb after them stops at Command \Bbbk already defined (the quoted form of the message). Remove amssymb (the font package supplies its symbols), or load amssymb before the font package if the class allows it.

Fails
\documentclass{article}
\usepackage{newtxmath}
\usepackage{amssymb}
\begin{document}
$\mathbb{R}$
\end{document}
Fixed
\documentclass{article}
\usepackage{newtxmath}
\begin{document}
$\mathbb{R}$
\end{document}

4. The same definition appears twice

Preambles merged from several papers, or a shared macros file loaded with \input that is also pasted in, define the same command twice. Keep one copy; use \providecommand in shared files so a second definition is skipped.

5. A new command whose name begins with end

\newcommand{\endthing} is refused because LaTeX reserves \end… names for the ends of environments. Choose another name.

In Manulyx

For \Bbbk already defined with amssymb after a Times-style maths font the editor offers a one-click Fix that comments out amssymb; other cases show the explanation beside the line.

Write in Manulyx for free · Journal templates

More in commands and packages

Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors