修复投影仪中幻灯片内容的位置

修复投影仪中幻灯片内容的位置

我正在努力运行我的自定义主题。我用 tikz 创建了标题和页脚横幅,但textheight计算错误。我的第一个想法是改变标题和页脚的高度(问题:Beamer 类:文本高度对于带有 tikz 图片的页脚和标题的高度来说太大)。由于似乎没有人能解决这个问题,我想到告诉 beamer 幻灯片内容的确切起始位置和结束位置。例如距顶部 2 厘米,距框架底部 1 厘米。如果这适用于c定位和框架中断,那就太好了。感谢您的任何想法。我的 MWE 包含一个itemize列表来检查它是否正确居中。

MWE(xelatex):

\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}
    \begin{frame}[c]
        \begin{itemize}
            \item Item
            \item Item
        \end{itemize}
    \end{frame}
\end{document}

相关内容