FormaTeX
FatalCommands & Packages

Command Already Defined

! LaTeX Error: Command \XXX already defined.

What this error means

You used \newcommand to define a command that already exists. LaTeX refuses to silently overwrite existing commands, which prevents hard-to-debug redefinition bugs.

Common causes

  • Using \newcommand for a command defined by a loaded package
  • Defining the same command twice in your document
  • Two packages both define the same command name

How to fix it

Use \renewcommand instead of \newcommand if you intentionally want to override an existing command. If the conflict is between two packages, load them in a different order or use the \let technique to save and restore the original.

Code examples

Causes the error
\documentclass{article}
\usepackage{amsmath}

% \text is already defined by amsmath
\newcommand{\text}[1]{\textit{#1}}

\begin{document}
Hello
\end{document}
Fixed
\documentclass{article}
\usepackage{amsmath}

% Use \renewcommand to override safely
\renewcommand{\text}[1]{\textit{#1}}

\begin{document}
Hello
\end{document}

Related errors

Test the fix live

Paste your LaTeX into the playground and compile instantly.

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy