TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}

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

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).




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.


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 ...'




\title{Important Stuff}
\author{Your name here}

\vspace*{2 cm}
\vspace{2 cm}


\part{Computer Science}

\chapter{Introduction to Computer Science}

\chapter{Data Structures and Advanced Programming}

\chapter{Computer Organization}

\chapter{Algorithm Design and Analysis}

\chapter{Principles of Programming Languages}

\chapter{Computer Graphics}

\chapter{Theory of Computation}

\chapter{Machine Learning}

\chapter{Artificial Intelligence}

\chapter{Compiler Design}

\chapter{Distributed Systems}

\chapter{Operating Systems}


\chapter{Single Variable Calculus}

\chapter{Multivariable Calculus}

\chapter{Linear Algebra}


share|improve this question

closed as unclear what you're asking by Joseph Wright Aug 11 '13 at 19:24

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Welcome to TeX.SX! You may have a look on our starter guide. – Jubobs May 24 '13 at 18:26
@TakeS: It is obvious that your .aux is truncated prematurely during an erroneous compilation. As such, \newlabel is not fully written (out has the form \newlabel{<label>}{{<1>}{<2>}{<3>}{<4>}{<5>}} since you're loading hyperref), 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
@DavidCarlisle and barbara beeton, if I delete the .aux file, all is good ... until I happen to cause another error in LaTeX. Then instead of finding that error, fixing it, and recompiling, I have to first delete that .aux file again, fix the text, and then recompile. – TakeS May 24 '13 at 19:46
Either you or your editor, when an error occurs are abruptly killing Tex while it is writing the command to the aux file so it ends up with a corrupt aux file. As the aux file is read in at the start of the next run that just generates more errors until you delete it. It should (almost always) be possible to quit tex after an error without doing that – David Carlisle May 24 '13 at 19:53
Following David's comment, it would be useful if you can show us what you use to invoke TeX from your editor/command line, and perhaps how it is killed. – Bruno Le Floch May 24 '13 at 20:12

Browse other questions tagged or ask your own question.