44

I have been using the Frankfurt theme in Beamer recently. It includes navigational section titles at the top of the slide and when subsections are included, it adds circles below section titles. Each circle represents a slide. The circle representing the active slide is filled and the circles representing the active subsection are shown in bold.

My question is:

  • Is it possible to include navigational circles in a Beamer presentation to represent each slide while having sections, but not subsections?

My motivation:

  • I think this would be useful to highlight to readers the number of slides per section and it would also be a useful navigational tool.
1
  • The Singapore theme (and perhaps others) have a compress option which does what you want. Mar 18, 2019 at 11:00

5 Answers 5

31

You don't need to declare a subsection, raising it's counter by \setcounter{subsection}{1} or \stepcounter{subsection} would be sufficient.

But as the section counter resets the subsection counter, I would do it in the preamble together with removing it from the reset:

\usepackage{remreset}% tiny package containing just the \@removefromreset command
\makeatletter
\@removefromreset{subsection}{section}
\makeatother
\setcounter{subsection}{1}

This way that counter will stay at the value 1 and the circles are shown without any \subsection.

A minimal working example demonstrating the solution:

\documentclass{beamer}
\usetheme{Frankfurt}
\usepackage{remreset}
\makeatletter
\@removefromreset{subsection}{section}
\makeatother
\setcounter{subsection}{1}
\begin{document}
\section{Test}
\frame{one}
\frame{two}
\frame{three}
\end{document}

Output:

alt text

If you uncomment the command \setcounter{subsection}{1} and compile twice, you could see the original problem of missing circles.

0
11

Since Beamer by default only displays dots for subsections, I found that it was easiest to put \AtBeginSection[]{\subsection{}} in the preamble:

\documentclass{beamer}
\useoutertheme{miniframes}
\AtBeginSection[]{\subsection{}}

I found this to work better than other answers that messed with counters and left me with output like this:

enter image description here

3
  • This worked like a charm for me with theme Darmstadt.
    – anjuta
    Oct 18, 2015 at 15:01
  • this is the easiest fix suggested. I only added the \AtBeginSection line also (no miniframes) +upvoted Jul 17, 2017 at 20:52
  • A stunning solution, especially when you have a Title page and the Outline page. Whilst the accepted solution also counts these two pages in the navigation dots, this solution does not.
    – AlessioX
    Oct 22, 2017 at 9:10
8

Really? I thought the circles would always be shown, even without declared subsections. That's what the example in the documentation appears to show, and it's the way I seem to remember that theme behaving when I used it in the past. (It was a while ago, perhaps I'm misremembering, and my LaTeX is broken so I can't test)

Anyway, as a quick fix, I suppose you could just declare one nameless subsection per section.

\section{Axxqzropy}
\subsection{}

Maybe define a command for it,

\newcommand*{\ssection}[1]{\section{#1}\subsection{}}

although this is admittedly a hack, not an ideal solution.

1
  • thanks, the subsection hack worked in terms of showing the circles. But it also had the side effect of removing the PDF sidebar navigation. Aug 20, 2010 at 12:44
8

Here's a solution that doesn't mess around with the subsection numbering, but just patches beamer so that "subsections numbered 0" show their slide entries. Frames immediately below \sections without \subsections get treated as subsection 0 and highlighted in a different group to any actual later \subsections. Therefore, subsections are not needed to get frames to show corresponding the navigation circles, but it doesn't prevent (or rather, obfuscate) subsection use.

Beamer's \slideentry has a test that checks if the current subsection number exceeds zero before it agrees to show the navigation circle; I have just patched that test by replacing it with something that's always true (but still in the if conditional form so it shouldn't break anything).

\usepackage{etoolbox}
\makeatletter
\patchcmd{\slideentry}{\ifnum#2>0}{\ifnum2>0}{}{\@error{unable to patch}}% replace the subsection number test with a test that always returns true
\makeatother

Note that it may also be necessary to do the same for \fakeslideentry (if using multiple parts?). If not using the compress option, it may also be necessary to \advance\beamer@ypos by1\relax before the \fi in the \ifbeamer@compress else clause. However, the above alone "works" in the following example:

\documentclass{beamer}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\slideentry}{\ifnum#2>0}{\ifnum2>0}{}{\@error{unable to patch}}% replace the subsection number test with a test that always returns true
\makeatother

\usetheme{Frankfurt}

% to illustrate the subsection numbering
\setbeamertemplate{subsection in toc}[subsections numbered]

\begin{document}
\frame{\tableofcontents}
\section{Test I}
\frame{one}
\frame{two}
\subsection{A}
\frame{three}
\frame{four}
\subsection{B}
\frame{five}
\section{Test II}
\frame{six}
\subsection{C}
\frame{seven}
\section{Test III}
\frame{eight}
\end{document}

(I realise that this may no longer be useful to the original poster, but it might help someone. This is what I wanted to do but found only this question and its original answers.)

1
3

I had the same question and cyberSingularity's answer worked for me. I filled it out so that it does work with the compact option, and also patched \fakeslideentry. The trickery with \ifhadanonsubsecn means that your various sections can be different: some can have subsections, some can lack them, and some can have some slides before their first subsection. Anyway maybe this will be useful to someone.

\RequirePackage{etoolbox}
\makeatletter

\pretocmd\sectionentry{%
  \let\ifhadanonsubsecn\@secondoftwo
}{}{\@error{unable to patch \string\sectionentry}{}}

\patchcmd\slideentry{%
  \ifnum#2>0%
}{%
  \ifnum2>0%
}{}{\@error{unable to patch \string\slideentry}{}}

\patchcmd\slideentry{%
  \beamer@xpos=#3\relax%
  \beamer@ypos=#2\relax%
}{%
  \ifnum#2=0\relax
  \let\ifhadanonsubsecn\@firstoftwo
  \fi
  \beamer@xpos=#3\relax
  \beamer@ypos=#2\relax
  \ifhadanonsubsecn{%
    \advance \beamer@ypos by1\relax
  }{}%
}{}{\@error{unable to patch \string#1}}%

\patchcmd\fakeslideentry{%
  \beamer@xpos=#3\relax%
  \beamer@ypos=#2\relax%
}{%
  \ifnum#2=0\relax
  \let\ifhadanonsubsecn\@firstoftwo
  \fi
  \beamer@xpos=#3\relax
  \beamer@ypos=#2\relax
  \ifhadanonsubsecn{%
    \advance \beamer@ypos by1\relax
  }{}%
}{}{\PackageError{patchbeamernav}{unable to patch \string#1}}%

\@addtoreset{subsectionslide}{section}
\makeatother

(Without the \@addtoreset at the end, when the first slide in a section is not in a subsection, it might get counted as, say, slide #3, and that would have the effect of moving the circle corresponding to that slide over to the right; gross.)

You must log in to answer this question.

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