![如何编辑 Beamer 主题 CambridgeUS](https://linux22.com/image/253777/%E5%A6%82%E4%BD%95%E7%BC%96%E8%BE%91%20Beamer%20%E4%B8%BB%E9%A2%98%20CambridgeUS.png)
我一直在 lyx 中使用带有主题 cambridgeUS 的 beamer 文档类。以下代码是序言。现在,我想通过在页眉或页脚中添加它们来在所有页面中插入指向 pdf 文件的超链接。页脚目前有作者、标题和页码。我该如何添加第四个?或者如何使用页眉来完成?
%\usecolortheme[named=Brown]{structure}
\usetheme{CambridgeUS}
%\usecolortheme{seahorse}
\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{items}[ball]
%\setbeamertemplate{navigation symbols}{}
\setbeamercolor{title}{bg=red!65!black, fg=white}
\usepackage{hyperref}
%% Macro for inserting Page number in Warsaw theme
%\newcommand*\oldmacro{}%
%\let\oldmacro\insertshorttitle%
%\renewcommand*\insertshorttitle{%
% \oldmacro\hfill%
% \insertframenumber\,/\,\inserttotalframenumber}
\usepackage{ragged2e}\title{TE TM Hybrid Modes}
\author[Dr. James]{Dr. James}
\institute[IIT Madras]{ \\Department of Electrical Engineering\\Indian Institute of Technology Madras}
\pgfdeclareimage[height=1cm]{iitmlogo}{/home/melvinp/Dropbox/NPTEL/Lecture2/IITMLogo.pdf}
\logo{\pgfuseimage{iitmlogo}}
\date{}
\AtBeginDocument{\setlength{\abovedisplayskip}{0pt}}
\addtobeamertemplate{block begin}{\setlength{\abovedisplayskip}{0pt}}
%\AtBeginSubsection[]
%{
% \begin{frame}<beamer>
% \frametitle{Layout}
% \tableofcontents[currentsection,currentsubsection]
% \end{frame}
%}
%\justifying{
谢谢
答案1
该CambridgeUS
主题使用外部主题infolines
。您可以下载CTAN 的原始文件并以此为基础制作自己的带有外部链接的外部主题。
在此示例中,页脚包含第四个字段,其中有指向 Beamer 用户指南的链接:
\mode<presentation>
\setbeamercolor*{author in head/foot}{parent=palette tertiary}
\setbeamercolor*{title in head/foot}{parent=palette secondary}
\setbeamercolor*{date in head/foot}{parent=palette primary}
\setbeamercolor*{section in head/foot}{parent=palette tertiary}
\setbeamercolor*{subsection in head/foot}{parent=palette primary}
% colors for the external link field
\setbeamercolor*{external link}{parent=palette secondary}
\defbeamertemplate*{footline}{withlink theme}
{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.25\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.25\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshorttitle
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.25\paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
\insertframenumber{} / \inserttotalframenumber
\end{beamercolorbox}%
% this is a new field with an external link
\begin{beamercolorbox}[wd=.25\paperwidth,ht=2.25ex,dp=1ex,right]{external link}%
\usebeamerfont{author in head/foot}\href{http://mirror.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf}{Link to manual}\hspace*{2ex}
\end{beamercolorbox}}%
\vskip0pt%
}
\defbeamertemplate*{headline}{withlink theme}
{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}%
\usebeamerfont{section in head/foot}\insertsectionhead\hspace*{2ex}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,left]{subsection in head/foot}%
\usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertsubsectionhead
\end{beamercolorbox}}%
\vskip0pt%
}
\setbeamersize{text margin left=1em,text margin right=1em}
\mode
<all>
将其另存为beamerouterthemewithlink.sty
并将其放入您的项目文件夹或本地 tex-mf 树中。然后您可以通过在 tex 文件中添加此行来使用它:
\useoutertheme{withlink}
类似地,您也可以通过添加另一个 来修改标题beamercolorbox
。只需确保所有beamercolorbox
es 的总宽度等于\textwidth
。
答案2
这是一个解决方案,可在导航符号上方立即添加指向 Web 资源的链接。这可通过修改模板来实现sidebar right
。(也可以在页脚中添加内容,但可能更适合添加额外的标题信息。)
\documentclass{beamer}
\usetheme{CambridgeUS}
\setbeamercolor{title}{bg=red!65!black,fg=white}
\setbeamertemplate{sidebar right}
{
\vfill%
\llap{\insertlogo\hskip0.1cm}%
\vskip2pt%
\llap{\href{http://tex.stackexchange.com/}{A link to tex.sx}\hskip0.2cm}% NEW
\vskip3pt% NEW
\llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}%
\vskip2pt%
}
\begin{document}
\title{TE TM Hybrid Modes}
\author{Dr. James}
\institute[IIT Madras]{Department of Electrical Engineering\\
Institute of Technology Madras}
\date{}
\maketitle
\end{document}
答案3
我也遇到了 beamer 类文件的问题。我正在使用以下代码:
\documentclass[slidestop,mathsrif]{beamer}
\usetheme{CambridgeUS}
\usecolortheme{lily}
\beamertemplateballitem
\usepackage{graphicx}
\usepackage{xcolor}
%\usepackage{ragged2e}
%\usepackage{hyperref}
\title[Many-body Physics with Stationary Light]{\color{red!50!green}{\bf Realization of Strongly Correlated Many-body Physics with Stationary Light}}
\subtitle{}
\author[Priyam Das]{\bf Priyam Das}
\institute{\color{green!60!blue} Institute of Nuclear Physics,\\ Hacettepe University}
\begin{document}
\maketitle
\end{document}
当我尝试通过“\institute[简短机构]{详细地址}”输入简短机构名称时,出现以下错误:
! Use of \beamer@institute doesn't match its definition.
\inserttitle ->\color {
red!50!green}{\bf Realization of Strongly Correlated ...
l.15 \begin{document}
如果我继续忽略错误,我会得到以下结果:重复的标题,但下面的简短研究所的问题并不存在。