This is my first attempt in using Tex and I am already drafting my Thesis in this, but so far so good. However, I have lately encountered this error, and I cannot figure out what this means... help please...enter image description here

%LINE 16
\frontmatter      % Begin Roman style (i, ii, iii, iv...) page numbering

% Set up the Title Page

% Chapter 1

\chapter{Introduction} % Write in your own chapter title
\lhead{Chapter 1. \emph{Introduction}} % Write in your own chapter title to set the page header


\section{Research Aim and Objectives}

\section{Research Approach}

\section{Thesis Structure}

enter image description here

  • 2
    Welcome to TeX.SX! This error is usually due to fragile commands in section titles. An example of code is needed.
    – egreg
    Commented Aug 21, 2015 at 13:15
  • Welcome! It may mean you have an unmatched opening curly bracket. Or TeX thinks you do. Start by looking on line 16 of Thesis.tex but sometimes the line number won't be very accurate. Probably it is in your preamble, though. If you post code which we can use to reproduce the error, we can help you find it.
    – cfr
    Commented Aug 21, 2015 at 13:16
  • 1
    This is due to a corrupted aux file. Just remove the file Thesis.aux. (Most LaTeX text editors have this somewhere in the menus).
    – yo'
    Commented Aug 21, 2015 at 13:18
  • 1
    @yo' -- but since this seems to be a problem related to something that was in the .aux file, it might happen again (on a "second" run). egreg's pointer to section titles is a reasonable clue, and it is almost certainly in a section title recently added. Commented Aug 21, 2015 at 13:22
  • 2
    @Manoj if you can make the smallest example you can that has the problem (probably just the section headings needed) then probably you can replace the words with abc and still show the same error. so no need to show any secrets, but basically if you comment out your section headings and remove the aux file then re-run latex, it should work, put the headings back one at a time until it breaks, and that will show the problem. Commented Aug 21, 2015 at 13:38

1 Answer 1


I think yo' is right with the comment, that the .aux file is truncated:

\section{Hello World}

After pdflatex test.tex the .aux file is:

\@writefile{toc}{\contentsline {section}{\numberline {1}Hello World}{1}}

Then the .aux file is edited in an editor to truncate it to:

\@writefile{toc}{\contentsline {s

Running again:

pdflatex -file-line-error test.tex

gives the error in the same format as in the question:

) (./test.aux)
Runaway argument?
{\contentsline {s
./test.tex:2: File ended while scanning use of \@writefile.
<inserted text>
l.2 \begin{document}


The \@writefile command starts on line 2 in file test.aux, but the error is detected after the file end, thus the file name is shown as test.tex.

Back to the question, the error occurs during the first read of the .aux file. The .aux file is truncated at line 16.

Suspicion: The file size of the .aux file is just a sector with 512 bytes. Thus the write cache did not get flushed at the probably abnormal end of the previous LaTeX run.

Deleting the .aux file and running LaTeX again should fix the issue, when the run is not aborted due to a fatal error.

You must log in to answer this question.

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