我在使用 beamer 主题时遇到了一些困难,我想是因为我使用了带和不带单位的位置的 tikz。
我想要一个使用页码的列表(0,\pgnbr)
,我将其定义为y=1.5cm
打开\begin{tikzpicture}[y=1.5cm]
,但我无法使用单位度量来移动它。即(0,\pgnbr+2cm)
似乎扭曲了一切。
看看发生了什么可能更容易。我的模板中的问题很明显:
- 我想让标题栏方块扩大
- 我希望侧边栏向下移动以免与标题栏重叠
- 侧边栏应该“拉伸”(参见我对此行的评论
\begin{tikzpicture}[y=1.5cm]
)
代码:
\documentclass{beamer}
\title{Title}
\author{Ricardo Cruz}
\date{}
\usepackage{tikz}
%% SIDEBAR
\def\swidth{1.2cm} % sidebar size
\def\sheight{\paperheigth / \inserttotalframenumber}
\def\theight{1.0cm} % frametitle size
\setbeamersize{sidebar width right=\swidth}
\setbeamerfont{sidebar right}{size=\normalsize}
\setbeamertemplate{sidebar right}{%
\begin{tikzpicture}[y=1.5cm] % FIXME: y=\sheight not working !
\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
\setbeamersize{frametitle height=\theight}
\setbeamercolor{frametitle}{fg=black}
\setbeamerfont{frametitle}{size=\Large\bfseries}
\setbeamertemplate{frametitle}{%
\begin{tikzpicture}
\draw[very thick] (0,0) rectangle (\paperwidth,\theight);
\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}
结果:
我试图模仿的模板:
http://www.robots.ox.ac.uk/~az/lectures/cv/adaboost_matas.pdf
答案1
\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}{%
\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,\theight);
\node[anchor=mid] at (\paperwidth/2,\theight/2) {\insertframetitle};
\end{tikzpicture}
}
%%
\begin{document}
\setlength\sheight{\dimexpr(\paperheight-\theight)/(\inserttotalframenumber-1) \relax}
{
\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}