考虑以下 MWE:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,intersections,calc,decorations.pathreplacing,
decorations.markings}
\addtobeamertemplate{frametitle}{}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=south west, yshift=-2pt, xshift=1pt] at (current page.south west)
{};
\draw[blue] ([yshift=-1cm, xshift=0.25cm]current page.north west)
-- ([yshift=-1cm, xshift=\paperwidth - 0.25cm]current page.north west);
\end{tikzpicture}}
\begin{document}
\begin{frame}
\frametitle{A shor title}
Foo
\end{frame}
\begin{frame}
\frametitle{A terribly long beamer slide title about some obscure meaningless
topic}
Bar
\end{frame}
\end{document}
所以我的问题是:是否可以使用 tikz(或任何其他包)来生成适应多行框架标题的规则? 谢谢!
编辑:在我的特定情况下,我需要一个也适用于大写框架标题的解决方案。我目前通过添加以下行来获得它:
\setbeamertemplate{frametitle}{\expandafter\MakeUppercase\expandafter\insertframetitle}
答案1
使用tikz
它来绘制一个简单的规则听起来有点过度 - 我只需执行以下操作:
\documentclass{beamer}
\setbeamercolor{separation line}{bg=red}
\makeatletter
\setbeamertemplate{frametitle}{
\ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
\@tempdima=\textwidth%
\advance\@tempdima by\beamer@leftmargin%
\advance\@tempdima by\beamer@rightmargin%
\begin{beamercolorbox}[sep=0.3cm,left,wd=\the\@tempdima]{frametitle}
\usebeamerfont{frametitle}%
\vbox{}\vskip-1ex%
\if@tempswa\else\csname beamer@fteleft\endcsname\fi%
\strut\MakeUppercase{\insertframetitle}\strut\par%
{%
\ifx\insertframesubtitle\@empty%
\else%
{\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
\fi
}%
\vskip-1ex%
\if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
\end{beamercolorbox}%
\begin{beamercolorbox}[sep=0.3cm,wd=\the\@tempdima]{frametitle}
\hrulefill\hspace*{0cm}
\end{beamercolorbox}
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{A shor title}
Foo
\end{frame}
\begin{frame}
\frametitle{A terribly long beamer slide title about some obscure meaningless
topic}
Bar
\end{frame}
\end{document}
TIKZ 解决方案
\documentclass{beamer}
\usepackage{tikz}
\setbeamercolor{separation line}{bg=red}
\makeatletter
\addtobeamertemplate{frametitle}{}{
\begin{beamercolorbox}[sep=0.3cm,wd=\the\@tempdima]{frametitle}
\begin{tikzpicture}
\draw[structure.fg] (0,0) -- (12.2,0);
\end{tikzpicture}
\end{beamercolorbox}
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{A shor title}
Foo
\end{frame}
\begin{frame}
\frametitle{A terribly long beamer slide title about some obscure meaningless
topic}
Bar
\end{frame}
\end{document}