Take the 2-minute tour ×
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.

My problem is that I can't create a table of contents for my document. I just use

\usepackage{tocloft}
...
  \newpage      
    \tableofcontents

but it's generating nothing but the word "Contents"! However TeXstudio, in the left sidebar, is showing all sections and stuff.

enter image description here

When I open the .toc file with notepad++ there's only this string

\select@language {russian}

Example

\documentclass[14pt,a4paper]{extarticle}
\usepackage[T2A]{fontenc}
\usepackage[english,russian]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{relsize}
\usepackage{listings}
\usepackage{tocloft}
\usepackage{tocvsec2}


\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\lstset{
  language=php,
  numbers=none,
  tabsize=3,
  breaklines=true,
  aboveskip=1ex,
  belowskip=1ex,
  basicstyle=\small\ttfamily,
  framerule=0pt,
  backgroundcolor=\color{gray!10},
  columns=fullflexible,
  showstringspaces=false
}

\begin{document}
    \newpage
        \tableofcontents
\newpage
        \begin{center}
            \section*{Краткая характеристика}
        \end{center}
        В данной работе рассматривается создание и управление базой данных для веб-сайта. На примерах рассмотрена регистрация пользователей на сайте, осуществление восстановления логина/пароля пользователя, так же рассмотрены функции администратора сайта - добавление/удаление информации и объектов.

        Все формы созданы на языке гипертекстовой разметки HTML, для создания сценариев взаимодействия с базами данных используется язык PHP.

        Применяемая СУБД: MySQL.

        Для администрирования СУБД использовалось приложение PHPMyAdmin.

\end{document}
share|improve this question
1  
And (just to be sure) do you run the document twice? –  Gonzalo Medina Dec 3 '12 at 18:55
1  
For this kind of problem, you should clear out all auxiliary files and start clean. Delete .toc and .aux files and recompile (at least twice). –  Werner Dec 3 '12 at 18:55
    
@GonzaloMedina yep, even more than twice –  Danil Gholtsman Dec 3 '12 at 19:00
    
@Werner well, its not helped me –  Danil Gholtsman Dec 3 '12 at 19:04
    
What document class are you using? Do you get any warning/error messages (if so, please add them verbatim to your question)? Can we please see a small but complete skeleton of your document? –  Gonzalo Medina Dec 3 '12 at 19:06
show 5 more comments

1 Answer

up vote 4 down vote accepted

You are using \section*{...}. This will format its text like a section, but the section will not be numbered and it will not be listed in the table of contents. Remove the star, compile twice, and the section should appear in the toc. If you want to have different entries in the toc and in the main text (for example if the section title is much too long for the toc), you can use \section[toc title]{section title}, where "toc title" goes into the toc and "section title" is written in the main text.

As more MWE you could look at

\documentclass{article}
\usepackage{tocloft}
\begin{document}
\tableofcontents
\newpage
\section[Some section title]{\centering Some longer section title}

\section*{\centering Another section title}
\end{document}

and the result when compiling it (twice).

I should also mention \addcontentsline{toc}{section}{section title only in toc} which adds an entry(-line including page number) to the toc (lof would add to the list of figures, lot to tables,...), formatted as section, but would not write anything in the main text.

share|improve this answer
    
Oh, thanks, it helped! –  Danil Gholtsman Dec 3 '12 at 19:27
1  
@DanilGholtsman You're welcome! Sometimes such small things have big effects and are hard to find (I know that from experience...). –  Stephen Dec 3 '12 at 19:59
add comment

Your Answer

 
discard

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.