이것가이드현재 섹션이 강조표시되는 동적 헤더를 생성하는 방법을 설명합니다.
그런데 강조표시에 사용되는 색상을 어떻게 제어할 수 있나요? (공간을 절약하기 위해 헤더의 글꼴 크기를 작은 값으로 설정했기 때문에 우리가 강연의 어느 섹션에 있는지 더 명확하게 하기 위해 약간의 대비를 추가하고 싶습니다).
답변1
귀하의 질문을 올바르게 이해했다면 가능한 해결책은 다음과 같습니다. 일반 ToC와 각 섹션 시작 부분에 생성된 ToC의 섹션 제목 주위에 색상 프레임을 추가했습니다.
\documentclass{beamer}
\usepackage{tikz}
\usetheme{Malmoe}
\newcommand\sectioncolor{white}
\newcommand\SectionBox[1]{%
\tikz\node[rectangle,fill=\sectioncolor,rounded corners] {#1};
}
\AtBeginSection{%
\setbeamercolor{section in toc}{fg=black,bg=\sectioncolor}
\begin{frame}<beamer>
\frametitle{Outline \thesection}
\tableofcontents[currentsection,subsectionstyle=show/show/shaded]
\end{frame}
}
\setbeamertemplate{section in toc shaded}[default][7]
\makeatletter
\long\def\beamer@section[#1]#2{%
\beamer@savemode%
\mode<all>%
\ifbeamer@inlecture
\refstepcounter{section}%
\renewcommand\sectioncolor{%
\ifcase\value{section}\or blue!20\or green!80!black\or red!80!black!50\or yellow!30!black!50\else orange!30!black!50\fi}
\beamer@ifempty{#2}%
{\long\def\secname{#1}\long\def\lastsection{#1}}%
{\global\advance\beamer@tocsectionnumber by 1\relax%
\long\def\secname{#2}%
\long\def\lastsection{#1}%
\addtocontents{toc}{\protect\beamer@sectionintoc{\the\c@section}%
{\protect\tikz\protect\node[rectangle,fill=\sectioncolor,rounded corners] {#2};}%
{\the\c@page}{\the\c@part}%
{\the\beamer@tocsectionnumber}}}%
{\let\\=\relax\xdef\sectionlink{{Navigation\the\c@page}{\noexpand\secname}}}%
\beamer@tempcount=\c@page\advance\beamer@tempcount by -1%
\beamer@ifempty{#1}{}{%
\addtocontents{nav}{\protect\headcommand{\protect\sectionentry{\the\c@section}{#1}{\the\c@page}{\secname}{\the\c@part}}}%
\addtocontents{nav}{\protect\headcommand{\protect\beamer@sectionpages{\the\beamer@sectionstartpage}{\the\beamer@tempcount}}}%
\addtocontents{nav}{\protect\headcommand{\protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\the\beamer@tempcount}}}%
}%
\beamer@sectionstartpage=\c@page%
\beamer@subsectionstartpage=\c@page%
\def\insertsection{\expandafter\hyperlink\sectionlink}%
\def\insertsubsection{}%
\def\insertsubsubsection{}%
\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}%
\def\insertsubsectionhead{}%
\def\insertsubsubsectionhead{}%
\def\lastsubsection{}%
\Hy@writebookmark{\the\c@section}{\secname}{Outline\the\c@part.\the\c@section}{2}{toc}%
\hyper@anchorstart{Outline\the\c@part.\the\c@section}\hyper@anchorend%
\beamer@ifempty{#2}{\beamer@atbeginsections}{\beamer@atbeginsection}%
\fi%
\beamer@resumemode}%
\makeatother
\begin{document}
\begin{frame}
\frametitle{General Outline}
\tableofcontents
\end{frame}
\section{Test Section One}
\subsection{Test Subsection One One}
\begin{frame}test one\end{frame}
\subsection{Test Subsection One Two}
\begin{frame}test one\end{frame}
\section{Test Section Two}
\subsection{Test Subsection Two One}
\begin{frame}test one\end{frame}
\subsection{Test Subsection Two Two}
\begin{frame}test one\end{frame}
\subsection{Test Subsection Two Three}
\begin{frame}test one\end{frame}
\section{Test Section Three}
\subsection{Test Subsection Three One}
\begin{frame}test one\end{frame}
\subsection{Test Subsection Three Two}
\begin{frame}test one\end{frame}
\end{document}
일반 ToC:
섹션 시작 부분에 있는 두 개의 ToC:
처음에 생각했던 것처럼 ToC가 아닌 탐색 모음의 섹션에 수정이 필요하므로 해결 방법이 훨씬 쉽습니다. 필요한 것은 템플릿 section in head/foot
(현재 섹션의 경우)과 section in head/foot shaded
(다른 섹션의 경우) 템플릿을 재정의하는 것뿐입니다. 현재). 다음 예에서는 현재 섹션에 색상 프레임을 사용했지만 원하는 다른 스타일을 사용할 수 있습니다.
\documentclass{beamer}
\usepackage{tikz}
\usetheme{Singapore}
\definecolor{SectionBox}{RGB}{60,160,0}
\setbeamertemplate{section in head/foot}{\hfill\protect\tikz\protect\node[rectangle,fill=SectionBox!90,rounded corners=1pt,inner sep=1pt,] {\textcolor{white}{\insertsectionhead}};}
\setbeamertemplate{section in head/foot shaded}{\textcolor{structure!40}{\hfill\insertsectionhead}}
\begin{document}
\section{Test Section One}
\subsection{Test Subsection One One}
\begin{frame}test section one\end{frame}
\subsection{Test Subsection One Two}
\begin{frame}test section one\end{frame}
\section{Test Section Two}
\subsection{Test Subsection Two One}
\begin{frame}test section two\end{frame}
\subsection{Test Subsection Two Two}
\begin{frame}test section two\end{frame}
\subsection{Test Subsection Two Three}
\begin{frame}test section two\end{frame}
\section{Test Section Three}
\subsection{Test Subsection Three One}
\begin{frame}test section three\end{frame}
\subsection{Test Subsection Three Two}
\begin{frame}test section three\end{frame}
\end{document}
일부 헤드라인의 일부 이미지: