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.
\documentclass{article}
\newcommand{\d}{\mathrm{d}}
\begin{document}
$\int f(x) \d x$
\end{document}\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.
\documentclass{article}
\usepackage{amsthm}
\newenvironment{proof}{\textit{Proof.}}{}
\begin{document}
\begin{proof} Trivial. \end{proof}
\end{document}\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.
\documentclass{article}
\usepackage{newtxmath}
\usepackage{amssymb}
\begin{document}
$\mathbb{R}$
\end{document}\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
- Missing number, treated as zero.A command that needs a number or length (\vspace, \setcounter, a width) got a word or nothing. Give it a value such as 1em or 3.
- Illegal parameter number in definition of \<name>.A # in a definition does not refer to a declared argument: #1 without [1], #1 in an environment's end code, or a # in a URL. Fix the count or escape it.
- Use of \<name> doesn't match its definition.A command with a special argument syntax, such as \put(x,y) or a \def with delimiters, was called without that syntax. Follow its exact form.
- LaTeX Error: Environment <name> undefined\begin{…} names an environment no loaded package defines: load the package (amsmath for align), fix the spelling, or define it with \newtheorem.
- LaTeX Error: Option clash for package <name>A package is loaded twice with different options, often because the class or another package loaded it first. Load it once, with all options.
- LaTeX Error: Unknown option `<opt>' for package `<pkg>'A package was given an option it does not accept: a typo, an option meant for the class or another package, or a babel language name it does not know.
Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors