钛钾是

钛钾是

像我之前的许多人一样,我试图在 Beamer 中重新创建我所在学院的 PowerPoint 主题。在我们的标题幻灯片上,我们有一个右对齐的图像,标题内容在左右对齐。搜索后,我发现回答如何将图像本身添加到幻灯片中;但是,这会导致图像与文本重叠(众所周知)。我尝试将文本放在另一个文本块中,但无法使文本块的边距模仿默认框架的边距。我还尝试将文本放在节点中tikz,但这也不起作用。然后我开始寻找如何调整单个框架上的边距,但找不到有效的方法。

最终,我调整了一下columns环境,并让它工作起来。例如:

\documentclass{beamer}

\usepackage{mwe}
\usepackage[overlay,absolute]{textpos}

\title{Super Awesome Presentation with a Really Long Title}
\subtitle{Because it is really cool}
\author{Me, Myself, and I}
\institute{Distinguished Institute,\par%
           Prestigious, Locale, 12345}
\date{\today}

\makeatletter
\defbeamertemplate*{title page}{custom}[1][]
{%
\newlength{\imwidth}
\setlength{\imwidth}{50mm}

\newlength{\offset}
\setlength{\offset}{\dimexpr\paperwidth-\imwidth}

\begin{textblock*}{\imwidth}(\offset, 0mm)
    \includegraphics[width=\imwidth,height=\paperheight]{example-image}
\end{textblock*}

\begin{columns}
    \begin{column}{\dimexpr\offset-\beamer@rightmargin}
        \vfill
        \inserttitle\par
        \insertsubtitle\par
        \bigskip
        \insertauthor\par
        \insertinstitute\par
        \bigskip
        \insertdate\par
    \end{column}
    \begin{column}{\imwidth}
    \end{column}
\end{columns}
}
\makeatother

\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}

虽然这种方法可行,但我认为这并不是最简洁的方法。所以,我的问题是:如何才能将图像绝对定位在投影仪幻灯片上,并让剩余空间遵循默认的投影仪格式?

答案1

使用remember picture, overlay选项,tikzpicture您可以相对于页面定位图像而不影响其他内容:

\documentclass{beamer}

\usepackage{tikz}

\title{Super Awesome Presentation with a Really Long Title}
\subtitle{Because it is really cool}
\author{Me, Myself, and I}
\institute{Distinguished Institute,\par%
           Prestigious, Locale, 12345}
\date{\today}

\makeatletter
\defbeamertemplate*{title page}{custom}[1][]
{%
\begin{tikzpicture}[remember picture, overlay]
\node[xshift=-.25\paperwidth] at (current page.east) {\includegraphics[width=.5\paperwidth,height=\paperheight]{example-image-duck}};
\end{tikzpicture}

\begin{columns}[onlytextwidth]
    \begin{column}{.5\textwidth}
        \vfill
        \inserttitle\par
        \insertsubtitle\par
        \bigskip
        \insertauthor\par
        \insertinstitute\par
        \bigskip
        \insertdate\par
    \end{column}
    \begin{column}{.5\textwidth}
    \end{column}
\end{columns}
}
\makeatother

\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}

图片模式

另一种方法是使用picture模式:

\documentclass{beamer}

\title{Super Awesome Presentation with a Really Long Title}
\subtitle{Because it is really cool}
\author{Me, Myself, and I}
\institute{Distinguished Institute,\par%
           Prestigious, Locale, 12345}
\date{\today}

\makeatletter
\defbeamertemplate*{title page}{custom}[1][]
{%
\setlength{\unitlength}{1mm}
% xpos: 128/2-10
% ypos: 
\begin{picture}(0,0)(-54,72.5)
\put(0,0){\includegraphics[width=.5\paperwidth,height=\paperheight]{example-image-duck}}
\end{picture}

\begin{columns}[onlytextwidth]
    \begin{column}{.5\textwidth}
        \vfill
        \inserttitle\par
        \insertsubtitle\par
        \bigskip
        \insertauthor\par
        \insertinstitute\par
        \bigskip
        \insertdate\par
    \end{column}
    \begin{column}{.5\textwidth}
    \end{column}
\end{columns}
}
\makeatother

\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}

在此处输入图片描述

答案2

基于这个问题和答案,其中提到使用geometry,可以使用 仅调整单张幻灯片上的右边距\newgeometry。简而言之,只需将右边距设置为图像宽度加上默认的投影仪宽度。这样可以保留页面上的其他边距和其余幻灯片上的边距,而无需columnsminipage环境。

一个有效的例子是:

\documentclass{beamer}

\usepackage{mwe}
\usepackage{lipsum}
\usepackage{geometry}
\usepackage[overlay,absolute]{textpos}

\title{Super Awesome Presentation with a Really Long Title}
\subtitle{Because it is really cool}
\author{Me, Myself, and I}
\institute{Distinguished Institute,\par%
           Prestigious, Locale, 12345}
\date{\today}

\makeatletter
\defbeamertemplate*{title page}{custom}[1][]
{%
    \newlength{\imwidth}
    \setlength{\imwidth}{50mm}

    \newlength{\offset}
    \setlength{\offset}{\dimexpr\paperwidth-\imwidth}

    \newgeometry{right=\dimexpr\imwidth+\beamer@rightmargin}

    \begin{textblock*}{\imwidth}(\offset, 0mm)
        \includegraphics[width=\imwidth,height=\paperheight]{example-image}
    \end{textblock*}
    \vfill
    \inserttitle\par
    \insertsubtitle\par
    \bigskip
    \insertauthor\par
    \insertinstitute\par
    \bigskip
    \insertdate\par
}
\makeatother

\begin{document}
\begin{frame}
\titlepage
\end{frame}

\begin{frame}
    \lipsum[1]
\end{frame}
\end{document}

相关内容