I've been running into this weird issue using TeXShop. Whenever I compile LaTeX and get an error, the output tells me where it is. So I fix it ... and recompile. But then I get this:
File ended while scanning use of \@new l@bel
According to the discussion here, I can fix this temporarily by trashing the aux file and recompiling. But that's not an optimal situation because then every time I make a tiny error, I have to re-trash my aux file before getting the compilation to proceed smoothly.
By moving my \end{document} code, I was able to locate the problem in my document:
% [Other text up here...]
\vspace{10 pt}
\noindent \textbf{My Thoughts}: Well, that was interesting.
% This part is the problem!
\chapter{Multivariable Calculus}
\label{2chapter:2}
\textbf{General Idea}: This is the study of [...]
% [Other text down here...]
But I can't figure out why this label is giving me the problem. I put \end{document} directly under this, tried to make a random error (I put a $ by itself), then deleted it, and came up with the error in the title. If I put \end{document} above this text and repeat the process of putting a $ by itself, I can delete it and compile LaTeX normally.
In fact, I also tried this trick with \end{document} at its normal spot. If I put that dollar sign above the line with 'Multivariable Calculus' it works as expected (i.e. error upon compiling, but works fine after I delete it), but if the dollar sign is below that line, I compile (get an error) and upon deleting that sign I get the error again (file ended while scanning, etc.)!
Here's the final few lines of the aux file that got created when I saw this error. I'm convinced that the problem is with the label here, or with the label assigned to the previous chapter (Single Variable Calculus).
\@writefile{toc}{\contentsline {chapter}{\numberline {12}Operating Systems}{29} {chapter.12}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\newlabel{1chapter:12}{{12}{29}{Operating Systems\relax }{chapter.12}{}}
\@writefile{toc}{\contentsline {part}{II\hspace {1em}Mathematics}{31}{part.2}}
\@writefile{toc}{\contentsline {chapter}{\numberline {13}Single Variable Calculus}{33}{chapter.13}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\newlabel{2cha
What's confusing, though, is that all these labels are quite similar. I'm writing a book and I have formatted it so there would be a bunch of chapters, and each chapter gets a label where the label name is Xchapter:Y where X is the "part" number (2 in this case, which corresponds to "Mathematics"), and Y is the numbering of that chapter within that part (Y=2 here, so the Multivariable Calculus chapter is the second chapter in its part). Is there a problem with the way I'm labeling things?
In case this is helpful, here's part of the preamble (my preamble is about 100 lines long, but I commented out most of it and it doesn't seem to be giving me problems).
\documentclass[10pt,notitlepage]{book}
\usepackage{amssymb,amsmath,graphicx,url,enumitem,tikz}
\usepackage{exercise}
\usepackage{hyperref}
\usepackage{makeidx}
\usepackage[bottom]{footmisc}
\usetikzlibrary{arrows}
\usepackage[left=1in,top=1in,right=1in,bottom=1in]{geometry}
\makeindex
\makeatletter
\newcommand*{\toccontents}{\@starttoc{toc}}
\makeatother
Let me know if there's anything else you would need to understand this. I'm new here and not sure how much information is too much, and this post is already getting long enough as it is.
UPDATE
Okay, so I've managed to trim down the document considerably. If you copy and paste the following text, and experiment with creating random errors before and after the Multivariable Calculus text, you should see some 'file ended while scanning ...'
\documentclass[10pt,notitlepage]{book}
\usepackage{amssymb,amsmath,graphicx,url,enumitem,tikz}
\usepackage{exercise}
\usepackage{hyperref}
\usepackage{makeidx}
\usepackage[bottom]{footmisc}
\usetikzlibrary{arrows}
\usepackage[left=1in,top=1in,right=1in,bottom=1in]{geometry}
\makeindex
\makeatletter
\newcommand*{\toccontents}{\@starttoc{toc}}
\makeatother
\title{Important Stuff}
\author{Your name here}
\begin{document}
\maketitle
\newpage
\vspace*{2 cm}
\textbf{\huge{Contents}}
\vspace{2 cm}
\toccontents
\newpage
\section{Introduction}
\part{Computer Science}
\label{part:1}
\chapter{Introduction to Computer Science}
\label{1chapter:1}
\chapter{Data Structures and Advanced Programming}
\label{1chapter:2}
\chapter{Computer Organization}
\label{1chapter:3}
\chapter{Algorithm Design and Analysis}
\label{1chapter:4}
\chapter{Principles of Programming Languages}
\label{1chapter:5}
\chapter{Computer Graphics}
\label{1chapter:6}
\chapter{Theory of Computation}
\label{1chapter:7}
\chapter{Machine Learning}
\label{1chapter:8}
\chapter{Artificial Intelligence}
\label{1chapter:9}
\chapter{Compiler Design}
\label{1chapter:10}
\chapter{Distributed Systems}
\label{1chapter:11}
\chapter{Operating Systems}
\label{1chapter:12}
\part{Mathematics}
\chapter{Single Variable Calculus}
\label{2chapter:1}
\chapter{Multivariable Calculus}
\label{2chapter:2}
\chapter{Linear Algebra}
\label{2chapter:3}
\clearpage
\addcontentsline{toc}{chapter}{Index}
\printindex
\end{document}
.auxis truncated prematurely during an erroneous compilation. As such,\newlabelis not fully written (out has the form\newlabel{<label>}{{<1>}{<2>}{<3>}{<4>}{<5>}}since you're loadinghyperref), but how/why? A minimal working example (MWE) is something that can be replicated. Understandably this is difficult when working with a very large document. However, always try and put yourself in the shoes of the community. We want to be able to copy-and-paste the code and see what's happening. – Werner May 24 '13 at 18:35\end{document}upwards (like you've been doing) but also move\begin{document}downwards. This would minimize the scope of the problem, and perhaps allow us to reproduce the problem. – Werner May 24 '13 at 18:58\newlabel{2chais clearly wrong, Just delete the.auxfile and everything should be OK. – David Carlisle May 24 '13 at 19:20.auxfile isn't terminated properly. so, as david carlisle suggests, delete the.auxfile. then clean up errors that you know about. repeat these two steps until the "first order" errors are obliterated, and your "final".auxfile should be good. – barbara beeton May 24 '13 at 19:35pdflatexon your file from the Command Line/Terminal? – Joseph Wright Aug 11 '13 at 19:24