We're back again with the undefined control sequence error, but this time I am not capable of finding it. It is something related with the header and footer:

\fancyhead[L]{\small \emph{Text}}
\fancyhead[R]{\small Text}
\fancyfoot[R]{\small \thepage}
\fancyfoot[L]{\small \emph{Chapter \thechapter. \Chaptername}}

AND Log report (near the error message):

]) (./Chapters/02_Abstract.tex) [2] [3

] (./Report.toc [4

]) \tf@toc=\write5 \openout5 = `Report.toc'.

 [5] (./Report.lof [6

] [7]) \tf@lof=\write6 \openout6 = `Report.lof'.

 [8] (./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=\write7 \openout7 = `Report.lot'.


] ! Undefined control sequence. <argument> Chapter \thechapter .
                                               l.121 \chapter
              {Presentation} 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.

AND Here is the code from the main .tex file that calls several .tex files.

\documentclass[11pt, twoside, draft]{report}


\captionsetup{font=footnotesize, labelfont=sc}
\graphicspath{ {images/} }

% \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}

\author{Gerard Illana Meler}
\date{September 2016}


\fancyhead[L]{\small \emph{TEXT}}
\fancyhead[R]{\small TEXT}
\fancyfoot[R]{\small \thepage}







\let\Chaptermark\chaptermark % THIS IS THE ERROR SOURCE
\def\chaptermark#1{\def\Chaptername{#1}\Chaptermark{#1}} % THIS IS THE ERROR SOURCE
\fancyhead[L]{\small \emph{Text}} % THIS IS THE ERROR SOURCE
\fancyhead[R]{\small Text} % THIS IS THE ERROR SOURCE
\fancyfoot[R]{\small \thepage} % THIS IS THE ERROR SOURCE
\fancyfoot[L]{\small \emph{Chapter \thechapter. \Chaptername}} % THIS IS THE ERROR SOURCE



\chapter{Experimental data}

\chapter{Analysis of the vehicle usage} \label{Analysis_of_the_vehicle_usage}

\chapter{Definition of driving patterns}

\chapter{Estimation of alternative power-train solutions}

\chapter{Impact of alternative power-trains}

\chapter{List of abbreviations}




  • i've recoded the error log insertion as a code block, since it's meant to be taken literally. material marked as a quote on this site reflows the text; i wasn't able to reconstruct that very well. Commented Sep 9, 2016 at 18:50
  • I cannot reproduce your problem. The only errors I get are about missing files that the document tries to input; so maybe one of your input files is the culprit. Can you invest a little bit more effort and provide a complete document (no reference to other documents) that shows the problem? And without loading packages that are irrelevant to the error?
    – gernot
    Commented Sep 9, 2016 at 18:55
  • in the document classes i'm most familiar with, the command is \chaptername with a lowercase "c"; the error message has \Chaptername. it's not clear where that is coming from; most likely in a file not shown here, and in particular, Report.lot, which according to the log has just been input, but not completely read in. Commented Sep 9, 2016 at 18:55
  • What makes you think that \Chaptername is defined?
    – egreg
    Commented Sep 9, 2016 at 19:01
  • @egreg @barbarabeeton \Chaptername gets defined in the redefined macro \chaptermark. When I compile the document without the \inputs, I get no errors.
    – gernot
    Commented Sep 9, 2016 at 19:06

1 Answer 1


Analysis of the problem

The problem is that when the new page style is being defined, LaTeX is in the middle of the last page in \listoftables; so when \chapter{Presentation} is executed, a page is ejected to begin with, but \Chaptername has not yet been set, because \chaptermark is executed after the \clearpage that starts the work of\chapter`.


Issue \clearpage after \listoftables, before \let\Chaptermark\chaptermark.

Miscellaneous comments

  1. You can also avoid defining \Chaptername and redefining \chaptermark: just do

  2. All your \externaldocument commands do exactly nothing. When you do \input{file} it's the same as if you added the contents of file.tex at the spot. And LaTeX doesn't need to rely on \externaldocument for labels and cross-references in the document it's processing.

  3. Also load fix-cm in order to remove the draftwatermark warning about font substitution. You won't need \SetWatermarkScale{3}.

  • Thank you all for your responses, I fix it through egreg solution proposal. I also applied all the rest of the corrections, sorry I am not an experienced user of LaTeX and it is always welcome to learn how some aspects actually work.
    – Gerard.Ill
    Commented Sep 10, 2016 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .