LaTeX errors explained
The 53 messages LaTeX and BibTeX print most, what each one means, and how to fix it. Every page has an example that fails and the same example fixed, compiled to check.
Help centre › LaTeX errors
Reading a LaTeX log. Errors start with !, and the line after them that starts with l. gives the line number and the text TeX had read when it stopped. Fix the first error first: later ones are often caused by it and disappear with it. Warnings (LaTeX Warning:) let the document compile but usually mean something is wrong in the output.
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.
- 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.
- TeX capacity exceeded, sorry [<what>].TeX ran out of one of its fixed memory areas. Almost always a command that calls itself forever; rarely a document that is genuinely too big.
- Package pgfkeys Error: I do not know the key '/tikz/<key>' and I am going to ignore it. Perhaps you misspelled it.A TikZ option is misspelled, is a color that was never defined, or belongs to a TikZ library that is not loaded with \usetikzlibrary.
- Package minted Error: You must invoke LaTeX with the -shell-escape flag.minted runs an external highlighter, which needs shell escape. Compile with -shell-escape where you may, or switch to the listings package.
Maths
- Missing $ inserted.A maths-only character or command (_ ^ \alpha) appeared in text, or text appeared in maths. Wrap the maths in $ … $ or escape the character.
- Double subscript.Two _ (or two ^) apply to the same symbol, as in x_i_j. Group them with braces: x_{i_j} or x_{ij}, x^{2^3} or {x^2}^3.
- Missing \right. inserted.A \left has no matching \right in the same formula or line, or a \right has no \left. Pair them, or use \right. / \left. as invisible partners.
- Display math should end with $$.A displayed equation was closed with a single $ or a $ appeared inside it. Use \[ … \] or an equation environment, and no $ inside.
- LaTeX Error: Bad math environment delimiter.\[ or \( was used inside maths, or \] or \) without its opening. Close one formula before opening the next, and pair each delimiter.
Braces and environments
- Extra }, or forgotten $.A closing brace } has no matching {. Count the braces on the reported line, or look for a $ that closes maths inside a {…} group.
- Missing } inserted.A { group was still open when maths or a table cell ended. Close the brace before the $ or & that ends it.
- Runaway argument?A command's argument was never closed, so TeX read on to the end of a paragraph or of the file. Add the missing } after the argument.
- Paragraph ended before \<name> was complete.A blank line (paragraph break) appeared inside an argument or maths environment that cannot contain one, often because a } or \end{…} is missing.
- LaTeX Error: \begin{<a>} on input line <n> ended by \end{<b>}An environment is closed by the wrong \end: a misspelled \end, environments closed in the wrong order, or a missing \end{…} further up.
Tables and alignment
- Misplaced alignment tab character &.An & appeared outside a table or align environment. In text write \&; in a bibliography fix the & in the .bib entry; in maths use align.
- Extra alignment tab has been changed to \cr.A table or matrix row has more & cells than the column specification allows. Add a column to {…}, remove an &, or add a missing \\.
Document structure
- LaTeX Error: Missing \begin{document}Something that prints text sits above \begin{document}, or that line is missing. Only settings belong in the preamble; find the stray text and move it.
- LaTeX Error: Can be used only in preambleA preamble-only command such as \usepackage or \documentclass appears after \begin{document}. Move it above \begin{document}.
- LaTeX Error: Something's wrong--perhaps a missing \itemA list has text before its first \item, or no items at all; an empty thebibliography is a common case. Start every list with \item.
- LaTeX Error: Lonely \item--perhaps a missing list environmentAn \item appears outside any list: the \begin{itemize} or \begin{enumerate} is missing, or the list was closed too early.
- LaTeX Error: \include cannot be nestedA file loaded with \include contains another \include. Only the main file may \include; inside an included file use \input instead.
- Package hyperref Warning: Token not allowed in a PDF string (<encoding>):Warning. A heading contains math or a command that cannot go into a PDF bookmark. The page is fine; give the bookmark plain text with \texorpdfstring.
Files and fonts
- LaTeX Error: File `<name>' not foundLaTeX cannot find a file you asked for: an \input or image name that is misspelled or missing, or a package or class that is not installed.
- LaTeX Error: Unicode character <c> (U+<hex>) not set up for use with LaTeXpdfLaTeX has no glyph for a character in your text. Write it as a LaTeX command, delete it if invisible, or compile with XeLaTeX or LuaLaTeX.
- LaTeX Font Warning: Font shape `<shape>' undefinedWarning. The font has no such combination of family, weight and shape (bold small caps, say), so LaTeX substitutes another. Change font encoding or font.
- LaTeX Error: Unknown graphics extension: <ext>\includegraphics was given an image format pdfLaTeX cannot read, such as .tif, .gif, .bmp or .svg. Convert the image to PDF, PNG or JPEG.
- LaTeX Error: Invalid UTF-8 byte sequenceThe file is not saved as UTF-8 (often Latin-1 or Windows-1252, from an old editor or a .bib export). Re-save it as UTF-8.
References and bibliography
- LaTeX Warning: Citation `<key>' on page <n> undefinedWarning. A \cite key has no entry in the built bibliography: a key typo, a missing \bibliography line, a broken .bib entry, or BibTeX has not run yet.
- LaTeX Warning: Reference `<label>' on page <n> undefinedWarning. A \ref, \eqref or \pageref names a label LaTeX has not seen: a typo, a missing \label, or a part excluded by \includeonly. Prints ?? in the PDF.
- LaTeX Warning: There were undefined references.Warning. The end-of-run summary: some \ref or \cite did not resolve. Find the individual "Reference ... undefined" or "Citation ... undefined" lines above it.
- LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.Warning. Some label's number or page changed during this run, so references printed from the old .aux may be wrong. Compile again; if it never settles, look for a loop.
- LaTeX Warning: Label `<label>' multiply defined.Warning. Two \label commands use the same name, so every \ref to it shows whichever came last. Rename one, and update the \ref commands that meant it.
- I couldn't open database file <name>.bibBibTeX cannot find the .bib file named in \bibliography. Check the spelling and folder, and write the name without the .bib extension.
- I found no \bibdata commandBibTeX read the .aux file and found no \bibliography, no \cite or no \bibliographystyle. Add the missing command, or run biber for biblatex.
- Repeated entry---line <n> of file <name>.bibTwo .bib entries share one citation key. BibTeX keeps the first and skips the other. Delete the duplicate or give it its own key.
- I was expecting a `,' or a `}'---line <n> of file <name>.bibA .bib entry is malformed, most often a missing comma between fields or a space in the key. BibTeX skips the rest of the entry.
- Package natbib Error: Bibliography not compatible with author-year citations.natbib wants author-year data, but the bibliography style gives only numbers. Use an author-year style such as plainnat, or load natbib with [numbers].
Floats and layout
- LaTeX Error: There's no line here to endA line break (\\ or \newline) comes where no line has started, typically after a blank line. Use \vspace or \medskip for vertical space.
- LaTeX Error: Not in outer par modeA figure, table or \marginpar is inside a box, minipage, table cell or another float. Floats must be in the main text; put the box inside the float.
- LaTeX Error: Too many unprocessed floatsFigures and tables are queued faster than LaTeX can place them, often behind one that cannot be placed. Relax placements, shrink it, or add \clearpage.
- LaTeX Error: Float(s) lostA figure or table sits inside a footnote, a framed box or a similar construct LaTeX cannot place floats from, and it disappears. Move it into the text.
- Overfull \hbox (<n>pt too wide) in paragraph at lines <a>--<b>Warning. A line sticks out into the margin because TeX found no acceptable place to break it: a long URL or word, or an image or equation wider than the column.
- Underfull \hbox (badness <n>) in paragraph at lines <a>--<b>Warning. A line had to be stretched more than TeX likes, leaving wide gaps between words. Usually caused by \\ or \linebreak in running text.
- LaTeX Warning: Float too large for page by <n>pt on input line <n>.Warning. A figure or table is taller than the text area, so it overprints the footer or runs off the page. Scale it to fit, or split a long table.
- Dimension too large.A length went past TeX's limit of about 16383pt (5.75 m). Usually a TikZ plot with large coordinates or a scale factor gone wrong.
- LaTeX Error: \caption outside float.\caption is used outside a figure or table environment. Wrap the content in figure or table, or use \captionof from the caption package.