# Add an asterisk in front of section label in TOC

Could you please tell me how to make the table of content like this:

Preface..................................i

Chapitre 1. Les décisions ................1

1.1 Bla bla bla ........................6

1.2 Bla bla bla ........................7

Chapitre 2. Les conférence ...............10

2.1 Bla bla bla ........................16

*2.2 Bla bla bla ........................17

2.3 Bla bla bla ........................19

*2.4 Bla bla bla ........................21

2.5 Bla bla bla ........................25

Conclusion ...............................30

Appendix A ...............................35

Bibliographie ............................40

The section 2.2 and 2.4 prefix an asterisk to denote a hard level. The header mark is same as in TOC.

-
You can have a look at the tocloft package to modify the table of contents. – ℝaphink Apr 21 '11 at 13:53

One way to do this is to create an environment that changes the format of the section number. Then a bit of tocloft magic will make the TOC entries look nice.

\documentclass{book}
\usepackage{tocloft}
\usepackage{lipsum} % for dummy text
\newenvironment{hard}
{\renewcommand{\thesection}{*\thechapter.\arabic{section}}}
{}
% set section numbers in TOC flush right (from the tocloft documentation)
\newlength{\extralen}
\setlength{\extralen}{0.5em}    % need some extra space at end of number
\renewcommand{\cftsecpresnum}{\hfill} % note the double ‘l’
\renewcommand{\cftsecaftersnum}{\hspace*{\extralen}}
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{A regular section}\label{easylabel}
In Section~\ref{easylabel} we see\ldots
\lipsum
\begin{hard}
\section{A hard section}\label{hardlabel}
\lipsum
\end{hard}
In Section~\ref{hardlabel} we see\ldots
\end{document}

Note that this solution will also make the section number in references have an *, and subsections within a hard section will also bear an *. (For subsections you'll also need to add the appropriate tocloft code to make their numbers flush right as well.) If you don't want that, then things get a bit more compicated.

-
 @A.M. Good solution! Thank you. – Stufazi Hoqckt Apr 22 '11 at 13:27 @Stufazi If the solution worked for you, and you consider your question answered, then you should click on the checkmark icon next to the answer to accept it. Thanks. – Alan Munn Apr 22 '11 at 13:37 Missing \endcsname inserted. \protect l.4171 ...n{Extensiones inseparables} \lipsum \end {hard} ? ! Emergency stop. Why is this? – Bruno Stonek Apr 24 '11 at 15:47 Since the example works for me and for others, there must be something else going on. Are you trying to compile this exact example? – Alan Munn Apr 24 '11 at 15:56

Here is a solution that looks pretty much like what you want, but will not number the hard section in the document. For that, you might want to tune with titlesec to format your headings:

\documentclass{book}
\usepackage{tocloft}
\usepackage{lipsum}

\newcommand{\hardsection}[1]{%
\section*{#1}%
\addcontentsline{toc}{section}{$^*$~\thesection~#2}
}

\begin{document}

\tableofcontents

\chapter{First chapter}
\section*{A section here}
\lipsum

\hardsection{And a hard section there}
\lipsum

\chapter{Second chapter}
\section*{And another section}

\lipsum

\end{document}
-
 ! Illegal parameter number in definition of \optionalsection. – Bruno Stonek Apr 24 '11 at 15:46