0

In my presentation, only one section has subsections. I use the IlMenau theme which loads the miniframes outer theme. As the title suggests, I would like the miniframes outer theme to show the "subsection bar" with the current subsection title only when there are subsections in the current section.

I know I can pass the option subsection=false to miniframes (from this solution) but it hides the subsection bar everywhere, which is not what I need. Does anyone knows how to hide this bar only for sections with no subsection ?

Here is a MWE:

\PassOptionsToPackage{subsection=false}{beamerouterthememiniframes} % doesnt work as I need
\documentclass{beamer} 
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usetheme{Ilmenau}

\begin{document}

\section{Section 1}
\begin{frame}

\end{frame}

\section{Section 2}
\subsection{Subsection 2.1}
\begin{frame}

\end{frame}

\subsection{Subsection 2.2}
\begin{frame}

\end{frame}
\end{document}
0

Would it be sufficient to hide the subsection bar for all slides with subsection number = 0?

\documentclass{beamer} 
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usetheme{Ilmenau}

\makeatletter
\setbeamertemplate{headline}{%
    \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
    \end{beamercolorbox}
    \begin{beamercolorbox}{section in head/foot}
        \vskip2pt\insertnavigation{\paperwidth}\vskip2pt
    \end{beamercolorbox}%
    \ifnum\value{subsection}>0%
%   \ifbeamer@theme@subsection%
    \begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
    \end{beamercolorbox}
    \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
        leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
        \usebeamerfont{subsection in head/foot}\insertsubsectionhead
    \end{beamercolorbox}%
    \fi%
    \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
    \end{beamercolorbox}
}


\setbeamertemplate{frametitle}
{
    \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
    \@tempdima=\textwidth%
    \advance\@tempdima by\beamer@leftmargin%
    \advance\@tempdima by\beamer@rightmargin%
    \ifnum\thesubsection>0%
        \vskip1.5ex%
    \fi%
    \begin{beamercolorbox}[sep=0.3cm,left,wd=\the\@tempdima]{frametitle}
        \usebeamerfont{frametitle}%
        \vbox{}\vskip-1ex%
        \if@tempswa\else\csname beamer@fteleft\endcsname\fi%
        \strut\insertframetitle\strut\par%
        {%
            \ifx\insertframesubtitle\@empty%
            \else%
            {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
            \fi
        }%
        \vskip-1ex%
        \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
    \end{beamercolorbox}%
}

\makeatother

\begin{document}

\section{Section 1}
\begin{frame}

\end{frame}

\begin{frame}
    \frametitle{d}
\end{frame}


\section{Section 2}
\subsection{Subsection 2.1}
\begin{frame}
    \frametitle{d}

\end{frame}

\subsection{Subsection 2.2}
\begin{frame}

\end{frame}
\end{document}

enter image description here


To hide the subsection line depending on the total number of subsections per page can be done with the package xcntperchap. The difference to the above solution is for frames between the section and its first subsection. In this solutions, the subsection line will be displayed in that case. (requires two compilations)

\documentclass{beamer} 
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usetheme{Ilmenau}

\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}

\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}
\usepackage{etoolbox}

\preto\frame{\setcounter{totalsubsection}{\ObtainTrackedValueExp[\value{section}]{section}{subsection}}}


\makeatletter
\setbeamertemplate{headline}{%
    \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
    \end{beamercolorbox}
    \begin{beamercolorbox}{section in head/foot}
        \vskip2pt\insertnavigation{\paperwidth}\vskip2pt
    \end{beamercolorbox}%
    \ifnum\value{totalsubsection}>0%
    %   \ifbeamer@theme@subsection%
    \begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
    \end{beamercolorbox}
    \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
        leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
        \usebeamerfont{subsection in head/foot}\insertsubsectionhead
    \end{beamercolorbox}%
    \fi%
    \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
    \end{beamercolorbox}
}
\makeatother

\begin{document}

    \section{Section 1}
    \begin{frame}

    \end{frame}

    \begin{frame}

    \end{frame}


    \section{Section 2}

    \frame{}

    \subsection{Subsection 2.1}
    \begin{frame}

    \end{frame}

    \subsection{Subsection 2.2}
    \begin{frame}

    \end{frame}
\end{document}
  • Thank you for your help ! It works but unfortunately when I add a 'frametitle' on the slide with a "subsection bar", the subsection bar is hidden by the title. Do you know how to solve this ? – snickers Jun 23 '16 at 9:38
  • @snickers Can you try the edited code? – user36296 Jun 23 '16 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.