Beamer 类:文本高度对于带有 tikz 图片的页脚和标题的高度来说太大

Beamer 类:文本高度对于带有 tikz 图片的页脚和标题的高度来说太大

我尝试重新创建我的大学 powerpoint 模板,其中包含图像作为标题和页脚横幅(beamer 类,无预定义主题,xelatex)。使用 tikz 放置图像和文本似乎更容易。在框架中放置文本时,文本从标题开始并违反页脚(定位 t 或 b)。我的 MWE 绘制了一个框来\textheight说明问题。

在此处输入图片描述

我发现这个代码片段应该可以以某种方式增加脚线的高度,但它并没有解决问题。我希望有人能帮助我。谢谢!

\makeatletter
    \patchcmd{\beamer@calculateheadfoot}{\advance\footheight by 4pt}{\advance\footheight by 20pt}{}{}
\makeatother

梅威瑟:

\documentclass[
        presentation,
        %handout,
        11pt,
        aspectratio=43, % 4:3, 128mm:96mm
        table,
        usepdftitle=false,
]{beamer}

% Packages
\usepackage{tikz}
\usetikzlibrary{arrows, shapes.arrows, arrows.meta, positioning, fit, calc, backgrounds, patterns, 3d}

% Lengths
\newlength{\myLeftMargin}
\newlength{\myLeftMarginText}
\newlength{\myRightMargin}
\newlength{\myRightMarginText}

\setlength{\myLeftMargin}{0.019685\paperwidth}
\setlength{\myLeftMarginText}{0.0909\paperwidth}
\setlength{\myRightMargin}{\myLeftMargin}
\setlength{\myRightMarginText}{\myLeftMarginText}

\setbeamersize{text margin left=\myLeftMarginText}
\setbeamersize{text margin right=\myRightMarginText}
\setbeamersize{sidebar width left=0pt}

% Headline
\makeatletter
    \patchcmd{\beamer@calculateheadfoot}{\advance\footheight by 4pt}{\advance\footheight by 20pt}{}{}
\makeatother

\setbeamertemplate{headline}{%
    \begin{tikzpicture}[overlay, remember picture]
        \node[anchor=north west, inner sep=0pt] at ($(current page.north west)+(0,0)$) (nodeHeadlineBar){
            \includegraphics[width=\paperwidth, height=0.15\paperheight]{example-image}
        };
    \end{tikzpicture}%
}

\setbeamertemplate{frametitle}{%
    \begin{tikzpicture}[overlay, remember picture]
        \node[anchor=west, inner sep=0pt] at ($(nodeHeadlineBar.west)+(\myLeftMargin,0)$){
            \insertframetitle
        };
    \end{tikzpicture}%
}

\setbeamertemplate{footline}{%
    \begin{tikzpicture}[overlay, remember picture]
        \node[anchor=south west, inner sep=0pt] at ($(current page.south west)+(0,0)$) (nodeFootlineBar){
            \includegraphics[width=\paperwidth, height=0.05\paperheight]{example-image}
        };
        \node[anchor=east, inner sep=0pt] at ($(nodeFootlineBar.east)+(-\myRightMargin,0)$){
            \insertframenumber\,/\,\inserttotalframenumber
        };
    \end{tikzpicture}%
}

\begin{document}
    \section{Example 1}
    \begin{frame}[b]{\secname}
        \begin{tikzpicture}
            \draw[red] (0,0) rectangle (\textwidth,\textheight);
            \draw[red] (0,\textheight) -- (\textwidth,0)
                       (0,0) -- (\textwidth, \textheight);
        \end{tikzpicture}
    \end{frame}
    \section{Example 2}
    \begin{frame}[t]{\secname}
        \begin{tikzpicture}
            \draw[red] (0,0) rectangle (\textwidth,\textheight);
            \draw[red] (0,\textheight) -- (\textwidth,0)
            (0,0) -- (\textwidth, \textheight);
        \end{tikzpicture}
    \end{frame}
\end{document}

相关内容