Beamer 的頭條新聞

Beamer 的頭條新聞

我正在以 Beamer 的華沙主題進行演示,標題結構如下:

\setbeamertemplate{headline}{%
\leavevmode%
  \hbox{%
    \begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex]{palette quaternary}%
    \insertsectionnavigationhorizontal{\paperwidth}{}{\hskip0pt plus1filll}
    \end{beamercolorbox}%
  }
}

如何僅顯示三個部分,或者像這樣,前一個-當前-後部分,並突出顯示當前部分?由於我有大量的部分~10,所有這些部分都無法顯示在標題中。請建議。

答案1

\documentclass{beamer}

\usetheme{Warsaw}

\AtBeginSection[]{\label{sec:\thesection}}

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

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

\newcounter{start}
\newcounter{stop}

\usepackage{pgffor}

\setbeamercolor{section in head/foot}{fg=white}
\setbeamercolor{section in head/foot shaded}{fg=white!60!bg}

\setbeamertemplate{headline}{%
\leavevmode%
  \hbox{%
    \begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex]{palette quaternary}%
        \ifnum\value{section}>0%
            \quad
            \setcounter{start}{\value{section}}
                \setcounter{stop}{\value{section}}
                \ifnum\value{section}>1
                    \addtocounter{start}{-1}
                \fi
                \ifnum\value{section}<\totvalue{totalsection}
                    \addtocounter{stop}{1}
                \fi     
                \foreach \i in {\thestart,...,\thestop}{%
                    \ifnum\i=\value{section}
                        \usebeamercolor[fg]{section in head/foot}
                    \else   
                        \usebeamercolor[fg]{section in head/foot shaded}
                    \fi
                    \hfill\hyperlink{sec:\i}{\nameref{sec:\i}}
                }
                \hfill\quad
            \fi
    \end{beamercolorbox}%
  }
}



\begin{document}

\section{test1}\begin{frame}abc\end{frame}  
\section{test2}\begin{frame}abc\end{frame}  
\section{test3}\begin{frame}abc\end{frame}  
\section{test4}\begin{frame}abc\end{frame}  
\section{test5}\begin{frame}abc\end{frame}  
\section{test6}\begin{frame}abc\end{frame}  
\section{test7}\begin{frame}abc\end{frame}  
\section{test8}\begin{frame}abc\end{frame}  
\section{test9}\begin{frame}abc\end{frame}  
\section{test10}\begin{frame}abc\end{frame} 
\section{test11}\begin{frame}abc\end{frame}     

\end{document}

在此輸入影像描述

相關內容