LaTeX forum ⇒ Presentations and Postershow to numerate subsection/ subsubsection beamer

Beamer, Powerdot and KOMA-Script presentations, Conference posters (a0poster, baposter, tikzposter)
caheo1294
Posts: 7
Joined: Wed Aug 18, 2021 2:10 am

how to numerate subsection/ subsubsection beamer

Postby caheo1294 » Thu Aug 19, 2021 12:06 pm

Hi, does anyone know how to add the subsection and subsection numbers into each slide using Beamer? I am looking for something like "1.1 Subsection 1.1" in each slide that belongs to Section 1.1. Thank you!!!

\documentclass[compress,12pt]{beamer}
\usepackage{amsmath,amssymb}
\usecolortheme[RGB={0,0,205}]{structure}
\usepackage{color, colortbl, graphics, graphicx}
\usepackage{pgfarrows,pgfnodes}
\usepackage{url}
\usepackage{textcomp}
\usepackage[vcentermath]{youngtab}
\usepackage{pgf}
\usepackage{bbm}
\usepackage[flushleft]{threeparttable}
\usepackage{xcolor}
\usepackage{color}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{rotating}
\usepackage{geometry}
\usepackage{lscape}
\usepackage{subfig}
\usepackage{tikz}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{ragged2e} \usepackage[authoryear]{natbib}
\hypersetup{
	colorlinks,%
	citecolor=blue,%
	filecolor=red,%
	linkcolor=black,%
	urlcolor=black
} 
\renewcommand<>{\hl}[1]{\only#2{\beameroriginal{\hl}}{#1}}
\newcommand{\hilight}[1]{\colorbox{yellow}{#1}}
\newtheorem{conjecture}{Conjecture}[section]
\newtheorem{remark}{Remark}[section]
\newtheorem{findings}{Findings}[section]
\newtheorem{methodology}{Methodology}[section]
\newtheorem{simulation}{Simulation design}[section]
\newtheorem{puzzles}{Puzzles}[section]



\def\onepc{$^{\ast\ast}$}
\def\fivepc{$^{\ast}$}
\definecolor{LRed}{rgb}{1,.8,.8}
\definecolor{MRed}{rgb}{1,.6,.6}
\definecolor{HRed}{rgb}{1,.2,.2}

\newtheorem{Assumption}{Assumption}
\newtheorem{assumption}{Assumption}
\newtheorem{Condition}{Condition}
\newtheorem{condition}{condition}
\newtheorem{Proposition}{Proposition}
\newtheorem{proposition}{Proposition}
\usetheme{CambridgeUS}

\newcounter{saveenumi}
\newcommand{\seti}{\setcounter{saveenumi}{\value{enumi}}}
\newcommand{\conti}{\setcounter{enumi}{\value{saveenumi}}}
\resetcounteronoverlays{saveenumi}

%\setbeamercovered{transparent=25}
\setbeamercolor{author in head/foot}{fg=blue!50!black,bg=white}
\setbeamercolor{date in head/foot}{fg=blue!50!black,bg=white}
\setbeamercolor{section in head/foot}{fg=blue!50!black, bg=white}
\setbeamercolor{item}{fg=blue!50!black}
\setbeamercolor{title}{fg=blue!50!black}
\setbeamercolor{frametitle}{fg=blue!50!black}
\setbeamercolor{author}{fg=blue!50!black}
\setbeamercolor{institute}{fg=blue!50!black}
\setbeamercolor{date}{fg=blue!50!black}
\setbeamercolor{block title example}{fg=blue!50!black}
\setbeamercolor{block title}{fg=blue!50!black}
\setbeamertemplate{itemize items}[ball]
\setbeamertemplate{itemize subitems}[ball]
\setbeamertemplate{itemize subsubitems}[ball]
\setbeamertemplate{section in head/foot shaded}[default][30]
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{bibliography item}[triangle]
\setbeamertemplate{headline}{
	\vskip1pt
	\begin{beamercolorbox}[ht=2.25ex,dp=1ex]{author in head/foot}
		\usebeamerfont{titlelike}\insertsectionnavigationhorizontal{1\paperwidth}{}{}
	\end{beamercolorbox}
}
\setbeamertemplate{footline}
{
	\hbox{  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex]{date in head/foot}    \usebeamerfont{titlelike}\hspace*{2ex}\hspace{1ex}
		\end{beamercolorbox}  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}    \usebeamerfont{date in head/foot}
			\insertshorttitle\hspace*{2ex}
	\end{beamercolorbox}}
	\vskip0pt
}
\newcommand{\bitb}[1]{\begin{exampleblock}{#1}\begin{itemize}}
		\newcommand{\eitb}{\end{itemize}\end{exampleblock}}
% \yen : yen mark (taken from ascmac.sty for jlatex)
\def\yen{{\setbox0=\hbox{Y}Y\kern-.97\wd0\vbox{\hrule height.1ex
			width.98\wd0\kern.33ex\hrule height.1ex width.98\wd0\kern.45ex}}}

\begin{document}
	\begin{frame}{Outline}
		\justifying 
		\tableofcontents
		\vfill
	\end{frame}
	
	\section{Section One}
	\begin{frame}{Section 1}
	This is an example 1. 
	\end{frame}
	\subsection{Sub sec 1}
	\begin{frame}{Subsection 1.2}
	This is an example 2. 
	\end{frame}
	\subsubsection{sub sub sec 1}
	this is an example


\end{document}

User avatar
Ijon Tichy
Posts: 565
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Thu Aug 19, 2021 6:09 pm

I'm not sure, that I understand your question. But beamer has `\insertsectionnumber` and `\insertsection` to print the current section number and section title. So you could use, e.g.:
\documentclass[compress,12pt]{beamer}
\usepackage{amsmath,amssymb}
\usecolortheme[RGB={0,0,205}]{structure}
\usepackage{color, colortbl, graphics, graphicx}% color, graphics, graphicx does not make sense
\usepackage{pgfarrows,pgfnodes}
\usepackage{url}% does not make sense
\usepackage{textcomp}
\usepackage[vcentermath]{youngtab}
\usepackage{pgf}% does not make sense
\usepackage{bbm}
\usepackage[flushleft]{threeparttable}
\usepackage{xcolor}% does not make sense
\usepackage{color}% does not make sense
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{rotating}
\usepackage{geometry}% does not make sense
\usepackage{lscape}
\usepackage{subfig}
\usepackage{tikz}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{ragged2e} \usepackage[authoryear]{natbib}
\hypersetup{
	colorlinks,%
	citecolor=blue,%
	filecolor=red,%
	linkcolor=black,%
	urlcolor=black
} 
\renewcommand<>{\hl}[1]{\only#2{\beameroriginal{\hl}}{#1}}
\newcommand{\hilight}[1]{\colorbox{yellow}{#1}}
\newtheorem{conjecture}{Conjecture}[section]
\newtheorem{remark}{Remark}[section]
\newtheorem{findings}{Findings}[section]
\newtheorem{methodology}{Methodology}[section]
\newtheorem{simulation}{Simulation design}[section]
\newtheorem{puzzles}{Puzzles}[section]



\def\onepc{$^{\ast\ast}$}
\def\fivepc{$^{\ast}$}
\definecolor{LRed}{rgb}{1,.8,.8}
\definecolor{MRed}{rgb}{1,.6,.6}
\definecolor{HRed}{rgb}{1,.2,.2}

\newtheorem{Assumption}{Assumption}
\newtheorem{assumption}{Assumption}
\newtheorem{Condition}{Condition}
\newtheorem{condition}{condition}
\newtheorem{Proposition}{Proposition}
\newtheorem{proposition}{Proposition}
\usetheme{CambridgeUS}

\newcounter{saveenumi}
\newcommand{\seti}{\setcounter{saveenumi}{\value{enumi}}}
\newcommand{\conti}{\setcounter{enumi}{\value{saveenumi}}}
\resetcounteronoverlays{saveenumi}

%\setbeamercovered{transparent=25}
\setbeamercolor{author in head/foot}{fg=blue!50!black,bg=white}
\setbeamercolor{date in head/foot}{fg=blue!50!black,bg=white}
\setbeamercolor{section in head/foot}{fg=blue!50!black, bg=white}
\setbeamercolor{item}{fg=blue!50!black}
\setbeamercolor{title}{fg=blue!50!black}
\setbeamercolor{frametitle}{fg=blue!50!black}
\setbeamercolor{author}{fg=blue!50!black}
\setbeamercolor{institute}{fg=blue!50!black}
\setbeamercolor{date}{fg=blue!50!black}
\setbeamercolor{block title example}{fg=blue!50!black}
\setbeamercolor{block title}{fg=blue!50!black}
\setbeamertemplate{itemize items}[ball]
\setbeamertemplate{itemize subitems}[ball]
\setbeamertemplate{itemize subsubitems}[ball]
\setbeamertemplate{section in head/foot shaded}[default][30]
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{bibliography item}[triangle]
\setbeamertemplate{headline}{
	\vskip1pt
	\begin{beamercolorbox}[ht=2.25ex,dp=1ex]{author in head/foot}
		\usebeamerfont{titlelike}\insertsectionnavigationhorizontal{1\paperwidth}{}{}
	\end{beamercolorbox}
}
\setbeamertemplate{footline}
{
	\hbox{  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex]{date in head/foot}    \usebeamerfont{titlelike}\hspace*{2ex}\hspace{1ex}
		\end{beamercolorbox}  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}    \usebeamerfont{date in head/foot}
			\insertshorttitle\hspace*{2ex}
	\end{beamercolorbox}}
	\vskip0pt
}
\newcommand{\bitb}[1]{\begin{exampleblock}{#1}\begin{itemize}}
		\newcommand{\eitb}{\end{itemize}\end{exampleblock}}
% \yen : yen mark (taken from ascmac.sty for jlatex)
\def\yen{{\setbox0=\hbox{Y}Y\kern-.97\wd0\vbox{\hrule height.1ex
			width.98\wd0\kern.33ex\hrule height.1ex width.98\wd0\kern.45ex}}}

\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]

\begin{document}
	\begin{frame}{Outline}
		\justifying 
		\tableofcontents
		\vfill
	\end{frame}
	
	\section{Section One}
	\begin{frame}{\insertsectionnumber{} \insertsection}
	This is an example 1. 
	\end{frame}
	\subsection{Sub sec 1}
	\begin{frame}{\insertsectionnumber.\insertsubsectionnumber{} \insertsubsection}
	This is an example 2. 
	\end{frame}
	\subsubsection{sub sub sec 1}
	this is an example


\end{document}

And please try to make more minimal examples. You are loading several packages, that are already loaded by beamer. Some packages you are loading more than once, which is almost never a good idea.


Return to “Presentations and Posters”

Who is online

Users browsing this forum: No registered users and 2 guests