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.
Help centre › LaTeX errors › Commands and packages · Error: the build stops or the output is wrong
What the log says
! Illegal parameter number in definition of \vect.
<to be read again>
1
l.2 \newcommand{\vect}{\mathbf{#1}}What it means
Inside a definition, #1, #2 … stand for the arguments of the command being defined, and # followed by anything else is not allowed. TeX found a # that does not match an argument the definition declared. The name in the message is the command being defined, which may be an internal one (\endnote for the end code of an environment note).
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. #1 used without declaring the argument
\newcommand{\vect}{\mathbf{#1}} declares no arguments. Add the count in square brackets: \newcommand{\vect}[1]{\mathbf{#1}}. A #2 needs [2], and so on.
\documentclass{article}
\newcommand{\vect}{\mathbf{#1}}
\begin{document}
$\vect{v}$
\end{document}\documentclass{article}
\newcommand{\vect}[1]{\mathbf{#1}}
\begin{document}
$\vect{v}$
\end{document}2. An environment's argument used in its end code
In \newenvironment{name}[1]{begin code}{end code}, #1 is available only in the begin code. Save it in a macro there (\newcommand{\notetitle}{#1} … then \notetitle in the end code).
\documentclass{article}
\newenvironment{note}[1]{\textbf{#1:}}{(end of #1)}
\begin{document}
\begin{note}{Remark} Text. \end{note}
\end{document}\documentclass{article}
\newenvironment{note}[1]{\def\notetitle{#1}\textbf{#1:}}{(end of \notetitle)}
\begin{document}
\begin{note}{Remark} Text. \end{note}
\end{document}3. A # in a URL or text inside a definition
A link such as https://example.org/#results inside a \newcommand (or inside another command's argument) puts a bare # in a definition. Write \# instead: \url and \href print it as # in the link.
\documentclass{article}
\usepackage{url}
\newcommand{\site}{\url{https://example.org/#results}}
\begin{document}
See \site.
\end{document}\documentclass{article}
\usepackage{url}
\newcommand{\site}{\url{https://example.org/\#results}}
\begin{document}
See \site.
\end{document}4. A definition inside a definition
The inner definition's parameters must be written ##1 so that they are not taken as the outer command's arguments.
In Manulyx
The editor shows the error beside the line with an explanation, and the compile log is parsed into a list of problems.
Write in Manulyx for free · Journal templates
More in commands and packages
- Undefined control sequence.LaTeX met a command it does not know: usually a typo, or a command whose package is not loaded. The log's l. line ends with the culprit.
- 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.
- 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.
- 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