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.

I would like the chapter number to be different in mainmatter and ToC.

In the ToC I would like to see :

chapter 1 ...
    bla bla bla


chapter 2 ...
    bla bla bla

But if I did :

\renewcommand{\thechapter}{chapter \arabic{chapter}}

In the text, when I do a crossref to a figure, for example, the figure number is chapter 1.3 for figure 3. And I do not like that.

I tried to use titletoc package without success.

Here is a short example :

\documentclass{book}
\renewcommand{\thechapter}{Serie \arabic{chapter}}
\renewcommand{\thesection}{\textrm{\Roman{section}}}

\title{titre}

\usepackage{titlesec}
\titleformat{\chapter}[display]{\filcenter\sffamily} 
{\textit{\LARGE\@title}\\
\vspace{5mm}
{\Large\thechapter}
}%
{1pc}%
{\titlerule\vspace{1pc}\Huge}%
[\vspace{1pc}\titlerule\thispagestyle{plain}]

\RequirePackage{titletoc}
\titlecontents{chapter}[1cm]{\vspace*{2ex}}{\bfseries\contentslabel{3em} : }{}    {\hfill\bfseries\contentspage}

\begin{document}

\tableofcontents

\chapter{Rappels}
\section{Section}
\begin{figure}[h]
\centering\fbox{A figure}
\caption{A caption} 
\end{figure}

\begin{table}[h]
\centering
\begin{tabular}{ccc}
\hline
aaa & bbb & ccc \\
\hline
\end{tabular}
\caption{A caption} 
\end{table}

\end{document}

I would like to keep the "serie" in the ToC but not in the figure and table number.

Here is a solution which work without the babel package following the answer of gonzalo medina. I redefined \chaptername instead of manually add "serie" because all of this is in a class file and it is easier to change the name of the "serie" if it is defined from a variable.

\documentclass{book}

\renewcommand{\chaptername}{Serie}

\usepackage[titles]{tocloft}

\newlength\mylen
\renewcommand\cftchappresnum{\bfseries \chaptername~}
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylen}
\renewcommand\cftchapaftersnum{:}
\renewcommand{\thesection}{\textrm{\Roman{section}}}

\usepackage{titlesec}
\titleformat{\chapter}[display]{\filcenter\sffamily} 
{\textit{\LARGE\@title}\\\vspace{5mm}
{\Large\chaptername~\thechapter}}%
{1pc}{\titlerule\vspace{1pc}\Huge}%
[\vspace{1pc}\titlerule\thispagestyle{plain}]

\begin{document}

\tableofcontents

\chapter{Rappels}
\section{Section}
\begin{figure}[h]
\centering\fbox{A figure}
\caption{A caption} 
\end{figure}

\begin{table}[h]
\centering
\begin{tabular}{ccc}
\hline
aaa & bbb & ccc \\
\hline
\end{tabular}
\caption{A caption} 
\end{table}

\end{document}

If I use the \babel package with the francais option, \chaptername is defined by babel at the beginning of the document. Thus I have to add this in the preamble :

\usepackage[francais]{babel}

\AtBeginDocument{\renewcommand{\chaptername}{Serie}}

But it does not work for the ToC. In the ToC there is still chapter instead of "serie". Thus I defined a new variable and I use it instead of chapter name.

\documentclass{book}

\usepackage[francais]{babel}

\newcommand{\seriename}{Serie}

\usepackage[titles]{tocloft}

\newlength\mylen
\renewcommand\cftchappresnum{\bfseries \seriename~}
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylen}
\renewcommand\cftchapaftersnum{:}
\renewcommand{\thesection}{\textrm{\Roman{section}}}

\usepackage{titlesec}
\titleformat{\chapter}[display]{\filcenter\sffamily} 
{\textit{\LARGE\@title}\\\vspace{5mm}
{\Large\seriename~\thechapter}}%
{1pc}{\titlerule\vspace{1pc}\Huge}%
[\vspace{1pc}\titlerule\thispagestyle{plain}]

\begin{document}

\tableofcontents

\chapter{Rappels}
\section{Section}
\begin{figure}[h]
\centering\fbox{A figure}
\caption{A caption} 
\end{figure}

\begin{table}[h]
\centering
\begin{tabular}{ccc}
\hline
aaa & bbb & ccc \\
\hline
\end{tabular}
\caption{A caption} 
\end{table}

\end{document}
share|improve this question

3 Answers 3

up vote 4 down vote accepted

To redefine the formatting of the chapter entries you can use either the tocloft or the titletoc package; below there's an example with tocloft showing the modifications required to include "Serie" before the chapter numbers and a colon immediately after the chapter numbers:

\documentclass{book}
\usepackage[titles]{tocloft}

\newlength\mylen
\renewcommand\cftchappresnum{\bfseries Serie~}
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylen}
\renewcommand\cftchapaftersnum{:}
\renewcommand{\thesection}{\textrm{\Roman{section}}}

\usepackage{titlesec}
\titleformat{\chapter}[display]{\filcenter\sffamily} 
{\textit{\LARGE\@title}\\\vspace{5mm}
{\Large\thechapter}}%
{1pc}{\titlerule\vspace{1pc}\Huge}%
[\vspace{1pc}\titlerule\thispagestyle{plain}]

\begin{document}
\tableofcontents

\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}
\chapter{Test Chapter Two}
\section{Test Section Two One}
\section{Test Section Two Two}

\end{document}

enter image description here

After the edit to the original question, here's some code in which I used \addto\captionsfrancais to change \chaptername in the preamble:

\documentclass{book}
\usepackage[francais]{babel}
\usepackage[titles]{tocloft}
\usepackage{titlesec}

\newlength\mylen
\renewcommand\cftchappresnum{\bfseries\chaptername~}
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylen}
\renewcommand\cftchapaftersnum{:}
\renewcommand{\thesection}{\textrm{\Roman{section}}}

\titleformat{\chapter}[display]{\filcenter\sffamily} 
{\textit{\LARGE\@title}\\\vspace{5mm}
{\Large\chaptername~\thechapter}}%
{1pc}{\titlerule\vspace{1pc}\Huge}%
[\vspace{1pc}\titlerule\thispagestyle{plain}]

\addto\captionsfrancais{\renewcommand{\chaptername}{Serie}}

\begin{document}

\tableofcontents

\chapter{Rappels}
\section{Section}
\begin{figure}[h]
\centering\fbox{A figure}
\caption{A caption} 
\end{figure}

\begin{table}[h]
\centering
\begin{tabular}{ccc}
\hline
aaa & bbb & ccc \\
\hline
\end{tabular}
\caption{A caption} 
\end{table}

\end{document}
share|improve this answer
    
This do the trick but it removes all the format of the ToC. –  Ger Sep 5 '12 at 7:24
    
@Ger all you have to do is to add the titles option to tocloft. I updated my answer with the settings from your example. –  Gonzalo Medina Sep 5 '12 at 11:57
    
Ok it works, but I changed \chaptername to serie and latex does not consider that. Actuallay, I do not understand why. If I add AtBeginDocument it works for the mainmater but the toc remains with chapter. I did all in a class file based on the book class. If I change chaptername directly in the tex file AtBeginDocument is not necessary. I fix this by using another variable which is not chaptername. –  Ger Sep 5 '12 at 14:35
    
@Ger Did you see my updated answer? I changed \chaptername to Serie in \cftchappresnum. And I used your settings so if something is not working something else is going on in your docuemnt and you need to provide that information in your question. –  Gonzalo Medina Sep 5 '12 at 14:38
    
Yes I saw. The origin of my issue is the francais option of the babel package which define at the beginning of the document the name of chapter. –  Ger Sep 5 '12 at 14:54

The toc setting is defined by \l@chapter which in book is

\newcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}

So you can redefine that and add Chapter at a suitable point (just before #1 for example)

share|improve this answer

I did not understand if you have some problem with the table of contents, but if what that you want is a simple numbering of tables and figures in a document class type book (the same for the entire document) this example is self-explanatory:

\documentclass{book}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\begin{document}

\chapter{Chapter}
\section{Section}
\begin{figure}[h]
\centering\fbox{A figure}
\caption{A caption} 
\end{figure}

\begin{table}[h]
\centering
\begin{tabular}{ccc}
\hline
aaa & bbb & ccc \\
\hline
\end{tabular}
\caption{A caption} 
\end{table}

\end{document}
share|improve this answer
    
No I do not want to remove the chapter number but only the chapter name. –  Ger Sep 5 '12 at 7:21
    
Then you cannot insert the word "Serie" redefining \thechapter, because \thechapter is the number of the chapter that must be referenced. Perhaps is better comment the line 2 of your MWE and try to insert this word in \titleformat. –  Fran Sep 5 '12 at 10:13

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.