我们又回到了未定义的控制序列错误,但这次我无法找到它。它与页眉和页脚有关:
\let\Chaptermark\chaptermark
\def\chaptermark#1{\def\Chaptername{#1}\Chaptermark{#1}}
\fancyhead{}
\fancyhead[L]{\small \emph{Text}}
\fancyhead[R]{\small Text}
\fancyfoot{}
\fancyfoot[R]{\small \thepage}
\fancyfoot[L]{\small \emph{Chapter \thechapter. \Chaptername}}
和日志报告(错误信息附近):
]) (./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'.
[9
] ! Undefined control sequence. <argument> Chapter \thechapter .
\Chaptername
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.
和这是调用几个 .tex 文件的主 .tex 文件的代码。
\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}
\usepackage{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}
\usepackage{subcaption}
\usepackage{fancyvrb}
\usepackage{siunitx}
\usepackage{fixltx2e}
\usepackage{draftwatermark}
\usepackage[figuresright]{rotating}
\usepackage{helvet}
\usepackage{footnote}
\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.
\SetWatermarkText{DRAFT}
\SetWatermarkScale{3}
\SetWatermarkLightness{0.9}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\pgfplotsset{every tick label/.append style={font={{\scriptsize}}}}
\pgfplotsset{/pgf/number format/use comma}
\pgfplotsset{compat=1.5}
\author{Gerard Illana Meler}
\date{September 2016}
\begin{document}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[L]{\small \emph{TEXT}}
\fancyhead[R]{\small TEXT}
\fancyfoot{}
\fancyfoot[R]{\small \thepage}
\input{Chapters/01_Title}
\input{Chapters/02_Abstract}
\chapter*{Acknowledgements}
\emph{Text}
\tableofcontents
\listoffigures
\listoftables
\let\Chaptermark\chaptermark % THIS IS THE ERROR SOURCE
\def\chaptermark#1{\def\Chaptername{#1}\Chaptermark{#1}} % THIS IS THE ERROR SOURCE
\fancyhead{} % 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{} % 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{Presentation}
\externaldocument{Chapters/03_Presentation}
\input{Chapters/03_Presentation}
\chapter{Introduction}
\externaldocument{Chapters/04_Introduction}
\input{Chapters/04_Introduction}
\chapter{Experimental data}
\externaldocument{Chapters/05_Experimental_data}
\input{Chapters/05_Experimental_data}
\chapter{Analysis of the vehicle usage} \label{Analysis_of_the_vehicle_usage}
\externaldocument{Chapters/06_Analysis_of_the_vehicle_usage}
\input{Chapters/06_Analysis_of_the_vehicle_usage}
\chapter{Definition of driving patterns}
\externaldocument{Chapters/07_Definition_of_driving_patterns}
\input{Chapters/07_Definition_of_driving_patterns}
\chapter{Estimation of alternative power-train solutions}
\externaldocument{Chapters/08_Estimation_of_alternative_power_train_solutions}
\input{Chapters/08_Estimation_of_alternative_power_train_solutions}
\chapter{Impact of alternative power-trains}
\externaldocument{Chapters/09_Impact_of_alternative_power_trains}
\input{Chapters/09_Impact_of_alternative_power_trains}
\chapter{List of abbreviations}
\externaldocument{Chapters/98_List_of_abbreviations}
\input{Chapters/98_List_of_abbreviations}
\bibliographystyle{IEEEtran}
\bibliography{References/Bibliography_report}
\appendix
\chapter{Appendix}
\externaldocument{Chapters/99_Appendix}
\input{Chapters/99_Appendix}
\end{document}
答案1
问题分析
问题是,当定义新的页面样式时,LaTeX 位于 中最后一页的中间\listoftables
;因此,当\chapter{Presentation}
执行 时,会弹出一个页面,但\Chaptername
尚未设置,因为\chaptermark
已执行后章节\clearpage that starts the work of
。
解决方案
发行\clearpage
于 之后\listoftables
,之前\let\Chaptermark\chaptermark
。
其他评论
你也可以避免定义
\Chaptername
和重新定义\chaptermark
:只需这样做\fancyfoot[L]{\small\emph{\nouppercase{\leftmark}}}
所有
\externaldocument
命令都没有任何作用。执行时,\input{file}
效果与在原处添加内容相同file.tex
。而且 LaTeX 不需要依赖\externaldocument
其正在处理的文档中的标签和交叉引用。还要加载
fix-cm
以删除draftwatermark
有关字体替换的警告。您不需要\SetWatermarkScale{3}
。