我正在开发以下风格:
\documentclass{beamer}
\let\Tiny=\tiny
\title{Title}
\author{Ricardo Cruz}
\date{}
\usepackage{tikz}
%% SIDEBAR
\newlength\swidth
\setlength\swidth{1.2cm}
\newlength\theight
\setlength\theight{1.0cm}
\makeatletter
\newlength\beamerleftmargin
\setlength\beamerleftmargin{\Gm@lmargin}
\makeatother
\newlength\sheight
\setbeamersize{sidebar width right=\swidth}
\setbeamerfont{sidebar right}{size=\normalsize}
\setbeamertemplate{sidebar right}{%
\setlength\sheight{\dimexpr(\paperheight-\theight)/(\inserttotalframenumber-1) \relax}
\vspace{\theight}
\begin{tikzpicture}[y=\sheight]
\foreach \i in {2,...,\inserttotalframenumber} {
\def\pgnbr{\inserttotalframenumber - \i-1}
\ifnum\i=\insertframenumber
\filldraw[very thick] (0,\pgnbr) rectangle (\swidth,\pgnbr+1);
\node[white,anchor=mid,font=\bfseries] at (\swidth/2,\pgnbr+0.5) {\number\numexpr\i-1};
\else
\draw[very thick] (0,\pgnbr) rectangle (\swidth-0.07cm,\pgnbr+1);
\node[anchor=mid,font=\bfseries] at (\swidth/2,\pgnbr+0.5) {\number\numexpr\i-1};
\fi
}
\end{tikzpicture}
}
%% TITLE
\setbeamercolor{frametitle}{fg=black}
\setbeamerfont{frametitle}{size=\Large\bfseries}
\setbeamertemplate{frametitle}{%
\begin{tikzpicture}
\hspace{-\beamerleftmargin}
\draw[very thick] (0,0) rectangle (\paperwidth-0.08cm,\theight-0.05cm);
\node[anchor=mid] at (\paperwidth/2,\theight/2) {\insertframetitle};
\end{tikzpicture}
}
%%
\begin{document}
{
\setbeamertemplate{sidebar right}{}
\begin{frame}
\titlepage
\end{frame}
}
\begin{frame}{First}
First
\end{frame}
\begin{frame}{Second}
Second
\end{frame}
\begin{frame}{Third}
Third
\end{frame}
\end{document}
我对此非常满意。(我们的想法是制作多张幻灯片,这样侧边栏的数字看起来就不会太大。)
但是现在,我不知道如何使侧边栏数字可点击以转到其各自的框架。
我知道我可以在每个框架内放置\label{frame1}
、\label{frame2}
等,然后使用\hyperlink{frame1}{1}
、\hyperlink{frame2}{2}
等,但我希望它是动态的。我如何定义动态标签,例如\label{frame\insertframenumber}
并将它们超链接起来?
- 更新*
实际上,动态标签似乎在 Latex 上工作得很好(抱歉,我没有尝试!)。但是,如何才能自动为每个帧定义一个标签,而不必像下面的代码那样手动插入它们?
我尝试将它们放入里面,\setbeamertemplate{frametitle}{...}
但没有用……
\documentclass{beamer}
\let\Tiny=\tiny
\title{Title}
\author{Ricardo Cruz}
\date{}
\usepackage{tikz}
%% SIDEBAR
\newlength\swidth
\setlength\swidth{1.2cm}
\newlength\theight
\setlength\theight{1.0cm}
\makeatletter
\newlength\beamerleftmargin
\setlength\beamerleftmargin{\Gm@lmargin}
\makeatother
\newlength\sheight
\setbeamersize{sidebar width right=\swidth}
\setbeamerfont{sidebar right}{size=\normalsize}
\setbeamertemplate{sidebar right}{%
\setlength\sheight{\dimexpr(\paperheight-\theight)/(\inserttotalframenumber-1) \relax}
\vspace{\theight}
\begin{tikzpicture}[y=\sheight]
\foreach \i in {2,...,\inserttotalframenumber} {
\def\pgnbr{\inserttotalframenumber - \i-1}
\ifnum\i=\insertframenumber
\filldraw[very thick] (0,\pgnbr) rectangle (\swidth,\pgnbr+1);
\node[white,anchor=mid,font=\bfseries] at (\swidth/2,\pgnbr+0.5) {\hyperlink{frame\i}{\number\numexpr\i-1}};
\else
\draw[very thick] (0,\pgnbr) rectangle (\swidth-0.07cm,\pgnbr+1);
\node[anchor=mid,font=\bfseries] at (\swidth/2,\pgnbr+0.5) {\hyperlink{frame\i}{\number\numexpr\i-1}};
\fi
}
\end{tikzpicture}
}
%% TITLE
\setbeamercolor{frametitle}{fg=black}
\setbeamerfont{frametitle}{size=\Large\bfseries}
\setbeamertemplate{frametitle}{%
\begin{tikzpicture}
\hspace{-\beamerleftmargin}
\draw[very thick] (0,0) rectangle (\paperwidth-0.08cm,\theight-0.05cm);
\node[anchor=mid] at (\paperwidth/2,\theight/2) {\insertframetitle};
\end{tikzpicture}
}
%%
\begin{document}
{
\setbeamertemplate{sidebar right}{}
\begin{frame}
\titlepage
\end{frame}
}
\begin{frame}{First}
\label{frame1}
First
\end{frame}
\begin{frame}{Second}
\label{frame2}
Second
\end{frame}
\begin{frame}{Third}
\label{frame3}
Third
\end{frame}
\end{document}
答案1
通过使用\rule
节点内部,可以单击矩形内的任意位置。
\documentclass{beamer}
\let\Tiny=\tiny
\title{Title}
\author{Ricardo Cruz}
\date{}
\usepackage{tikz}
%% SIDEBAR
\newlength\swidth
\setlength\swidth{1.2cm}
\newlength\theight
\setlength\theight{1.0cm}
\makeatletter
\newlength\beamerleftmargin
\setlength\beamerleftmargin{\Gm@lmargin}
\makeatother
\newlength\sheight
\setbeamersize{sidebar width right=\swidth}
\setbeamerfont{sidebar right}{size=\normalsize}
\setbeamertemplate{sidebar right}{%
\setlength\sheight{\dimexpr(\paperheight-\theight)/(\inserttotalframenumber-1) \relax}
\vspace{\theight}
\begin{tikzpicture}[y=\sheight]
\foreach \i in {2,...,\inserttotalframenumber} {
\def\pgnbr{\inserttotalframenumber - \i-1}
\ifnum\i=\insertframenumber
\node[draw,very thick,inner sep=0pt,above right] at (0,\pgnbr) {\hyperlink{Navigation\i}{\rule{\swidth}{\sheight}}};
\node[white,anchor=mid,font=\bfseries] at (\swidth/2,\pgnbr+0.5) {\number\numexpr\i-1};
\else
\node[draw,very thick,inner sep=0pt,above right] at (0,\pgnbr) {\hyperlink{Navigation\i}{\color{white}\rule{\swidth}{\sheight}}};
\node[anchor=mid,font=\bfseries] at (\swidth/2,\pgnbr+0.5) {\number\numexpr\i-1};
\fi
}
\end{tikzpicture}
}
%% TITLE
\setbeamercolor{frametitle}{fg=black}
\setbeamerfont{frametitle}{size=\Large\bfseries}
\setbeamertemplate{frametitle}{%
\begin{tikzpicture}
\hspace{-\beamerleftmargin}
\draw[very thick] (0,0) rectangle (\paperwidth-0.08cm,\theight-0.05cm);
\node[anchor=mid] at (\paperwidth/2,\theight/2) {\insertframetitle};
\end{tikzpicture}
}
%%
\begin{document}
{
\setbeamertemplate{sidebar right}{}
\begin{frame}
\titlepage
\end{frame}
}
\begin{frame}{First}
\label{frame1}
First
\end{frame}
\begin{frame}{Second}
\label{frame2}
Second
\end{frame}
\begin{frame}{Third}
\label{frame3}
Third
\end{frame}
\end{document}
您也可以看看\beamer@startpageofframe
。