TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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 am using TeXworks to try and create a PDF file. The problem is that it seems that the \tableofcontents is making the pdf generation fail. Here is part of my code which seems to be causing the trouble:

\addtocontents{toc}{entry text}

As soon as I remove that from the script, the pdf is generated. I am very new to LaTeX so I am definitely doing something that I shouldn't. Anyone can tell me what is there problem or where can I look?

I have reduced my code to this (and still managed to replicate the error




{\Huge Sample Text}


\section{Aims and Objectives}



\section{Work Packages}

\section{Relevance to Beneficiaries}

\section{Justification of resources}




The error I get:

{section}{\numberline{1}Introduction}{1} Thanks

share|improve this question
please provide a minimal but complete example which produces the error. Your given code is error free. I guess, you don't add entry text to the TOC. For example, if this argument contains a macro, there might be a problem. – Stefan Kottwitz Jan 10 '11 at 19:36
This code contains a spurious \end{bibliography} – Seamus Jan 10 '11 at 20:25

In your edited question, the following code line raises an error:


The second mandatory argument is missing: what text should be written to the TOC.

In the first code snippet it has been correct.

In the case that you would like to use \addtocontents in order to change the page style within the TOC, put the command into an argument and protect it:

share|improve this answer
I am still getting the same error: {section}{\numberline{1}Introduction}{1} – npinti Jan 10 '11 at 20:19
@npinti: As long as you don't post your code but some fictional code instead, I cannot really help you. Your code example doesn't contain Introduction like the error, for example. – Stefan Kottwitz Jan 10 '11 at 20:25
The problem is that this is part of an assignment, so I can't throw my work on the net so as to avoid possible plagiarism issues. Despite the fact that I removed any section headers from my code, I am still getting that error. – npinti Jan 10 '11 at 20:54
@npinti: You don't need to post your content. Just make a copy, remove prose content and formulas, shrink it to get it smaller as long as the error remains, then post it. Have a serious look at What is a minimal working example? to get help now and in the future. And did you follow the link in my first comment to the question? – Stefan Kottwitz Jan 10 '11 at 21:12
@npinti: Delete the .toc file (if it still contains an error) and compile/typeset again. When I compile your current example, it brings no error, just a warning "Empty thebibliography environment". – Stefan Kottwitz Jan 10 '11 at 22:05
up vote 0 down vote accepted

I think that there was something wrong with the LaTeX installation. I tried parsing the document with a plugin available for eclipse (here). The document was parsed without any problems and the pdf was successfully generated.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.