我想自定义 Beamer 文档中的页脚,以使用条形图显示部分名称超过文档页脚中名称的顶部。例如:
使用在 Stack Exchange 上找到的代码,我能够在页脚中生成以下内容:
我想知道是否有人可以建议对我的代码进行修改,以产生后者,以便达到前者(或至少尽可能接近)。具体来说,我希望部分名称位于符号下方,所有部分的符号都可见(当前部分颜色较深),形状大致为矩形。如果可能的话,我还希望通过单击部分标题上方的块来导航到相关部分。我生成后者的代码如下,非常感谢,乔
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes,calc,positioning,arrows}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=4.8ex,dp=5.125ex]{palette}%
\insertsectionnavigationhorizontal{\paperwidth}{}{\hskip0pt plus1filll}
\end{beamercolorbox}%
}
}
\setbeamertemplate{section in head/foot}{%
\if\insertsectionheadnumber1
\tikz\node[draw=blue,fill=blue,shape=signal,very thick,text=white]{\insertsectionhead\hskip.3cm};
\else
\tikz\node[draw=blue,fill=blue,shape=signal,signal from=west, signal to=east,very thick,text=white] {\insertsectionhead\hskip.3cm};
\fi
}
\setbeamertemplate{section in head/foot shaded}{%
\if\insertsectionheadnumber1
\tikz\node[draw=blue,fill=white,shape=signal,very thick,text=blue]{\insertsectionhead\hskip.3cm};
\else
\tikz\node[draw=blue,fill=white,shape=signal,signal from=west, signal to=east,very thick,text=blue] {\insertsectionhead\hskip.3cm};
\fi
}
\begin{document}
\section{objective 1}
\begin{frame} \frametitle{My First Slide} Slide 1 \end{frame}
\section{objective 2}
\begin{frame} \frametitle{My Second Slide} Slide 2 \end{frame}
\end{document}
答案1
所以如果我理解正确的话,你基本上是想在 TikZ 代码中更改绘图。首先我们可以简单地这样做,因为形状不会因部分而异。然后我们调整绘图和颜色以遵循您的示例。基本上,绘图分为两个步骤。首先填充您喜欢的区域\fill[fill=blue,draw=none] (0,0) -| (1.5,0.2) -- (0.4,0.2) -- (0.3,0.3) -- (0.2,0.2) -| cycle;
,然后在下面添加一个包含文本的节点\node(text)[text=blue,anchor=north west] at (0,0) {\strut\insertsectionhead\hskip.3cm};
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes,calc,positioning,arrows}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{%
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=4.8ex,dp=5.125ex]{palette}%
\insertsectionnavigationhorizontal{\paperwidth}{}{\hskip0pt plus1filll}
\end{beamercolorbox}%
}
}
\setbeamertemplate{section in head/foot}{%
\begin{tikzpicture}%
\node[anchor=north west,inner sep=0pt,outer sep=0pt,text=white] at (0,0.3) {\hyperlink{Outline\insertpartheadnumber.\insertsectionheadnumber}{\rule{1.5cm}{0.6cm}}};
\fill[fill=blue,draw=none] (0,0) -| (1.5,0.2) -- (0.4,0.2) -- (0.3,0.3) -- (0.2,0.2) -| cycle;
\node(text)[text=blue,anchor=north west] at (0,0) {\strut\insertsectionhead\hskip.3cm};
\end{tikzpicture}
}
\setbeamertemplate{section in head/foot shaded}{%
\begin{tikzpicture}%
\node[anchor=north west,inner sep=0pt,outer sep=0pt,text=white] at (0,0.3) {\hyperlink{Outline\insertpartheadnumber.\insertsectionheadnumber}{\rule{1.5cm}{0.6cm}}};
\fill[fill=blue!50,draw=none] (0,0) -| (1.5,0.2) -| cycle;
\node(text)[text=blue,anchor=north west] at (0,0) {\strut};
\end{tikzpicture}
}
\begin{document}
\section{objective 1}
\begin{frame} \frametitle{My First Slide} Slide 1 \end{frame}
\section{objective 2}
\begin{frame} \frametitle{My Second Slide} Slide 2 \end{frame}
\section{objective 3}
\begin{frame} \frametitle{My Second Slide} Slide 2 \end{frame}
\end{document}
除了您的请求外,还有一个可用的链接
实际上beamer
使用已命名的目标Outline<part>.<section>
来标识部分的起始页。beamer
还提供\hyperlink
链接到此类目标的命令。我发现一个快速而粗略的解决方案是在背景中放置一个可用于链接的表面,然后使用给定的部分和部分编号引用该部分。因此我们添加此行:\node[anchor=north west,inner sep=0pt,outer sep=0pt,text=white] at (0,0.3) {\hyperlink{Outline\insertpartheadnumber.\insertsectionheadnumber}{\rule{1.5cm}{0.6cm}}};
我相信有更好的解决方案,即在节点中创建一个空框以使超链接工作,在这种情况下,您可以删除,text=white
也许还可以动态调整节点的大小以适应实际内容。尽管如此,此解决方案还是会为矩形和按钮的区域生成一个链接,如果您想查看大小,请更改text=white
为text=red
,它将被绘制为红色。