Presentations and PostersHow to get Section Number in each Section Slide on LaTeX Beamer?

Beamer, Powerdot and KOMA-Script presentations, Conference posters (a0poster, baposter, tikzposter)
Post Reply
CMP
Posts: 13
Joined: Thu Aug 22, 2019 8:33 pm

How to get Section Number in each Section Slide on LaTeX Beamer?

Post by CMP »

Greetings there,

I've been trying to create Section Number with Section Title in each Section Title Slide Page on Beamer class but was not able to create it. :(

That is, as in the "Table of Contents" page, e.g.,

1 Introduction

I wanted to get

1 Introduction

on page 3, too.

But how could we accomplish this?

I would appreciate for any help in this regard.

Thanks!

Code: Select all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Question to ask!
% Solution can be found at this link

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[T1]{fontenc}
\usetheme{AnnArbor}
\usecolortheme{whale}
\setbeamercolor{title}{bg=RoyalPurple}
\setbeamercolor{frametitle}{fg=white,bg=RoyalPurple}

\usepackage{amsmath}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% To generate generate section title slides automatically in Beamer!
% Taken from this web page:
% https://tex.stackexchange.com/questions/178800/creating-sections-each-with-title-pages-in-beamers-slides
\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=10pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Question!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title[\sc Getting Section Number]
{Getting Section Number on \LaTeX \ Beamer Slides}

\begin{frame}
\titlepage
\end{frame}

\frame{{Table of Contents}
\tableofcontents
}

\section{Introduction}

\frame{\frametitle{Who is David Hilbert?} 

David Hilbert is a great Mathematician!

}

\section{Mathematics}

\frame{{How do you define Mathematics?}

Mathematics is a language of sciences. Moreover, $\cdots$

}

\section{Examples}

\frame{\frametitle{Some Examples}
  
This is the first example.

}

\end{document}
Attachments
Section Number.pdf
(118.59 KiB) Downloaded 1228 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Bartman
Posts: 366
Joined: Fri Jan 03, 2020 2:39 pm

How to get Section Number in each Section Slide on LaTeX Beamer?

Post by Bartman »

You can put \insertsectionnumber before the section title command.
CMP
Posts: 13
Joined: Thu Aug 22, 2019 8:33 pm

How to get Section Number in each Section Slide on LaTeX Beamer?

Post by CMP »

That's exactly what I was looking for.

Thank you very much, Bartman!

Here is a complete example now.

Code: Select all

\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[T1]{fontenc}
\usetheme{AnnArbor}
\usecolortheme{whale}
\setbeamercolor{title}{bg=RoyalPurple}
\setbeamercolor{frametitle}{fg=white,bg=RoyalPurple}

\usepackage{amsmath}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% To generate generate section title slides automatically in Beamer!
% Taken from this web page:
% https://tex.stackexchange.com/questions/178800/creating-sections-each-with-title-pages-in-beamers-slides
\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=10pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionnumber\protect~\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Question!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title[\sc Getting Section Number]
{Getting Section Number on \LaTeX \ Beamer Slides}

\begin{frame}
\titlepage
\end{frame}

\frame{{Table of Contents}
\tableofcontents
}

\section{Introduction}

\frame{\frametitle{Who is David Hilbert?} 

David Hilbert is a great Mathematician!

}

\section{Mathematics}

\frame{{How do you define Mathematics?}

Mathematics is a language of sciences. Moreover, $\cdots$

}

\section{Examples}

\frame{\frametitle{Some Examples}
  
This is the first example.

}

\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to get Section Number in each Section Slide on LaTeX Beamer?

Post by Stefan Kottwitz »

Hi CMP,

very good complete example!

Btw. I noticed that \sc may not work here:

Code: Select all

\title[\sc Getting Section Number]
{Getting Section Number on \LaTeX \ Beamer Slides}
On the one hand, it's an obsolete command, on the other hand, even \scshape or \textsc wouldn't work. I did not check why though, since it's currently not really on topic, only if one is curious.

Stefan
LaTeX.org admin
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

How to get Section Number in each Section Slide on LaTeX Beamer?

Post by rais »

IIRC, computer modern sans serif font doesn't ship with small caps.

Code: Select all

LaTeX Font Warning: Font shape `T1/cmss/m/sc' undefined
(Font)              using `T1/cmss/m/n' instead on input line 38.
(from the log file) appears to agree with my memory ;)

KR
Rainer
Post Reply