迷你框架:仅在有子部分框时才显示

迷你框架:仅在有子部分框时才显示

在我的演示文稿中,只有一个部分有子部分。我使用IlMenau加载miniframes外部主题的主题。正如标题所示,我希望miniframes外部主题仅在当前部分中有子部分时才显示带有当前子部分标题的“子部分栏”。

我知道我可以将选项传递subsection=falseminiframes(从此解决方案),但它会隐藏所有子部分栏,这不是我需要的。有人知道如何仅隐藏没有子部分的部分的此栏吗?

以下是 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}

答案1

隐藏所有子部分编号为 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}

在此处输入图片描述


可以使用软件包隐藏每页子节的总数对应的子节行xcntperchap。与上述解决方案的区别在于节与其第一个子节之间的框架。在此解决方案中,子节行将显示在这种情况下。(需要两次编译)

\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}

相关内容