Skip to content

Common LaTeX errors

HughParsonage edited this page Oct 3, 2016 · 1 revision

Common LaTeX Errors {#cha:common-errors}

This chapter is best understood by following the PDF output.

The following is a list of common LaTeX compile errors as they appear in the log file, and suggestions for how to resolve these. More often than not, errors come from something simple, such as forgetting a parenthesis, a typo, or forgetting to end an environment. But there are also cases where you have no idea what you have done wrong and it can take a fair bit of time to find or even understand your error.

A feature of ShareLaTeX is that it provides ‘hints’ on how to resolve particular errors – most of the time these hints are sufficient. But if not, it may be necessary to view the raw log file to diagnose the problem.

The Form of an Error {#sec:form-an-error}

There are two forms of errors: LaTeX errors and TeX errors. In both types of errors, the part after the error message will tell you where the error occurred. An example:

l.15 <offending text>

The l.15 tells you what line the error occurred on and the text will tell you the text that caused the error.

LaTeX Errors {#sec:latex-errors}

The general form of an error in LaTeX is shown below:

! LaTeX error: <error message>

See the LaTeX manual or LaTeX Companion for
explanation.
Type H <return>   for immediate help.
...

The ! lets you know that the error has occurred. The error message will tell you what type of error you have committed. After the ellipses, you will find the line at which the error occurred and the text that caused the error (or at least the text where LaTeX found the error).

TeX Errors {#sec:tex-errors}

Errors may also have the following form:

! <error message>

These errors are formatted differently because they are error messages that came from TeX instead of LaTeX. After the error, you will still find the line that the error occurred in and the text of the error.

Warnings {#sec:warnings}

There are some error messages that are just warnings and will not stop or change the compilation of the document. Chances are you have seen them many times.

Underfull {#sec:underfull}

The following error results when a line does not extend the width of the page, something LaTeX always tries to accomplish:

Underfull \hbox (badness 10000) in paragraph at lines
104--107

This error message is just a warning and is not something to worry about. For the most part, when a line does not span the width of the page, it is because you have written something that you want to only cover part of the page.

Overfull {#sec:overfull}

The following error results when a line extends beyond the width of the page:

Overfull \hbox (16.04988pt too wide) in paragraph at
lines 30--31 [] [] \OT1/cmtt/m/n/12 I'm trying to put
way too much text into a line in my document.

Usually this error comes form when you are using the verbatim package because it will not move to the next line if your text does not go to the next line. The easiest way to fix this is to find the place in your document where this is occurring and change the text so that it fits to the page.

This error will still show up if the text is still on the page but outside of the width of text that LaTeX has set. In this case, you are welcome to fix things so that the error does not show up or you can leave the text as it is.

References {#sec:references-1}

The following warnings occur when references are changed when LaTeX was compiled:

LaTeX Warning: Label(s) may have changed. Rerun to get
cross-references right.

LaTeX Warning: There were undefined references.

LaTeX Warning: Reference `name' on page 1 undefined on
input line 15.

The way to fix these errors is to recompile the document again to correct the page numbers. Sometimes it is necessary to recompile the document twice to fix this error. You also may have defined a reference wrong, so you should check to make sure your label is correct.

Beginning and Ending {#sec:beginning-ending}

Begin Ended by End {#sec:begin-ended-end}

This type of error occurs when each environment is not correctly started and ended. When you are missing an \end command, the following error will show up:

! LaTeX Error: \begin{enumerate} on input line 23
ended by \end{document}.

To fix this, you need to end the environment mentioned in the error with the appropriate command.

When you are missing a \begin command, the following will appear:

! LaTeX Error: \begin{document} ended by
\end{itemize}.

To fix this, you basically do the same thing as before, correctly beginning the environment mentioned in the error with the appropriate command.

End Occurred Inside a Group {#sec:end-occurred-inside}

The following error message will show up at the end of compiling a file if an environment is begun that is not ended:

(\end occurred inside a group at level <n>)

To fix this error, make sure you end the environment that was begun. The previous error is more helpful in finding the \begin statement.

Ended by End of Line {#sec:ended-end-line}

The following error will occur when you try to place a command inside a section heading:

! LaTeX Error: \verb ended by end of line.

See the LaTeX manual or LaTeX Companion for
explanation.
Type H <return>   for immediate help.
...

There will be many errors of the same type for this mistake. In order to find where you put the command, look in the output file and find the last heading that shows up.

Missing Begin Document {#sec:miss-begin-docum}

This error is self-explanatory:

! LaTeX Error: Missing \begin{document}

Errors Usually Caused by Bad Spelling {#sec:errors-usually-caus}

Unknown Control Sequence {#sec:unkn-contr-sequ}

This error results when you use a command (something that starts with a \backslash) that is not recognized by LaTeX:

! Undefined control sequence.

Usually this error results from spelling a command incorrectly. Go to the line that is indicated by the error and fix the command.

Environment Undefined {#sec:envir-undef}

This error results when you begin an environment with a \begin command that is not recognized:

! LaTeX Error: Environment verbatin undefined.

Usually you have just spelled your environment incorrectly, so you just need to fix it.

Bad File Name {#sec:bad-file-name}

This error results when you have mistyped the command latex or do not have LaTeX installed on your computer:

Bad command or file name

To fix this, correctly spell the command to compile your file or make sure that LaTeX is correctly installed on your computer.

Cannot Find File Name {#sec:cannot-find-file}

This error occurs when you try to compile a file that the computer cannot find:

! I can't find file `sample'.
<*> sample

Please type another input file name:

To fix this error, make sure you have spelled the file name correctly. You also may be in the wrong directory to compile the file, so check to make sure you are in the same directory as your file.

Fatal Errors {#sec:fatal-errors}

Runaway Argument {#sec:runaway-argument}

This error happens when a paragraph ends before a command’s argument is done (i.e., LaTeX thinks that there is a missing }):

Runaway argument?

To fix this, you should use a different command to accomplish what you are trying to do. An example of this is to use \bfseries instead of \bftext to make bold text in more than one paragraph.

This error can also be caused by a missing mandatory argument to a command.

Just an * {#sec:just-an-asterisk}

This error normally occurs when you do not end your document with
\end{document}:

*

If you are prompted to enter something in, it is best to enter

\end{document}

and hope it works. Be sure to end your document with the appropriate command.

Emergency Stop {#sec:emergency-stop}

This error happens when LaTeX will stop trying to compile your document due to a serious error:

! Emergency stop.

To fix this error, you will need to figure out what caused it to stop compiling. Chance are you forgot to end your document with \end{document}, but there might also be another reason for the emergency stop.

Please Type a Command or Say End {#sec:please-type-command}

This error happens when your file has ended prematurely:

(Please type a command or say `\end')

The best way to deal with this type of error is to type

\end

or

\end{document}

in the case that the absence of that command caused the error. Usually if you have ended your document correctly, the error will result from a missing } or forgetting to end a verbatim environment.

Graphics Errors {#sec:graphics-errors}

Too Many Unprocessed Floats {#sec:too-many-unprocessed}

This error occurs when figures or tables (i.e., floats) have not been typeset:

! LaTeX Error: Too many unprocessed floats.

LaTeX can only have so many floats waiting to be typeset. In order to fix this error, make sure that you are placing your floats where you want them (with a [h] option) and not wanting too many on one page in sequence. Using the command \clearpage can be very useful in distributing floats correctly.

Unknown Graphics Extension {#sec:unkn-graph-extens}

The following error occurs when you try to use a type of graphic that is not supported by the type of file that you are producing:

! LaTeX Error: Unknown graphics extension: .gif

In order to fix this error, you should change your graphics to the types that are supported by the type of file you are outputting or you will need to include the correct package to deal with that type of graphic. Sometimes you may have named the graphic poorly so that LaTeX will not recognize it as a graphic file.

Division by Zero {#sec:division-zero}

The following error occurs when the height of a graphic object is zero:

! Package graphics Error: Division by 0.

This is usually caused when you rotate an object with zero depth so that its height becomes zero. The best way to fix this is to use the keyword totalheight instead of height.

Math Errors {#sec:math-errors}

Display Math Should End With $$ {#sec:display-math-should}

This error occurs when the displaymath or equation mode is ended incorrectly:

! Display math should end with $$

To fix this error, make sure that you end the displaymath or equation mode correctly (ending them with a $ is not acceptable).

Bad Math Environment Delimiter {#sec:bad-math-environment}

This error occurs when you do not have your delimiters correct in math mode:

! LaTeX Error: Bad math environment delimiter.

Usually this occurs when you forget to match a right delimiter with every left delimiter. This error may also happen when you forget to end an array.

Missing Right {#sec:missing-right}

This error occurs when you have a missing right parenthesis:

! Extra \right.

To fix this, you either need to add a \right command or you need to end an array.

Missing Delimiter {#sec:missing-delimiter}

This error message occurs when a delimiter is missing:

! Missing delimiter (. inserted).

To fix this error, you need to make sure that you have a right delimiter for every left delimiter. If you do not want a right delimiter matching a left delimiter, you need to use “.” to not have an error message show up.

Missing $ Inserted {#sec:missing--inserted}

The following error occurs when you try to use a character that can only be used in math mode, like _ or ^:

! Missing $ inserted

To fix this error, make sure you change the character to what it should be in text mode.

Tabular Environment Errors {#sec:tabul-envir-errors}

Misplaced Alignment Tab Character & {#sec:mispl-alignm-tab}

This error occurs when you use & and when you are not in a tabular environment:

Misplaced alignment tab character &

To fix this error, you need to use \& to make a &.

Extra Alignment Tab {#sec:extra-alignment-tab}

This error occurs when you use too many tabs for the number of columns in a table:

! Extra alignment tab has been changed to \cr

The result of this error is that a new row is formed where the extra tab was. You should go back and fix your table so that the correct number of items in each row would show up.

Argument Has an Extra } {#sec:argument-has-an}

These errors happen when an incorrect number of arguments to a tabular environment have been specified:

! Argument of \cline has an extra }.

! Argument of \multicolumn has an extra }.

To fix this error, make sure your arguments to the tabular environment are correct.

Errors With Lists {#sec:errors-with-lists}

Missing Item {#sec:missing-item}

This error occurs when there is plain text in an environment that takes items:

! LaTeX Error: Something's wrong--perhaps a missing
\item.

To fix this error, make sure the plain text is changed into an item.

Too Deeply Nested {#sec:too-deeply-nested}

This error occurs when there are too many lists for LaTeX to handle:

! LaTeX Error: Too deeply nested

LaTeX can only handle four levels of one type of list and six levels of different types of lists. To fix this, you need to use less levels of lists or define your own list environment.

Miscellaneous Errors {#sec:miscellaneous-errors}

Only Used in the Preamble {#sec:only-used-preamble}

This error occurs when you place a command in the body of a LaTeX document that should be placed in the preamble:

! LaTeX Error: Can be used only in the preamble.

To fix this error, just move the command to the preamble.

There Is No Line/Page Here to End {#sec:there-no-linepage}

This error occurs when you incorrectly use the commands that make a new line or a new page:

! LaTeX Error: There's a no line here to end.

You may just leave the command that is making a new line in place or you can take it out. Here, LaTeX is just trying to make sure that everything looks nice.

Command Already Defined {#sec:comm-alre-defin}

This error occurs when you try to define a command that already exists:

! LaTeX Error: Command ... already defined.

To fix this, you need to define your command differently.

Missing Number {#sec:missing-number}

This error is made when a number is expected as an argument and one is not provided:

! Missing number, treated as zero.

To fix this error, you need to find where a number is expected so that you can provide the correct one.

Clone this wiki locally