无法使用 Beamer 创建仅带有背景图像的标题页

无法使用 Beamer 创建仅带有背景图像的标题页

我在这里阅读了说明Beamer:标题页整页图像创建一个仅在标题页中有背景的演示文稿,我对 LaTex 了解不多,因为我使用 pandoc 来生成演示文稿。无论如何,我可以修改 pandoc 生成的 LaTex 文件以添加背景,但它不起作用。这是 LaTex,pandoc 生成了很多东西:

\documentclass[ignorenonframetext,]{beamer}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{: }
\setbeamercolor{caption name}{fg=normal text.fg}
\beamertemplatenavigationsymbolsempty
\usepackage{lmodern}
\usepackage{tikz}

\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
\usecolortheme{fly}
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\newif\ifbibliography
\hypersetup{
            pdftitle={Testing background images},
            pdfauthor={First Author; Second Author},
            pdfborder={0 0 0},
            breaklinks=true}

% Prevent slide breaks in the middle of a paragraph:
\widowpenalties 1 10000
\raggedbottom

\AtBeginPart{
  \let\insertpartnumber\relax
  \let\partname\relax
  \frame{\partpage}
}
\AtBeginSection{
  \ifbibliography
  \else
    \let\insertsectionnumber\relax
    \let\sectionname\relax
    \frame{\sectionpage}
  \fi
}
\AtBeginSubsection{
  \let\insertsubsectionnumber\relax
  \let\subsectionname\relax
  \frame{\subsectionpage}
}

\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{Figures1.jpg}}
\title{Testing background images}
\author{First Author \and Second Author}
\institute{Universidad Nacional De Gral. Sarmiento}
\date{May 2017}

\begin{document}

\frame{\titlepage}
{
\usebackgroundtemplate{}

\begin{frame}{Test slide}

This is a test with no background

\begin{itemize}
\tightlist
\item
  Item 1
\end{itemize}

\end{frame}
}
\end{document}

答案1

您应该删除为 beamer 指定的选项,然后使用:

{
\usebackgroundtemplate{\includegraphics[width=\paperwidth,height=\paperheight]{yourimagename}}
\begin{frame}
\titlepage
\end{frame}
}

制作一张只有图片的幻灯片,并附有标题。下面是一个例子,第一张幻灯片上有一只猫,第二张幻灯片(测试幻灯片)上有一只猫的影子。请记住,我正在使用环境frame;我不建议使用该frame命令(我认为它在这里没有任何好处,而且会引起用法上的混淆):

    \documentclass{beamer}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{: }
\setbeamercolor{caption name}{fg=normal text.fg}
\beamertemplatenavigationsymbolsempty
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
\usecolortheme{fly}
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\newif\ifbibliography
\hypersetup{
            pdftitle={Testing background images},
            pdfauthor={First Author; Second Author},
            pdfborder={0 0 0},
            breaklinks=true}

% Prevent slide breaks in the middle of a paragraph:
\widowpenalties 1 10000
\raggedbottom

\AtBeginPart{
  \let\insertpartnumber\relax
  \let\partname\relax
  \frame{\partpage}
}
\AtBeginSection{
  \ifbibliography
  \else
    \let\insertsectionnumber\relax
    \let\sectionname\relax
    \frame{\sectionpage}
  \fi
}
\AtBeginSubsection{
  \let\insertsubsectionnumber\relax
  \let\subsectionname\relax
  \frame{\subsectionpage}
}

\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}


\title{Testing background images}
\author{First Author \and Second Author}
\institute{Universidad Nacional De Gral. Sarmiento}
\date{May 2017}

\begin{document}

{
\usebackgroundtemplate{\includegraphics[width=\paperwidth,height=\paperheight]{example}}
\begin{frame}
\titlepage
\end{frame}
}
\begin{frame}{Test slide}

This is a test with no background

\begin{itemize}
\tightlist
\item
  Item 1
\end{itemize}

\end{frame}

\end{document}

在此处输入图片描述

我认为这种行为背后的主要原因是该ignorenonframetext选项改变了 beamer 文件的解析模式,进入了所谓的mode*

引用beamer手册:

文本被逐个标记地吞噬,直到找到以下标记之一:\mode、\frame、\againframe、\part、\section、\subsection、\appendix、\note、\begin{frame} 和 \end{document}

基本上这会忽略usebeamertemplate命令,从而产生结果

答案2

原因正如 @moriambar 所指出的,是ignorenonframetextpandoc 添加的选项。因此,为了规避此限制,您必须将 \setbeamertemplate(或\usebackgroundtemplate对于旧命令)标记为属于演示文稿,如下所示:

\begin{document}
\mode<all>  % enable the interpretation of the next line
\setbeamertemplate{background canvas}{\includegraphics[width=\paperwidth]{Figures1.jpg}}
\frame{\titlepage}

% Undo the background and reset the mode to \mode*
\mode<all>\setbeamertemplate{background canvas}{}
\mode*

\begin{frame}{My next frame title}
...
\end{frame}

相关内容