LaTeX error "Command \vec already defined": cause and fix

Error Command \vec already defined

\newcommand, \newenvironment and \newcounter refuse to overwrite a name that exists. The second line of the message, "Or name \end... illegal", belongs to the same check: a new command name must not start with \end.

Why it happens

How to fix it

A document that produces the message

\documentclass{article}
\newcommand{\vec}[1]{\mathbf{#1}}
\begin{document}
The vector $\vec{v}$ has length 1.
\end{document}

Open in the editor

The corrected document

\documentclass{article}
\renewcommand{\vec}[1]{\mathbf{#1}}
\begin{document}
The vector $\vec{v}$ has length 1.
\end{document}

Open in the editor

Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.

Finding the line in the editor

The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.

Related pages