[Tex/LaTex] Add a section to beamer table of contents but not to navigation bar

beamermini-framestable of contents

This question has been asked before, but for a different beamer theme. The answer there did not make it clear to me how to deal with my case, illustrated in this example (which I think is close to minimal):

\documentclass[compress]{beamer}
\usetheme{Singapore}
    \setbeamercolor{section in head/foot}{bg=white}
    \useoutertheme{miniframes}  
    % ^ dots up top
    \setbeamertemplate{navigation symbols}{}
    % ^ disable annoying footer
\newcommand{\mytoc}{
    \tableofcontents[ 
        currentsubsection, 
        hideothersubsections, 
        subsectionstyle=show/shaded/hide,
        ]} 
    \newcommand{\mytocslide}{
    \begin{frame}
        \mytoc
    \end{frame}}
\begin{document}
\section{Introduction}\subsection{}
\begin{frame}{hiya}
    yo
\end{frame}
\mytocslide
\section{Second section}\subsection{}
\begin{frame}
    yoyo
\end{frame}
\addcontentsline{toc}{section}{Section not in top nav}
\begin{frame}
    yoyoyo
\end{frame}
\end{document}

The resulting document includes the extra section in the TOC but not the nav bar (as desired), but it looks weird in the TOC.

Best Answer

To achieve the same formatting as a regular section entry, you need some additional work: section entries in the ToC have a vertical extra spacing of 1.5em and they have a special color, so you need to say something like:

\addtocontents{toc}{\vskip1.5em}
\addcontentsline{toc}{section}{\protect\usebeamercolor[fg]{structure} text}

A complete example:

\documentclass[compress]{beamer}
\usetheme{Singapore}
    \setbeamercolor{section in head/foot}{bg=white}
    \useoutertheme{miniframes}  
    \setbeamertemplate{navigation symbols}{}
\newcommand{\mytoc}{
    \tableofcontents[ 
        currentsubsection, 
        hideothersubsections, 
        subsectionstyle=show/shaded/hide,
        ]} 
\newcommand{\mytocslide}{
    \begin{frame}
        \mytoc
    \end{frame}}

\begin{document}
\section{Introduction}
\subsection{}
\begin{frame}{hiya}
    yo
\end{frame}
\mytocslide

\section{Second section}
\subsection{}
\begin{frame}
    yoyo
\end{frame}

\addtocontents{toc}{\vskip1.5em}
\addcontentsline{toc}{section}{\protect\usebeamercolor[fg]{structure} Section in ToC but not in the navigation bar}

\begin{frame}
    yoyoyo
\end{frame}

\end{document}

An image of the resulting ToC, showing the new additional entry, not present in the navigation bar:

enter image description here

A more robust solution (that doesn't require manual intervention and that will even give you an hyperlink) can be achieved by defining a new command using the exact way in which sections are included in the ToC (the relevant definition can be found in the file beamerbasesection.sty):

\documentclass[compress]{beamer}
\usetheme{Singapore}
    \setbeamercolor{section in head/foot}{bg=white}
    \useoutertheme{miniframes}  
    \setbeamertemplate{navigation symbols}{}
\newcommand{\mytoc}{
    \tableofcontents[ 
        currentsubsection, 
        hideothersubsections, 
        subsectionstyle=show/shaded/hide,
        ]} 
\newcommand{\mytocslide}{
    \begin{frame}
        \mytoc
    \end{frame}}

\makeatletter
\newcommand\addsectiontotoc[1]{%
\addtocontents{toc}{%
  \protect\beamer@sectionintoc{\the\c@section}{#1}{\the\c@page}{\the\c@part}%
    {\the\beamer@tocsectionnumber}}
}
\makeatother

\begin{document}

\section{Introduction}
\subsection{}
\begin{frame}{hiya}
    yo
\end{frame}
\mytocslide

\section{Second section}
\subsection{}
\begin{frame}
    yoyo
\end{frame}

\addsectiontotoc{Section in ToC but not in the navigation bar}

\begin{frame}
    yoyoyo
\end{frame}
\end{document}