2

there is a way to set the height of the navigation bar for each section in Beamer? I'm using the Warsaw theme and the height of the navigation bar is controlled by the maximum number of subsections in all the presentation.

For example I have the first section (the introduction) with only two subsection (definition of a problem and purpose of the research), and the second section (Study cases) that has seven subsections (one for each major topic of a previous study case). The other sections have two or three subsections each.

As of now the navigation bar on the Introduction and on the other sections is controlled by the seven subsections, so I have a ton of empty space when I am on the introduction or in the discussion.

There is a way to set the height of the navigation bar according to the actual number of subsection in a section? A height of two row for the two subsection in the introduction; a height of seven row for the section of the study cases, a height of three row for discussion and a height of one row for the conclusion?

Thanks,

Drew

P.S. I found something only about sectioning with a redefinition of the part in beamer. But I don't want to hide from the section "area" of the navigation bar the other sections. I want the two section always visible (the conclusion is not indexed in the nav bar at the moment) but for each section the height based on their respective number of subsections.

edit: MWE

\documentclass[xcolor=dvipsnames, table]{beamer}

\beamertemplatenavigationsymbolsempty
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage[dvipsnames]{xcolor}
\usepackage[compatibility=false]{caption}
\usepackage{appendixnumberbeamer}

\title[title]{title}
\author[authors]{authors}
\date[date]{date}
\institute{institute}

\usetheme{Warsaw}
\setbeamerfont{title}{size=\Huge}

\begin{document}

\begin{frame}[plain]
\maketitle
\end{frame}

\begin{frame}[plain]\frametitle{Introduction}

\centering
{\large Introduction}

Some photos.

\end{frame}

\section{Problem}

\subsection{Definition of a Problem}

\begin{frame}\frametitle{Problem 1}
    text
\end{frame}

\begin{frame}\frametitle{Problem 2}
    text
\end{frame}

\subsection{Purpose of the project}

\begin{frame}\frametitle{Project}
text
\end{frame}

\section{Study cases}

\subsection{Study case 1}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 2}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 3}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 4}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 5}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 6}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 7}

\begin{frame}\frametitle{title}
text
\end{frame}

\section{Discussion}

\subsection{Results}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Future prospective}

\begin{frame}\frametitle{title}
text
\end{frame}


\section{}\label{sec:conclusion}

\begin{frame}[plain]\frametitle{Conclusion}
    text
\end{frame}

\appendix

\section*{Appendix i}

\begin{frame}\frametitle{Supplementary material i}
    text
\end{frame}

\section*{Appendix ii}

\begin{frame}\frametitle{Supplementary material ii}
    text
\end{frame}

\section*{Appendix iii}

\begin{frame}\frametitle{Supplementary material iii}
 text
\end{frame}

\end{document}
2
  • Can you please make a minimal working example (MWE)? Commented Jul 30, 2018 at 8:10
  • Added a MWE, basically I'd like to make the height of the navigaton bar dynamic. A height of two rows for the first section, seven rows for the second and two for the last one. As of now I have always seven rows (the maximum number of subsection) and a lot of empty space in the first and last sections.
    – DrewGecko
    Commented Jul 30, 2018 at 8:37

1 Answer 1

3

You could redefine the headline as the following:

\documentclass[xcolor=dvipsnames, table]{beamer}

\beamertemplatenavigationsymbolsempty
\usepackage[utf8]{inputenc}
\usepackage{multirow}
%\usepackage[dvipsnames]{xcolor}
\usepackage[compatibility=false]{caption}
\usepackage{appendixnumberbeamer}

\title[title]{title}
\author[authors]{authors}
\date[date]{date}
\institute{institute}

\usetheme{Warsaw}
\setbeamerfont{title}{size=\Huge}


\usepackage{totcount}
\newcounter{totalsection}
\regtotcounter{totalsection}

\AtBeginDocument{%
  \pretocmd{\section}{\refstepcounter{totalsection}}{}{}%
}%

% number of subsections per section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}
\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}




\newcounter{currentsub}
\setcounter{currentsub}{0}
\newcounter{totsection}
\AtBeginSection[]{%
    \setcounter{currentsub}{\ObtainTrackedValueExp[\thesection]{section}{subsection}}
    \recalc
}

\makeatletter
\setbeamertemplate{headline}{%
  \leavevmode%
  \@tempdimb=2.4375ex%
  \ifnum\thecurrentsub<\beamer@sectionmax%
    \multiply\@tempdimb by\beamer@sectionmax%
  \else%
    \multiply\@tempdimb by\thecurrentsub%
  \fi%
  \ifdim\@tempdimb>0pt%
    \advance\@tempdimb by 1.825ex%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{section in head/foot}%
      \vbox to\@tempdimb{\vfil\insertsectionnavigation{.5\paperwidth}\vfil}%
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
      \vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.5\paperwidth}\vfil}%
    \end{beamercolorbox}%
  \fi%
}

\newcommand{\recalc}{\beamer@calculateheadfoot}
\makeatother


\begin{document}

\begin{frame}[plain]
\maketitle
\end{frame}

\begin{frame}[plain]\frametitle{Introduction}

\centering
{\large Introduction}

Some photos.

\end{frame}

\section{Problem}

\subsection{Definition of a Problem}

\begin{frame}\frametitle{Problem 1}
    text
\end{frame}

\begin{frame}\frametitle{Problem 2}
    text
\end{frame}

\subsection{Purpose of the project}

\begin{frame}\frametitle{Project}
text
\end{frame}

\section{Study cases}

\subsection{Study case 1}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 2}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 3}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 4}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 5}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 6}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Study case 7}

\begin{frame}\frametitle{title}
text
\end{frame}

\section{Discussion}

\subsection{Results}

\begin{frame}\frametitle{title}
text
\end{frame}

\subsection{Future prospective}

\begin{frame}\frametitle{title}
text
\end{frame}


\section{}\label{sec:conclusion}

\begin{frame}[plain]\frametitle{Conclusion}
    text
\end{frame}

\appendix

\section*{Appendix i}

\begin{frame}\frametitle{Supplementary material i}
    text
\end{frame}

\section*{Appendix ii}

\begin{frame}\frametitle{Supplementary material ii}
    text
\end{frame}

\section*{Appendix iii}

\begin{frame}\frametitle{Supplementary material iii}
 text
\end{frame}

\end{document}

enter image description here

3
  • Thanks, this is just what I was searching! The two paramaters 2.4375ex and 1.825ex control the empty space before and after the first and last subsection?
    – DrewGecko
    Commented Jul 30, 2018 at 12:34
  • 1
    @DrewEugene17 You're welcome! Commented Jul 30, 2018 at 12:34
  • 1
    @DrewEugene17 I somehow missed the second part of your comment, sorry! 2.4375ex stands for the height of a single line. 1.825ex adds additional space above and below (the text will be vertically centred) Commented Jul 30, 2018 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .