[Latex] Problème modification sommaire.

Résolu
Kev -  
 Kev -
Bonjour,

Je souhaite modifier la mise en forme des titres dans le contenu et le sommaire mais je n'arrive pas à faire en sorte que le compteur des sections ou sous-sections soit réinitialisés lorsque qu'un nouveau chapitre commence.

Le fichier sommaire.cls:
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{sommaire}

\LoadClass{report}

\newcounter {chapitre}
\newcounter {mysection}     [chapitre] 
\newcounter {mysubsection}  [mysection]

\setcounter {chapitre}     {0}
\setcounter {mysection}    {0}
\setcounter {mysubsection} {0}

%\renewcommand {\themysection}    {}
%\renewcommand {\themysubsection} {}

\renewcommand{\chapter}[1]{%
	\addtocounter{chapitre}{1}
	\newpage
	Chapitre \thechapitre -- #1
	\addcontentsline{toc}{chapter}{Chapitre \thechapitre -- #1}
}

\renewcommand{\section}[1]{%
	\addtocounter{mysection}{1}
	\themysection - #1
	\addcontentsline{toc}{section}{\themysection - #1}
}

\renewcommand{\subsection}[1]{%
	\addtocounter{mysubsection}{1}
	\themysubsection - #1
	\addcontentsline{toc}{subsection}{\themysubsection - #1}
}

\renewcommand{\tableofcontents}{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
      \else
      \@restonecolfalse
    \fi
    \contentsname
%    \chapter*{\contentsname
%        \@mkboth{%
 %          \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
	\@starttoc{toc}%
   \if@restonecol\twocolumn\fi
}


Le fichier sommaire.tex:
\documentclass{sommaire}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}

\begin{document}

\renewcommand{\contentsname}{%
\begin{Huge}
\textbf{Sommaire}
\end{Huge}}

\tableofcontents

\chapter{Introduction}

	\section{Première section}
	
		\subsection{Première subsection}

\chapter{Présentation}

	\section{Deuxième section}
	
		\subsection{Deuxième subsection}
		
\chapter{Contenu}

\chapter{Conclusion}

\end{document}



Normalement la commande,
\newcounter {mysection}     [chapitre]

devrait réinitialiser le compteur mysection quand chapitre est incrémenté, si j'ai bien compris, mais ca ne marche pas.

Merci d'avance de votre aide.
A voir également:

4 réponses

Char Snipeur Messages postés 9813 Date d'inscription   Statut Contributeur Dernière intervention   1 299
 
http://en.wikibooks.org/wiki/LaTeX/Advanced_Topics
si je comprends bien, il vaut mieux utiliser stepcounter :
\renewcommand{\section}[1]{%
	\stepcounter{mysection}
	\themysection - #1
	\addcontentsline{toc}{section}{\themysection - #1}
}
1
Kev
 
Ça marche.
Merci beaucoup.
0
Kev
 
J'ai un autre problème.

je voudrait redéfinir \themysection et \themysubsection. Je fait donc pour cela:
\renewcommand {\themysection}    {\thechapitre-\themysection}
\renewcommand {\themysubsection} {\thechapitre-\themysection-\themysubsection}


Le problème et que j'obtient cette erreur:
! TeX capacity exceeded, sorry [main memory size=3000000].
<argument> \c@chapitre
l.18 \section{Première section}
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
0
Kev
 
Problème résolu avec ce code:
\renewcommand {\themysection}    {\thechapitre-\arabic{mysection}}
\renewcommand {\themysubsection} {\thechapitre-\arabic{mysection}-\arabic{mysubsection}}
0