Beamer : section title — titre des sections

I wanted to change the way beamer set the titles of the section.
For example, I wanted each section to be “Exercise 1: blabla”, “Exercise 2: another” and I wanted to be able to refer to the number of the section, that is, not to redefine the number of the section by something like “Exercise \number”.

Je voulais changer la façon dont beamer gère les titres de section.
Par exemple, je voulais que chaque section soit « Exercice 1 : blabla », « Exercice 2: autreexo » et que je puisse appeler une référence au numéro de la section, donc pas seulement changer le numéro de la section en « Exercice\numéro ».

Here is my way to do it, thanks to this very good site (check also the chapter section ;)):

\documentclass{article}
\usepackage{enumerate}

%Changing the section titles
\def\section{\numberedsection}
\def\numberedsection#1{\numberedsectionwithtwoarguments[#1]{#1}}
%I only want numbered sections
\def\numberedsectionwithtwoarguments[#1]#2{%I always want an argument (title)
\ifhmode\par\fi
\removelastskip
\vskip 3ex\goodbreak
\refstepcounter{section}%
\begingroup
\noindent\leavevmode\Large\bfseries\raggedright
%Here is my definition
%#2 is the title
Exercise \thesection\ : #2\par
\endgroup
\vskip 2ex\nobreak
\addcontentsline{toc}{section}{%
\protect\numberline{\thesection}%
#1}%
}
%Document example
\begin{document}
\section{test}
one two
\section{test2}\label{mysection}
Blablabla
ergfv
\begin{enumerate}[\ref{mysection}.i]
\item Truc
\item Chose
\end{enumerate}
\end{document}

Voici ma façon de faire, grâce à ce très bon site (faites un tour sur la partie chapitre ;)) :

\documentclass{article}
\usepackage{enumerate}

%Changer les titres des sections
\def\section{\numberedsection}
\def\numberedsection#1{\numberedsectionwithtwoarguments[#1]{#1}}
%Je ne veux que des sections numérotées
\def\numberedsectionwithtwoarguments[#1]#2{%Je veux toujours un argumen (le titre)
\ifhmode\par\fi
\removelastskip
\vskip 3ex\goodbreak
\refstepcounter{section}%
\begingroup
\noindent\leavevmode\Large\bfseries\raggedright
%C’est ici que ça se passe
%#2 est le titre
Exercice \thesection\ : #2\par
\endgroup
\vskip 2ex\nobreak
\addcontentsline{toc}{section}{%
\protect\numberline{\thesection}%
#1}%
}
%Exemple de document
\begin{document}
\section{test}
one two
\section{test2}\label{masection}
Blablabla
ergfv
\begin{enumerate}[\ref{masection}.i]
\item Truc
\item Chose
\end{enumerate}
\end{document}

~ by loquehumaine on 2008, October 28 - Tuesday.

Leave a Reply