LaTeX forum ⇒ Presentations and PostersHow to get Section Number in each Section Slide on LaTeX Beamer? Topic is solved

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

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

Postby CMP » Wed Apr 14, 2021 4:04 pm

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!

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 10 times

Bartman
Posts: 185
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Wed Apr 14, 2021 5:00 pm

You can put \insertsectionnumber before the section title command.

CMP
Posts: 12
Joined: Thu Aug 22, 2019 8:33 pm

Postby CMP » Wed Apr 14, 2021 5:56 pm

That's exactly what I was looking for.

Thank you very much, Bartman!

Here is a complete example now.

\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: 9685
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Wed Apr 14, 2021 7:08 pm

Hi CMP,

very good complete example!

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

\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: 288
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Wed Apr 14, 2021 9:05 pm

IIRC, computer modern sans serif font doesn't ship with small caps.
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


Return to “Presentations and Posters”

Who is online

Users browsing this forum: No registered users and 1 guest