LaTeX error "Missing control sequence inserted": cause and fix
TeX expected a command name, a word that starts with a backslash, and found a normal character. This happens when a definition names the new command without its backslash.
Why it happens
- The backslash of the new name is missing:
\newcommand{name}{...}instead of\newcommand{\name}{...}. The same goes for\renewcommandand\providecommand. - A length or a box is declared without backslash:
\newlength{mywidth},\newsavebox{mybox}. \defis followed by a word instead of a command:\def name{...}.
How to fix it
- Add the backslash:
\newcommand{\name}{Ada Lovelace}. - Names of commands, lengths and boxes take a backslash. Names of counters (
\newcounter{name}) and environments (\newenvironment{name}) do not. - Fix this line first. The log reports several errors for it, among them Missing number, treated as zero and, in the preamble, LaTeX Error: Missing \begin{document}. They disappear together.
A document that produces the message
\documentclass{article}
\newcommand{name}{Ada Lovelace}
\begin{document}
The author is \name.
\end{document}The corrected document
\documentclass{article}
\newcommand{\name}{Ada Lovelace}
\begin{document}
The author is \name.
\end{document}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.