나는 다음과 같은 헤드라인 구조를 가진 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}