This error appears when LaTeX does not understand one of the commands you have used.
Common Examples
Typo in a command:
The most common causes of such an error are simple typos. An example of such a typo is shown below, where you accidentally pressed Z
instead of a
when writing alpha
A typo when writing $alpha$ could be $Zlpha$
This will give an error message of
main.tex, line 10
Undefined control sequence.
<<recently read> Zlpha
l.10 A typo when writing $alpha$ could be $Zlpha
$
The control sequence at the end of the top line
of your error message was never def’ed. If you have
misspelled it (e.g., `hobx’), type `I’ and the correct
spelling (e.g., `Ihbox’). Otherwise just continue,
and I’ll forget about whatever was undefined.
[1
These errors are easily spotted by humans but can cause LaTeX to get confused as to what is being asked.
Forgetting to load a package:
Another cause of such an error is when a specific package is needed to use a certain command, but it is accidentally forgotten in the preamble. An example of this would be
I want to include a space after the word LaTeXxspace but I have forgotten to load the xspace package.
In this example, the document will fail to compile as LaTeX doesn’t recognize the xspace
command. This is not a typo, as xspace
is a perfectly fine command. The problem is that you have forgotten to include usepackage{xspace}
in the preamble. When this line is included, the error message will disappear as LaTeX now knows how to interpret the xspace
command.
Backslash used in wrong place:
Another cause of an Undefined Control Sequence error is a backslash used inappropriately. This can happen particularly when writing file links as shown below.
An error will be generated if you write a file path as
C:UsersFiles
The issue is that when LaTeX sees a backslash , it interprets what follows as a command. Here, there is no such command as Users, so you will get an Undefined Control Sequence error. To avoid this, when writing text you should write a backslash as
backslash
. For writing long file paths and urls, it may sometimes be more convenient to use the url
package rather than writing backslash
every time.
I’m getting this error:
! Undefined control sequence.
l.64 ...p(- frac{E_j - E_i}{k_B T}) & quad text
{: E_j > E_i}\
?
! Undefined control sequence.
l.65 1 & quad text
{: E_j<E_i}\
?
which is from this:
begin{equation}label{eq:hop}
w_{i,j}=w_0 exp(-2 gamma R_{i,j})left{
begin{array}{l l}
exp(- frac{E_j - E_i}{k_B T}) & quad text{: E_j > E_i}\
1 & quad text{: E_j<E_i}\
end{array} right.
end{equation}
But I don’t understand why I get the error. This is my header:
documentclass[11pt]{iopart}
%newcommand{gguide}{{it Preparing graphics for IOP journals}}
%Uncomment next line if AMS fonts required
usepackage{iopams}
usepackage{graphicx, wrapfig}
usepackage{fixltx2e}
graphicspath{{images/}}
DeclareGraphicsExtensions{.pdf,.png,.jpg,.gif}
makeatletter
g@addto@macro@floatboxresetcentering
%def@cite#1{textsuperscript{[#1]}}
makeatother
And my class file is the standard IoP one from here
Can anyone help me get read of this error?
LaTeX |
---|
Getting Started
Common Elements
Mechanics
Technical Text
Special Pages
Special Documents
Creating Graphics
Programming
Miscellaneous
Help and Recommendations
Appendices
|
edit this box • edit the TOC |
LaTeX describes what it is typesetting while it does it. If it encounters something it doesn’t understand or can’t do, it will display a message saying what is wrong. It may also display warnings for less serious conditions.
Don’t panic if you see error messages: it is very common to mistype or misspell commands, forget curly braces, type a forward slash instead of a backslash, or use a special character by mistake. Errors are easily spotted and easily corrected in your editor, and you can then run LaTeX again to check you have fixed everything. Some of the most common errors are described in the next sections.
Error messages[edit | edit source]
The format of an error message is always the same. Error messages begin with an exclamation mark at the start of the line, and give a description of the error, followed by another line starting with the number, which refers to the line-number in your document file which LaTeX was processing when the error was spotted. Here’s an example, showing that the user mistyped the tableofcontents
command:
! Undefined control sequence. l.6 tableofcotnetns
When LaTeX finds an error like this, it displays the error message and pauses. You must type one of the following letters to
continue:
Key | Meaning |
---|---|
x | Stop immediately and exit the program. |
q | Carry on quietly as best you can and don’t bother me with any more error messages. |
e | Stop the program but re-position the text in my editor at the point where you found the error (This only works if you’re using an editor which LaTeX can communicate with). |
h | Try to give me more help. |
i | (followed by a correction) means input the correction in place of the error and carry on (This is only a temporary fix to get the file processed. You still have to make that correction in the editor). |
r | run in non-stop mode. Plow through any errors, unless too many pile up and it fails (100 errors). |
Some systems (Emacs is one example) run LaTeX with a «nonstop» switch turned on, so it will always process through to the end of the file, regardless of errors, or until a limit is reached.
Warnings[edit | edit source]
Warnings don’t begin with an exclamation mark: they are just comments by LaTeX about things you might want to look into, such as overlong or underrun lines (often caused by unusual hyphenations, for example), pages running short or long, and other typographical niceties (most of which you can ignore until later).
Unlike other systems, which try to hide unevennesses in the text (usually unsuccessfully) by interfering with the letter spacing, LaTeX takes the view that the author or editor should be able to contribute. While it is certainly possible to set LaTeX’s parameters so that the spacing is sufficiently sloppy that you will almost never get a warning about badly-fitting lines or pages, you will almost certainly just be delaying matters until you start to get complaints from your readers or publishers.
Examples[edit | edit source]
Only a few common error messages are given here: those most likely to be encountered by beginners. If you find another error message not shown here, and it’s not clear what you should do, ask for help.
Most error messages are self-explanatory, but be aware that the place where LaTeX spots and reports an error may be later in the file than the place where it actually occurred. For example if you forget to close a curly brace which encloses, say, italics, LaTeX won’t report this until something else occurs which can’t happen until the curly brace is encountered (e.g. the end of the document!) Some errors can only be righted by humans who can read and understand what the document is supposed to mean or look like.
Newcomers should remember to check the list of special characters: a very large number of errors when you are learning LaTeX are due to accidentally typing a special character when you didn’t mean to. This disappears after a few days as you get used to them.
Too many }’s[edit | edit source]
! Too many }'s. l.6 date December 2004}
The reason LaTeX thinks there are too many }’s here is that the opening curly brace is missing after the date control sequence and before the word December, so the closing curly brace is seen as one too many (which it is!). In fact, there are other things which can follow the date command apart from a date in curly braces, so LaTeX cannot possibly guess that you’ve missed out the opening curly brace until it finds a closing one!
Undefined control sequence[edit | edit source]
! Undefined control sequence. l.6 dtae {December 2004}
In this example, LaTeX is complaining that it has no such command («control sequence») as dtae. Obviously it’s been mistyped, but only a human can detect that fact: all LaTeX knows is that dtae is not a command it knows about: it’s undefined. Mistypings are the most common source of errors. Some editors allow common commands and environments to be inserted using drop-down menus or icons, which may be used to avoid these errors.
Not in Mathematics Mode[edit | edit source]
! Missing $ inserted
A character that can only be used in the mathematics mode was inserted in normal text.
If you intended to use mathematics mode, then use $…$ or begin{math}…end{math} or use the ‘quick math mode’: ensuremath{…}.
If you did not intend to use mathematics mode, then perhaps you are trying to use a special character that needs to be entered in a different way; for example _ will be interpreted as a subscript operator in mathematics mode, and you need _ to get an underscore character.
This can also happen if you use the wrong character encoding, for example using utf8 without «usepackage[utf8]{inputenc}» or using iso8859-1 without «usepackage[latin1]{inputenc}», there are several character encoding formats, make sure to pick the right one.
Runaway argument[edit | edit source]
Runaway argument? {December 2004 maketitle ! Paragraph ended before date was complete. <to be read again> par l.8
In this error, the closing curly brace has been omitted from the date. It’s the opposite of the error of too many }’s, and it results in maketitle trying to format the title page while LaTeX is still expecting more text for the date! As maketitle creates new paragraphs on the title page, this is detected and LaTeX complains that the previous paragraph has ended but date is not yet finished.
Underfull hbox[edit | edit source]
Underfull hbox (badness 1394) in paragraph at lines 28--30 [][]LY1/brm/b/n/10 Bull, RJ: LY1/brm/m/n/10 Ac-count-ing in Busi- [94]
This is a warning that LaTeX cannot stretch the line wide enough to fit, without making the spacing bigger than its currently permitted maximum. The badness (0-10,000) indicates how severe this is (here you can probably ignore a badness of 1394). It says what lines of your file it was typesetting when it found this, and the number in square brackets is the number of the page onto which the offending line was printed. The codes separated by slashes are the typeface and font style and size used in the line. Ignore them for the moment.
This comes up if you force a linebreak, e.g., \, and have a return before it. Normally TeX ignores linebreaks, providing full paragraphs to ragged text. In this case it is necessary to pull the linebreak up one line to the end of the previous sentence.
This warning may also appear when inserting images. It can be avoided by using the textwidth or possibly linewidth options, e.g. includegraphics[width=textwidth]{image_name}
Overfull hbox[edit | edit source]
[101] Overfull hbox (9.11617pt too wide) in paragraph at lines 860--861 []LY1/brm/m/n/10 Windows, LY1/brm/m/it/10 see LY1/brm/m/n/10 X Win-
An overfull hbox means that there is a hyphenation or justification problem: moving the last word on the line to the next line would make the spaces in the line wider than the current limit; keeping the word on the line would make the spaces smaller than the current limit, so the word is left on the line, but with the minimum allowed space between words, and which makes the line go over the edge.
The warning is given so that you can find the line in the code that originates the problem (in this case: 860-861) and fix it. The line on this example is too long by a shade over 9pt. The chosen hyphenation point which minimizes the error is shown at the end of the line (Win-). Line numbers and page numbers are given as before. In this case, 9pt is too much to ignore (over 3mm), and a manual correction needs making (such as a change to the hyphenation), or the flexibility settings need changing.
If the «overfull» word includes a forward slash, such as «input/output
«, this should be properly typeset as «inputslash output
«. The use of slash
has the same effect as using the «/
» character, except that it can form the end of a line (with the following words appearing at the start of the next line). The «/
» character is typically used in units, such as «mm/year
» character, which should not be broken over multiple lines.
The warning can also be issued when the end{document} tag was not included or was deleted.
Easily spotting overfull hboxes in the document[edit | edit source]
To easily find the location of overfull hbox in your document, you can make latex add a black bar where a line is too wide:
Missing package[edit | edit source]
! LaTeX Error: File `paralisy.sty' not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: sty) Enter file name:
When you use the usepackage command to request LaTeX to use a certain package, it will look for a file with the specified name and the filetype .sty. In this case the user has mistyped the name of the paralist package, so it’s easy to fix. However, if you get the name right, but the package is not installed on your machine, you will need to download and install it before continuing. If you don’t want to affect the global installation of the machine, you can simply download from Internet the necessary .sty file and put it in the same folder of the document you are compiling.
Package babel Warning: No hyphenation patterns were loaded for the language X[edit | edit source]
Although this is a warning from the Babel package and not from LaTeX, this error is very common and (can) give some strange hyphenation (word breaking) problems in your document. Wrong hyphenation rules can decrease the neatness of your document.
Package babel Warning: No hyphenation patterns were loaded for (babel) the language `Latin' (babel) I will use the patterns loaded for language=0 instead.
This can happen after the usage of: (see LaTeX/Internationalization)
usepackage[latin]{babel}
The solution is not difficult, just install the used language in your LaTeX distribution.
Package babel Error: You haven’t loaded the option X yet.[edit | edit source]
If you previously set the X language, and then decided to switch to Y, you will get this error.
This may seem awkward, as there is obviously no error in your code if you did not change anything.
The answer lies in the .aux file, where babel defined your language.
If you try the compilation a second time, it should work.
If not, delete the .aux file, then everything will work as usual.
No error message, but won’t compile[edit | edit source]
One common cause of (pdf)LaTeX getting stuck is forgetting to include end{document}
Software that can check your .tex Code[edit | edit source]
There are several programs capable of checking LaTeX source, with the aim of finding errors or highlighting bad practice, and providing more help to (particularly novice) users than the built-in error messages.
- nag (www.ctan.org/tex-archive/macros/latex/contrib/nag) is a LaTeX package designed to indicate the use of obsolete commands.
- lacheck (www.ctan.org/tex-archive/support/lacheck) is a consistency checker intended to spot mistakes in code. It is available as source code or compiled for Windows and OS/2
- chktex (baruch.ev-en.org/proj/chktex/) is a LaTeX semantic checker available as source code for Unix-like systems.
0
1
При компиляции выдает ошибку: ! Undefined control sequence. DeclareUnicodeCharacter
и так ругается на все строки ниже.
На других компьютерах собирает файл нормально.
Помогите исправить, пожалуйста.
В LaTex 2й день, так что подробно.
documentclass[a4paper,12pt]{article}
usepackage{geometry}
geometry{left=3cm,right=1.5cm,top=2cm,bottom=2cm}
usepackage[cp1251]{inputenc}
usepackage{mathtext}
usepackage[T2A]{fontenc}
usepackage[english,russian]{babel}
usepackage{amstext,amsmath,amssymb}
usepackage{bm}
usepackage[pdftex]{graphicx}
usepackage{amsfonts}
usepackage{indentfirst}
usepackage{cite}
usepackage{multirow}
usepackage{array}
linespread{1.3}
pagestyle{plain}
usepackage{color}
begin{document}
begin{titlepage}
begin{center}
Министерство
(государственный университет) flqq МФТИfrqq\
Факультет \
Кафедра \
end{center}
vspace{5cm}
begin{center}
LARGE bf{******************** }
end{center}
begin{center}
large {Диплом на соискание степени магистра}
end{center}
vspace{3cm}
large !!!!здесь ругается !!!!
begin{flushright}
textbf{Выполнил:}\
группа\
***************\
vspace{1cm}
textbf{Научный руководитель:}\
(степень руководителя) \
******************
end{flushright}
vspace{1cm}
documentclass{book}
usepackage{amsmath}
usepackage[german]{babel}
usepackage{amssymb}
usepackage{amsxtra}
usepackage[dvips]{epsfig,psfrag}
usepackage{listings}
newcommand{refchapter}[1]{Kapitel~ref{#1}}
newcommand{refsec}[1]{Sektion~ref{#1}}
newcommand{refeqn}[1]{Gleichung~(ref{#1})}
newcommand{reffig}[1]{Abbildung~ref{#1}}
title{bf Grundz"uge der Softwareentwicklung \
{small Analyse- und Entwurfsdokument} vspace{1cm}\
centering
epsfig{file=figures/logo.eps,width=.4textwidth}
}
author{Uschi Musterfrau, Detlef Mustermann und Ralf Auchmustermann}
date{Matr.-Nr. 0815, 0816 und 0817 \
email: {tt [uschi|detlef|ralf]@rwth-aachen.de}
}
begin{document}
lstloadlanguages{[ISO]C++}
lstset{basicstyle=small, numbers=left, numberstyle=footnotesize,
stepnumber=1, numbersep=5pt, breaklines=true, escapeinside={/*@}{@*/}}
pagestyle{headings}
maketitle
tableofcontents
include{vorwort}
include{analyse}
include{entwurf}
include{nutzerdoc}
include{entwicklerdoc}
bibliographystyle{plain}
bibliography{analyse_entwurf}
appendix
include{quellcode}
end{document}
this is how my file starts. I didn’t even edit it, I received it like this. However, if I want to make a pdf, it gives me the undefined control sequence error at the first line… What is wrong??