LaTeX compiling error if more sections are added: "Undefined control sequence"
You seem to be trying to create a function to get the current chaptername and put that in the footer. The function caused some problems. Also, the function already exists. It is called \leftmark
, which would in a report print the current chapter, and you also have \rightmark
which prints the current section. In an article these would respectively be the section and the subsection.
Output
Code
\documentclass[11pt, twoside, draft]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}
\usepackage{fancyhdr}
\usepackage{subcaption}
\usepackage[numbers,sort&compress]{natbib}
\usepackage{color,soul}
\usepackage{xcolor}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{array}
\usepackage{colortbl}
\usepackage{hyperref}
\usepackage{xr}
\usepackage{textcomp}
\usepackage{courier}
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{font=footnotesize, labelfont=sc}
\graphicspath{ {images/} }
%\pagestyle{fancy}
\definecolor{bblue}{HTML}{A9D0F5}
\definecolor{lightbblue}{HTML}{CEF6EC}
\definecolor{darkbblue}{HTML}{4189F5}
\definecolor{ggreen}{HTML}{D8F6CE}
\definecolor{darkggreen}{HTML}{41F583}
\definecolor{verydarkggreen}{HTML}{31B404}
\definecolor{rred}{HTML}{F5A9A9}
\definecolor{verydarkrred}{HTML}{DF0101}
\definecolor{oorange}{HTML}{F5ECCE}
\definecolor{verydarkoorange}{HTML}{DF7401}
\usepackage{pgffor,lipsum}
% \def\tabularxcolumn#1{m{#1}} This is for vertical centering in tabularx.
%\input{Chapters/01_Title}
%\input{Chapters/02_Abstract}
\pagestyle{fancy}
%\let\Chaptermark\chaptermark
%\def\chaptermark#1{\def\Chaptername{#1}\Chaptermark{#1}}
\fancyhead{}
\fancyhead[L]{\small \emph{Title}}
\fancyhead[R]{\small Author name}
\fancyfoot{}
\fancyfoot[R]{\small \thepage}
\fancyfoot[L]{\small \itshape \leftmark.}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\chapter{Presentation}
\foreach \x in {1,...,50}{
\section{Sectiontitle}
\lipsum
}
%\externaldocument{Chapters/03_Presentation}
%\input{Chapters/03_Presentation}
\chapter{Introduction}
%\externaldocument{Chapters/04_Introduction}
%\input{Chapters/04_Introduction}
%\bibliographystyle{IEEEtran}
%\bibliography{References/Bibliography_report}
%\appendix
\chapter{Appendix}
%\externaldocument{Chapters/99_Appendix}
%\input{Chapters/99_Appendix}
\end{document}

Gerard.Ill
Updated on August 15, 2022Comments
-
Gerard.Ill about 1 year
After several hours of trying to find the error that was making the compilation fail:
Undefined control sequence. \listoffigures
Resulted that this error has nothing to relate to figures, neither tables.
It seems that I have reached a section max number limit (yes, it seems incredible also for me): if add another
\section{title}
to any of the .tex files that are called in the project, the error ofUndefined control sequence.
will arise.And, curiously, this max number of sections seems to be the number of sections that fit in a single page of the Table of Contents:
So, I have no idea how to deal with this.
I am stuck and I simply cannot add any more sections
\section{title}
to my .tex project.Code in the main document (which calls other .tex files that are very simple and contain only commands for sectioning, tables, figures, and tikz pictures with captions):
\documentclass[11pt, twoside, draft]{report} \usepackage[utf8]{inputenc} \usepackage{graphicx} \usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry} \usepackage{fancyhdr} \usepackage{subcaption} \usepackage[numbers,sort&compress]{natbib} \usepackage{color,soul} \usepackage{xcolor} \usepackage{pgfplots} \usepackage{tikz} \usepackage{booktabs} \usepackage{tabularx} \usepackage{longtable} \usepackage{tabu} \usepackage{array} \usepackage{colortbl} \usepackage{hyperref} \usepackage{xr} \usepackage{textcomp} \usepackage{courier} \usepackage{graphicx} \usepackage{caption} \captionsetup{font=footnotesize, labelfont=sc} \graphicspath{ {images/} } \pagestyle{fancy} \definecolor{bblue}{HTML}{A9D0F5} \definecolor{lightbblue}{HTML}{CEF6EC} \definecolor{darkbblue}{HTML}{4189F5} \definecolor{ggreen}{HTML}{D8F6CE} \definecolor{darkggreen}{HTML}{41F583} \definecolor{verydarkggreen}{HTML}{31B404} \definecolor{rred}{HTML}{F5A9A9} \definecolor{verydarkrred}{HTML}{DF0101} \definecolor{oorange}{HTML}{F5ECCE} \definecolor{verydarkoorange}{HTML}{DF7401} % \def\tabularxcolumn#1{m{#1}} This is for vertical centering in tabularx. \pgfplotsset{every tick label/.append style={font={{\scriptsize}}}} \pgfplotsset{/pgf/number format/use comma} \pgfplotsset{compat=1.5} \input{Chapters/01_Title} \input{Chapters/02_Abstract} \pagestyle{fancy} \let\Chaptermark\chaptermark \def\chaptermark#1{\def\Chaptername{#1}\Chaptermark{#1}} \fancyhead{} \fancyhead[L]{\small \emph{Title}} \fancyhead[R]{\small Author name} \fancyfoot{} \fancyfoot[R]{\small \thepage} \fancyfoot[L]{\small \emph{Chapter \thechapter. \Chaptername.}} \tableofcontents \listoffigures \listoftables \chapter{Presentation} \externaldocument{Chapters/03_Presentation} \input{Chapters/03_Presentation} \chapter{Introduction} \externaldocument{Chapters/04_Introduction} \input{Chapters/04_Introduction} \bibliographystyle{IEEEtran} \bibliography{References/Bibliography_report} \appendix \chapter{Appendix} \externaldocument{Chapters/99_Appendix} \input{Chapters/99_Appendix} \end{document}
Thank you in advance for your help.
EDIT Nº1 This is the error log near to the
!
indicator. [...]] (./Report.toc LaTeX Font Info: External font `cmex10' loaded for size (Font) <10.95> on input line 2. LaTeX Font Info: External font `cmex10' loaded for size (Font) <8> on input line 2. LaTeX Font Info: External font `cmex10' loaded for size (Font) <6> on input line 2. [4 ]) \tf@toc=\write4 \openout4 = `Report.toc'. ! Undefined control sequence. <argument> Chapter \thechapter . \Chaptername . l.95 \listoffigures 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., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. [5] (./Report.lof) \tf@lof=\write5 \openout5 = `Report.lof'. [6 ] (./Report.lot Overfull \hbox (1.74966pt too wide) in paragraph at lines 4--4 [][] []\OT1/cmr/m/n/10.95 Summary of power-trains used and/or de-vel-op-ment i n pas-sen-ger light-weight | [] ) \tf@lot=\write6 \openout6 = `Report.lot'. [7 ] Chapter 1.
[...]
By the way, this error has something to relate with the auxiliary files result of the compilation, because if get the error, and then I delete the sections that "exceed", I keep obtaining the same error. I need to erase all the auxiliary files, and then if I compile (respecting this apparent max number of sections in the .tex project), it works; but obviously I will need soon or later to add more sections.
-
David Carlisle about 7 yearsthe error you show is not the format tex uses so you have not shown which command is undefined. Copy the exact error message from the log all the lines from
!
to?
put in a code block in your question so linebreaks are preserved -
Runar about 7 yearsThe error is becouse of the lines regarding
chaptermark
andChaptername
. What are you trying to do there? Removing those lines solves your problem. -
David Carlisle about 7 yearsthe error message which was not in your original question shows that the undefined command is
\Chaptername
which you are (rather strangely) defining in a local scope that does not include the list of figures. -
David Carlisle about 7 yearsyou need to fix (or delete) the chaptermark definition, then delete the corrupted
Report.lof
file and regenerate.
-