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.

Is it possible just to generate a table of contents based on sections in asterisk mode, i.e., \section*? I basically just want the table of contents without section numbers. Like a list of headings and their associated pages.

The following doesn't generate a ToC:

\documentclass[12pt,a4paper]{article}

\begin{document}

\tableofcontents

\subsection*{Section 1}

\subsection*{Section 2}

\end{document}
share|improve this question

3 Answers 3

up vote 12 down vote accepted

You don't have numbered sections, do you? In this case the simplest arrangement is

\setcounter{secnumdepth}{0} % sections are level 1

\begin{document}

\section{First}

\section{Second}

No sectional unit below \section will be numbered, but sections and subsections will go anyway in the table of contents (as this depends on the value of the tocdepth counter, default 2).

share|improve this answer
    
Suppose I don't want numbering for headings at any level, how would I modify your solution? Keep in mind I do still want a table of contents, just without heading numbering... –  ptrcao Oct 2 '11 at 12:40
4  
\setcounter{secnumdepth}{-2} will remove the numbering also for parts (and all levels below). –  egreg Oct 2 '11 at 12:41
    
This is a good solution - very minimal and unobtrusive, without any compromise. :) –  ptrcao Oct 3 '11 at 10:03
    
You are a hero. Take my internet points. –  Henrik Jun 29 '13 at 12:46
1  
@FrankEjbyPoulsen Try just after \begin{document} –  egreg Jan 22 at 20:56

The following is a manual way of adding entries to the table of contents by means of \addcontentsline:

\documentclass[12pt,a4paper]{article}

\begin{document}

\tableofcontents

\section*{Section 1}
\addcontentsline{toc}{section}{\protect\numberline{}Section 1}%
\section*{Section 2}
\addcontentsline{toc}{section}{\protect\numberline{}Section 2}%

\end{document}

Starred sections in ToC

The reason for using \numberline{} is to allow for the traditional numbered space in the table of contents. If you're not interested in this numeric alignment, then you can drop the \protect\numberline{}.

share|improve this answer

Adapting DevSolar's answer from this question (clearing out the definition of \thesection), and assuming you don't really care if you use \section*, you just want to remove numbers from the headings and ToC entries:

enter image description here

\documentclass[12pt,a4paper]{article}
\renewcommand{\thesection}{}
\begin{document}
\tableofcontents
\section{A Section}
\section{Another Section}
\end{document}
share|improve this answer
    
Thanks Mike - this seems like a fairly succinct solution - and moreover it works, though would you mind explaining what is happening? I don't understand why/how this works. –  ptrcao Oct 2 '11 at 4:37
1  
In many cases, \theX is a macro that prints the number of the current document division (where 'X' is chapter, section, subsection, etc.) Clearing it out prevents it from being printed. However, on further examination, this doesn't suppress the space between the number and the division title, and the section headings get indented more than I'd like. So I'd go with egreg's version instead. –  Mike Renfro Oct 3 '11 at 3:23
    
This is a nice option. However, in my case, it leaves a blank space where there was supposed to be the number of the section, subsection etc. How do I get rid of that? –  Frank Ejby Poulsen Jan 22 at 17:54
    
As I'd indicated, I'd go with egreg's solution over mine. –  Mike Renfro Jan 23 at 17:52

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.