GeneralWhy "File ended while scanning use of \contentsline" error?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
EmceeDIG
Posts: 7
Joined: Wed Oct 17, 2012 12:25 pm

Why "File ended while scanning use of \contentsline" error?

Post by EmceeDIG »

Hi,

Please, could you help me resolve the LaTeX runaway argument error below?

Code: Select all

"File ended while scanning use of \contentsline."
"<inserted text>" \par
With many thanks,

Esuene.
Last edited by cgnieder on Tue Oct 23, 2012 1:04 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Why "File ended while scanning use of \contentsline" err

Post by Stefan Kottwitz »

Hi Esuene,

welcome to the board!

Can you post a small example, which produces the error? It could be a reduced copy of your document.

Stefan
LaTeX.org admin
EmceeDIG
Posts: 7
Joined: Wed Oct 17, 2012 12:25 pm

Why "File ended while scanning use of \contentsline" error?

Post by EmceeDIG »

Thanks Stefan_K, it's great to be here.

The document is my thesis, and I honestly cannot detect which part of the document leads to this compilation error. As a test, I have systematically removed the chapters that were previously included in the compilation, yet the error persists. So, I've included the content of my PREAMBLE file, as a MWE.

Code: Select all

\listfiles

\documentclass[onecolumn,a4paper,11pt]{report}

%
\usepackage[auto]{chappg} % To number pages per Chapter

%%%%%%%%%% WHAT TO INCLUDE IN OUTPUT FILE - Use the following to selectively exclude chapters
%\includeonly{toc,chapter1_CORR,chapter2_CORRed1,chapter3new_CORR,chapter4new_CORR,chapter5new_CORR}

\usepackage[dvips]{graphicx} %%%%%%%%%% Package for figures
\usepackage[percent]{overpic}%\setlength\unitlength{0.01}

\usepackage{fancyhdr}

\usepackage{setspace}

\usepackage[font=small,labelfont=bf,labelsep=colon]{caption}[2012/02/19]

%\usepackage{ctable} % For FOOTNOTES directly below TABLES
\usepackage{footnote}
\makesavenoteenv{tabular}
\usepackage{threeparttable} % For FOOTNOTES in FLOATS


\usepackage{multirow}
\frenchspacing

\usepackage{array}

\usepackage[english]{babel} % For wrapping texts in a column with specified width

%%%%%%%%%%% Specify FONT-TYPE, use one with Maths Support:
\usepackage[T1]{fontenc}

\usepackage{mathptmx}  % Font-type is Times with its Maths support

\usepackage[sort]{natbib}

\usepackage{xcolor}
	\definecolor{fuchsia}{rgb}{1,0,1}
	\definecolor{orange}{rgb}{1,0.6445,0}
	\definecolor{brown}{rgb}{0.6445,0.1641,0.1641}
	\definecolor{gray}{rgb}{0.5,0.5,0.7}
	\definecolor{lightgray}{rgb}{0.8242,0.8242,0.8242}
	\definecolor{indigo}{rgb}{0.3,0,0.51}
	\definecolor{blueviolet}{rgb}{0.5391,0.168,0.8828}
%
\usepackage{varioref}
%
\usepackage{enumerate} % for optional arguments for the enumerate (numbered list) environment so that you can define 																 the style in which LaTeX prints the counter.

\usepackage{rotating} % To rotate wide tables
\setlength{\rotFPtop}{0pt plus 1fil}

\usepackage{flafter} % The ``flafter package'' used to ensure floats are never placed before their references.

\usepackage[justification=centering, singlelinecheck=false]{subfig} % Uses sub-floats within a single float {Latex * center sub-float captions as well. Sub-floats are centred, and their Captions are also centred using ``singlelinecheck=false'' option.

\usepackage[below]{placeins} %\usepackage[section]{placeins}

\usepackage{verbatim} % Must be used to activate "`BLOCK COMMENTING"'

\usepackage{soul}

\usepackage{pdflscape}

\usepackage{dcolumn} % To construct tables with entries aligned on a ”decimal point” etc.

\usepackage{lastpage} % To find the total number of pages for use in "page X of Y"

\usepackage{amssymb}
\usepackage{amsmath}

\numberwithin{equation}{section} % To prepend the section number to all equation numbers.

\usepackage{appendix}

\usepackage{parskip}

% Rules for handling pre-zipped figures. To create zipped figs do these: % $ head myfigure.eps >myfigure.eps.bb; $ gzip myfigure.eps
\DeclareGraphicsRule{.eps.gz}{eps}{.eps.bb}{`zcat #1}
\DeclareGraphicsRule{.epsi.gz}{eps}{.epsi.bb}{`zcat #1}
\DeclareGraphicsRule{.eps.Z}{eps}{.eps.bb}{`zcat #1}

\setlength{\textheight}{240mm}

\setlength{\topmargin}{-5.4mm}
\setlength{\textwidth}{150mm}
\setlength{\oddsidemargin}{14.6mm}
\setlength{\evensidemargin}{14.6mm}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{4}

\usepackage[]{titlesec}

\titleformat{\chapter}[display]{\normalfont\LARGE\bfseries}{\chaptertitlename\ \thechapter}{15pt}{\LARGE}\titlespacing*{\chapter}{0pt}{*2}{*1}
		
\setlength{\textfloatsep}{0.5 cm}
\setlength{\intextsep}{0.5 cm}

%%%%%%%%  	
\renewcommand{\topfraction}{0.9}

\renewcommand{\textfraction}{0.1}

\renewcommand{\bottomfraction}{0.5}

\renewcommand{\floatpagefraction}{0.8}

\renewcommand\bibname{References}	% Specify reference file

%%%%%%%%%%%%%%%%%%%%%%%%%%%% Begin the THESIS document here
\onehalfspacing	% Line spacing


%%	\\\\\  TO REMOVE EMPTY LINE SPACE BETWEEN ITEMS IN BIBLIOGRAPHY
 \let\oldthebibliography=\thebibliography
  \let\endoldthebibliography=\endthebibliography
  \renewenvironment{thebibliography}[1]{%
    \begin{oldthebibliography}{#1}%
      \setlength{\parskip}{0ex}%
      \setlength{\itemsep}{0ex}%
  }%
  {%
    \end{oldthebibliography}%
  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%  	BEGIN DOCUMENT

\begin{document}

%
\include{cover}	% This is the front page
%
\include{declare}	
%
\include{acknowledge}
%
\include{abstract_CORR}
%
\tableofcontents
%
\listoffigures
%
\listoftables

%%%%%%%% 
\setlength{\parskip}{0.5cm}

\setlength{\parindent}{0 cm}

%% Adjusting the amount of space above and below equations
\setlength\abovedisplayskip{0.15 cm}
\setlength\belowdisplayskip{0.15 cm}

%% Adjusting the amount of space above and below captions
\setlength\abovecaptionskip{0.15 cm}
\setlength\belowcaptionskip{0 cm}
	%\addtolength\belowcaptionskip{0.5cm}

%% Adjusting the amount of space above and below captions
\setlength{\topskip}{0.5 cm}
\setlength{\footskip}{0.5 cm}

%\include{glossaryCORR}

\newpage

%%%%%%%%  	Set-up page numbering
\pagenumbering{arabic}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%			PAGE LAYOUT			%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhead[L]{\textsl{\chaptername\ \thechapter}}
\fancyhead[R]{\textsl{}}
\fancyfoot[C]{}
\cfoot{\thepage\ of \pageref{LastPage}}

\renewcommand{\headrulewidth}{0.3pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

%%%%%%%%  	THESIS CHAPTERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Include the following chapters in LaTeX compilation
%\include{chapter1}
%
\include{chapter1_CORR}

%%%%%%%%  	DRAFT CORRECTIONS
%
\include{chapter2_CORRed1}
%
\include{chapter3new_CORR}
%
\include{chapter4new_CORR}
%
\include{chapter5new_CORR}



%%%%%%%%  	BIBLIOGRAPHY
\bibliographystyle{gji} % makebst Default bibliographystyle is ``plain''. 
									%\bibliographystyle{seg}
%
\addcontentsline{toc}{chapter}{\numberline { }References}%
\bibliography{myReferences}

\fancyhf{}

%%%%%%%%  	APPENDICES
\appendix
%\appendixpage
\addappheadtotoc
%\include{appendixCHAP1}
%
\include{appendCHAP2}
%
\include{appendCHAP3}
%
\include{appendCHAP4}
%
\include{appendCHAP5}
%
\include{appendCHAP5tanz}

\end{document}
Kind regards,
Esuene.
Last edited by Stefan Kottwitz on Wed Oct 17, 2012 4:01 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Why "File ended while scanning use of \contentsline" error?

Post by Stefan Kottwitz »

Hi Esuene,

I tested your code. I had to remove the \include lines to make it testable, because I don't have the files you are including. Then it compiles without errors. So the problem is not in the posted code.

Try again, as the error persists, to post a copy of the code which has the error. No need for half a dozen includes, no need for color definitions. Remove all what is not related to the problem, to get a small document which produces the persisting error. So we can test (without searching through a big document) and fix it.

Stefan
LaTeX.org admin
EmceeDIG
Posts: 7
Joined: Wed Oct 17, 2012 12:25 pm

Why "File ended while scanning use of \contentsline" error?

Post by EmceeDIG »

Okay, thanks.

When \tableofcontents is commented out in the preamble file (shown in MWE above), the entire code runs, producing my thesis document. However, the document produced has no table of contents for the chapters and appendices compiled. My document consists of 7 chapters and 8 appendices, and was 263 pages long (prior to the \contentsline error). Let me add that the current compilation has 0 error, 29 warnings and 59 bad boxes!

How can this be explained? And how can I resolve this error from \tableofcontents?

Thank you.

Esuene.
Last edited by cgnieder on Wed Oct 17, 2012 9:56 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Why "File ended while scanning use of \contentsline" error?

Post by Stefan Kottwitz »

The explanation is probably easy. It just requires to know your code. So, have a look what a Infominimal working example means (follow the link) and post a reduced copy of your document. No real content, hack a copy down step by step, as long as the error persists. The final short code will contain the problem. Or a reduction step will do.

Perhaps somebody could already see the cause in your .toc file.

Stefan
LaTeX.org admin
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Why "File ended while scanning use of \contentsline" error?

Post by cgnieder »

EmceeDIG wrote:[...] My document [...] was 263 pages long (prior to the \contentsline error).
One way of debugging is remove everything you inserted until you have the version that worked agein. I'm not suggesting to actually delete anything but to move \end{document} to an earlier place in the document. If that works subsequently move \end{document} to a later place again, step by step. This way you should find the piece of code that causes the error.
EmceeDIG wrote:And how can I resolve this error from \tableofcontents?
May be the solution is as simple as this: delete the toc file (and maybe also the aux file) and see if it compiles. If it doesn't see above.

Regards
site moderator & package author
EmceeDIG
Posts: 7
Joined: Wed Oct 17, 2012 12:25 pm

Re: Why "File ended while scanning use of \contentsline" err

Post by EmceeDIG »

Sorry, I've been away from the internet since Wednesday.

Using cgnieder's suggestion, I've stepped in through my entire code. Rather wierdly, my code now compiles without any error messages. I found no problem whatsoever.

Many thanks Stefan and cgnieder, for your prompt assistance.

Esuene.
Post Reply