Undefined control sequence latex ошибка

I have been using LaTeX for years, but today on sigchi template I am getting undefined control sequence error. I want to place my figures spanning two columns or even in a single column, but none works. Here is a minimal example code:

documentclass{sigchi}

% Remove or comment out these two lines for final version
toappearbox{Large Submitted to CHI'13. \Do not cite, do not circulate.}
pagenumbering{arabic}% Arabic page numbers for submission. 

% Use toappear{...} to override the default ACM copyright statement (e.g. for preprints).

% Load basic packages
usepackage{balance}  % to better equalize the last page
usepackage{graphicx} % for EPS, load graphicx instead
usepackage{times}    % comment if you want LaTeX's default font
usepackage{url}      % llt: nicely formatted URLs
usepackage{soul}
usepackage{color}
usepackage{subfig}



newcommand{hilight}[1]{colorbox{yellow}{#1}}

% llt: Define a global style for URLs, rather that the default one
makeatletter
defurl@leostyle{%
  @ifundefined{selectfont}{defUrlFont{sf}}{defUrlFont{smallbfttfamily}}}
makeatother
urlstyle{leo}


% To make various LaTeX processors do the right thing with page size.
defpprw{8.5in}
defpprh{11in}
special{papersize=pprw,pprh}
setlength{paperwidth}{pprw}
setlength{paperheight}{pprh}
setlength{pdfpagewidth}{pprw}
setlength{pdfpageheight}{pprh}

% Make sure hyperref comes last of your loaded packages, 
% to give it a fighting chance of not being over-written, 
% since its job is to redefine many LaTeX commands.
usepackage[pdftex]{hyperref}
hypersetup{
pdftitle={SIGCHI Conference Proceedings Format},
pdfauthor={LaTeX},
pdfkeywords={SIGCHI, proceedings, archival format},
bookmarksnumbered,
pdfstartview={FitH},
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black,
breaklinks=true,
}

% create a shortcut to typeset table headings
newcommandtabhead[1]{smalltextbf{#1}}


% End of preamble. Here it comes the document.
begin{document}

title{title}

maketitle

begin{abstract}

Abstract
end{abstract}
section{Introduction}

Figure here
 begin{figure*}
 subfigure{includegraphics{graph}}

 subfigure{includegraphics{graph2}}

 subfigure{includegraphics{graph3}}
 end{figure*}

balance


bibliographystyle{acm-sigchi}
bibliography{IEEEabrv,mybibfile,sample}
end{document}

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.

Undefined control sequence error signifies different types of issues like writing confusing commands, forgetting to load a package, or loading a package at the wrong location, etc. You can say that this simple three-word error has more causes than you expect, but you don’t need to be worried about it because this post is here to serve you.Undefined Control Sequence

In this article, you’ll get to view the long list of well-explained causes and have a look at the solutions that’ll make your day. So, wait no more, grab a seat, and start reading to see how you can iron out the error.

Contents

  • What Causes the Undefined Control Sequence Error?
    • – LaTeX is Unable To Identify the Command
    • – You Are Using an Invalid Command Inside the Class
    • – You Have Loaded the Package After Starting the Document
    • – You Are Loading the Subfig and Subfigure Packages in a Single File
    • – The RequirePackage[numbers]{natbib} Line Might Be the Reason
    • – Your Elsarticle Template Doesn’t Match the Elsarticle Class Version
    • – You Are Using pdftex To Produce Your Document
  • How To Fix the Undefined Control Sequence Error?
    • – Replace the in the Text With backslash
    • – Study the Classes and Their Commands Well
    • – Load the Package, But Before Starting the Document
    • – Choose subfig Over subfigure
    • – Try Removing the Line That Requires the natbib Package
    • – Use the Elsarticle Template Matching the Current Elsarticle Version
    • – Use Pdflatex, Latex, Xelatex, or Lualatex To Produce Your Document
  • Conclusion

What Causes the Undefined Control Sequence Error?

The undefined control sequence – Overleaf error is caused by a command that is not recognized by LaTeX due to different reasons at the backend. Moreover, loading the same kind of obsolete and latest packages together or using pdftex to produce a document can result in the given error.

– LaTeX is Unable To Identify the Command

Your code might be confusing LaTeX between the backslash that is part of a command and the backslash that is a part of the text. Also, it’s possible that you haven’t loaded the package required for using a particular command. In any of the said cases, you’ll receive the error under consideration today.

Think about it this way. You have entered some text that contains backslashes. In such a scenario, LaTex will consider the text following the backslash as a command and throw an undefined control sequence LaTeX table error.

Now, look at another example. You have entered the includegraphics command without loading the graphicx package. Here, an undefined control sequence includegraphics error, will pop up to indicate that LaTeX can’t identify the command because the necessary package isn’t loaded.

– You Are Using an Invalid Command Inside the Class

Not having clarity regarding classes and their commands can make you the victim of the above error. Putting it in simple words, if you use a command inside the wrong class, you’ll get to see the same error. It’s the same as using an irrelevant command inside a class.Undefined Control Sequence Causes

For example, you write the chapter command inside the article class. You must know that the chapter command belongs to the book and report classes. Therefore, an undefined control sequence chapter error will interrupt your document processing.

– You Have Loaded the Package After Starting the Document

It’s not only about loading the required package. Note that if you load the package after writing the begin{document} command, neither the package will be recognized nor you’ll be able to use any of its commands. It means that the location where the package is loaded matters too.

Here is a relevant piece of code for your reference that’ll throw the undefined control sequence begin(document):

begin{document}

usepackage{graphicx}

– You Are Loading the Subfig and Subfigure Packages in a Single File

Loading the subfig and subfigure packages in a single file is a possible reason behind the error stated in the title. You must know that both of the said packages offer the same functionality. Plus, the subfigure package has become obsolete, while the subfig has been used recently.

According to this, if you can find yourself loading both subfig and subfigure packages, then you should stop your search for the cause of the error.

– The RequirePackage[numbers]{natbib} Line Might Be the Reason

Although not necessarily always, sometimes, the line at which you require the natbib package can trigger the given error on your screen. So, if your code contains such a line, then you should consider this cause because it might be generating the error on your side.

Say that you have used the RequirePackage command for multiple packages, including the natbib package. Suddenly, you receive an error saying undefined control sequence on your screen. In this case, requiring the natbib package can be the culprit.

– Your Elsarticle Template Doesn’t Match the Elsarticle Class Version

If you are facing an undefined control sequence affiliation error while using the affiliation command inside the elsarticle class, then the absence of the given command in the elsarticle version you are using currently can be the cause. Note that affiliation isn’t found in elsarticle in TexLive19.Undefined Control Sequence Reasons

Furthermore, remember that the affiliation command is available in the elsarticle version present in the fully updated TexLive20. So, even if you are working with TexLive20, but the elsarticle version is not the one present in fully updated TexLive20, then you’ll get the same error.

– You Are Using pdftex To Produce Your Document

Using pdftex to produce your document can lead you to an undefined control sequence documentclass error. The commands, such as usepackage, begin{document}, etc., follow the LaTeX format and aren’t understandable by pdftex. Hence, the latter stops at the begin{document}, and shows you an error.

This cause suggests that even if your entire LaTeX code is perfect, using the wrong program to compile the code, and produce a document can make things go wrong for you.

How To Fix the Undefined Control Sequence Error?

You can fix the undefined control sequence error by replacing with backslash in plain text, loading the package before starting the document, or writing only valid commands for the classes. Also, using latex or a relevant program to produce the document can solve the error.



– Replace the in the Text With backslash

The clearer your LaTeX code, the more chances you’ll have to satisfy LaTeX and stay away from the mentioned error. So, if you don’t intend to write a command after the backslash character, then it would be best to write backslash instead of entering only the character.

This solution is the simplest one as all that you’ll have to do is to replace with backslash in your already written text.

– Study the Classes and Their Commands Well

Studying the classes and their commands well enough will help you make fewer mistakes while using commands. As you’ll be aware of everything already, you won’t mix and match irrelevant commands with different classes. Also, the error will have no reasons to stay.Undefined Control Sequence Fixes

Talking about the same example where you used the chapter command inside the article class. Here, you’ll need to change either the class or the command. To stay with the chapter command, you’ll have to switch from article to book or report. However, if you want to keep using the article class, you’ll need to tweak the command to make it section or subsection.

– Load the Package, But Before Starting the Document

You should load the required package by using the usepackage command to eliminate the given error. But don’t forget to load it before the begin{document} to ensure that the error never comes back. Both of these steps will help LaTeX recognize the package and command.

Here is what the perfect sequence of commands looks like:

usepackage{graphicx}

begin{document}

– Choose subfig Over subfigure

As the subfigure package has become obsolete, it would be better to choose the subfig package over the subfigure. Having only the subfig package will allow you to use the expected functionalities and kill the given error right away. So, it’s a no-loss deal.

It means if your code contains both packages, then removing the line that loads the subfigure package will resolve the issue.

– Try Removing the Line That Requires the natbib Package

If you think your code might be facing the rarest problem where requiring the natbib package causes an error, then you might like to eliminate the erroneous line. However, removing the said line won’t allow you to use the commands belonging to the same package.

Please feel free to try out this solution to see if it kicks away the error.

– Use the Elsarticle Template Matching the Current Elsarticle Version

You can resolve the error occurring while using the affiliation command of the elsarticle class in TexLive19 by giving up using the affiliation command. Next, you’ll need to follow the elsarticle template based on its version currently in use.Undefined Control Sequence Solutions

Making it simple, using only the commands available in your current elsarticle class version will solve the error.

– Use Pdflatex, Latex, Xelatex, or Lualatex To Produce Your Document

You should use pdflatex, latex, xelatex, or lualatex program to efficiently produce a document from your LaTeX code. Moreover, choosing an appropriate program to produce the document will make the error leave your screen without causing any further problems. So, you shouldn’t hesitate to apply this solution.

Please feel free to go with any of the given programs because all of them understand LaTeX easily.

Conclusion

As per this guide, the undefined control sequence error shows up whenever you go wrong with the commands, the packages, the classes, or the placement of backslashes. Although it’s difficult to predict the actual cause of the error on your side, the causes discussed above will make it easier for you to find out the culprit at the earliest. Please read on to view the listicle putting together some noteworthy points for you.

  • It would be best to use backslash instead of a character in the text.
  • You should use the with only valid commands in a class and after loading the required package.
  • Ensure to use usepackage before begin{document} to avoid the said error.
  • Always use pdflatex and similar programs to generate the document.
  • You should use subfig instead of subfigure to get rid of the error.

In the end, never forget that understanding the LaTeX format and having sufficient knowledge about its basics is the key to error-free document generation.

  • Author
  • Recent Posts

Position is Everything

Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL. Meet The Team

Position is Everything

When I compile the following latex code:

begin{align}   
f_{m}(x) = c_{1,m} times I(x_{i}^{m} geqslant t_{m} ) + c_{2,m} times I(x_{i}^{m} <     t_{m} ),  
end{align} 

I always get an error:

! Undefined control sequence.  
<argument> ..._{1,m} times I(x_{i}^{m} geqslant   
                                              t_{m} ) + c_{2,m} times I...  
l.124 end{align}

When I replace geqslant with >=, it is okay.

I already include the amsmath package. What would cause the problem?

Thanks and regards!


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}

Понравилась статья? Поделить с друзьями:
  • Uncaught syntaxerror missing after argument list ошибка
  • Uncaught syntaxerror invalid or unexpected token ошибка
  • Uncaught rangeerror array buffer allocation failed ошибка
  • Uncaught in promise ошибка 404
  • Uncaught in promise ошибка 400