Beamer 改变框架高度

Beamer 改变框架高度

我编写了一个自定义的 beamer 样式。框架标题的高度比标准高度大。因此,框架向下移动到脚线和下边框上方。

我如何使用或类似方法校正框架高度以保持在框架标题和页脚线之间\defbeamertemplate

示例演示

\documentclass[10pt,aspectratio=169]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usetheme{mwe}

\author{an Author}
\title{a Title}
\subtitle{a subtitle}
\date{\today}

%%% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{frame}{title}
\begin{tikzpicture}
\draw [very thick] (0,0)rectangle(\textwidth,\textheight);
\end{tikzpicture}
\end{frame}

\end{document}

beamerthememwesty.sty

\mode<presentation>

\RequirePackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}

% Settings
\useoutertheme{mwe}

\mode<all>

beamerouterthememwest.sty

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{mwe}[1][]
{
    \begin{tikzpicture}
        \useasboundingbox[]
            (0,0)rectangle(\textwidth+0.5\paperwidth-0.5\textwidth,.135\paperheight);
        \node [ anchor=east,
        font=\LARGE,
        black,
        minimum height=10pt,
        align=center]
            at (current bounding box.east)
            {\textbf{\insertframetitle}};
    \end{tikzpicture}
    \vspace*{5pt}
}


\defbeamertemplate*{footline}{mwe}[1][]
{
    \begin{tikzpicture}
        \useasboundingbox [draw] (0,\the\textheight) -- (\the\paperwidth,\the\textheight);

        \node [anchor=south west, font=\tiny, black]
            at ($(current bounding box.west)+(5pt,0)$)
            {\insertauthor};

        \node [anchor=south, font=\tiny, black]
            at (current bounding box)
            {\insertdate};

        \node [anchor=south east, font=\tiny, black]
            at ($(current bounding box.east)+(-5pt,0)$)
            {\insertframenumber/\inserttotalframenumber};

        \draw [double distance = 0.6pt, line cap=round,color=black]
            ($(current bounding box.west)+(5pt,11pt)$) --
            ($(current bounding box.east)+(-5pt,11pt)$);

    \end{tikzpicture}
}
\mode<all>

这是输出:大框架显示框架区域的尺寸。

在此处输入图片描述


\newcommand*{\BlockImage}[3]
{
   \begin{column}{#1\textwidth}
   \begin{block}{\footnotesize #2}
      \centering
      \includegraphics[width=\textwidth,
                       height=.75\beamer@frametextheight,
                       keepaspectratio]{#3}
   \end{block}
   \end{column}
}

最后的解决办法

\makeatletter
\newlength{\frameheadheight}
\setlength{\frameheadheight}{2cm}
\newlength{\frametextheight}
\setlength{\frametextheight}{\paperheight}
\addtolength{\frametextheight}{-\footheight}
\addtolength{\frametextheight}{-\headheight}
\addtolength{\frametextheight}{-\frameheadheight}
\makeatother

\newcommand*{\BlockImg}[3]
{
   \begin{column}{#1\textwidth}
   \vskip-.5\frameheadheight
   \begin{block}{\footnotesize #2}
      \centering
      \includegraphics[%width=\textwidth,
                       height=.75\frametextheight,
                       keepaspectratio]{#3}
   \end{block}
   \end{column}
}

答案1

您的 itemize 没有缩小到 footline 上方的问题与 frametitle 或 textheight 完全无关。问题在于您的 footline 高度为零。如果您增加 footline 的高度,项目将缩小到其上方:

\documentclass[10pt,aspectratio=169]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\RequirePackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{mwe}[1][]
{
    \begin{tikzpicture}
        \useasboundingbox[]
            (0,0)rectangle(\textwidth+0.5\paperwidth-0.5\textwidth,.135\paperheight);
        \node [ anchor=east,
        font=\LARGE,
        black,
        minimum height=10pt,
        align=center]
            at (current bounding box.east)
            {\textbf{\insertframetitle}};
    \end{tikzpicture}
    \vspace*{5pt}
}


\defbeamertemplate*{footline}{mwe}[1][]
{
        \vskip1.8\baselineskip
    \begin{tikzpicture}
        \useasboundingbox [draw] (0,\the\textheight) -- (\the\paperwidth,\the\textheight);

        \node [anchor=south west, font=\tiny, black]
            at ($(current bounding box.west)+(5pt,0)$)
            {\insertauthor};

        \node [anchor=south, font=\tiny, black]
            at (current bounding box)
            {\insertdate};

        \node [anchor=south east, font=\tiny, black]
            at ($(current bounding box.east)+(-5pt,0)$)
            {\insertframenumber/\inserttotalframenumber};

        \draw [double distance = 0.6pt, line cap=round,color=black]
            ($(current bounding box.west)+(5pt,11pt)$) --
            ($(current bounding box.east)+(-5pt,11pt)$);

    \end{tikzpicture}
}
\mode<all>

\author{an Author}
\title{a Title}
\subtitle{a subtitle}
\date{\today}

%%% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{frame}{title}
\begin{itemize}
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\end{itemize}
\end{frame}

\begin{frame}{title}
\begin{itemize}
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\end{itemize}
\end{frame}

\end{document}

为了创建一些高度来缩放图像:

\documentclass[10pt,aspectratio=169]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\RequirePackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{mwe}[1][]
{
    \begin{tikzpicture}
        \useasboundingbox[]
            (0,0)rectangle(\textwidth+0.5\paperwidth-0.5\textwidth,.135\paperheight);
        \node [ anchor=east,
        font=\LARGE,
        black,
        minimum height=10pt,
        align=center]
            at (current bounding box.east)
            {\textbf{\insertframetitle}};
    \end{tikzpicture}
    \vspace*{5pt}
}


\defbeamertemplate*{footline}{mwe}[1][]
{
        \vskip1.8\baselineskip
    \begin{tikzpicture}
        \useasboundingbox [draw] (0,\the\textheight) -- (\the\paperwidth,\the\textheight);

        \node [anchor=south west, font=\tiny, black]
            at ($(current bounding box.west)+(5pt,0)$)
            {\insertauthor};

        \node [anchor=south, font=\tiny, black]
            at (current bounding box)
            {\insertdate};

        \node [anchor=south east, font=\tiny, black]
            at ($(current bounding box.east)+(-5pt,0)$)
            {\insertframenumber/\inserttotalframenumber};

        \draw [double distance = 0.6pt, line cap=round,color=black]
            ($(current bounding box.west)+(5pt,11pt)$) --
            ($(current bounding box.east)+(-5pt,11pt)$);

    \end{tikzpicture}
}
\mode<all>

\makeatletter
\newlength{\myheight}
\setlength{\myheight}{\paperheight}
\addtolength{\myheight}{-\footheight}
\addtolength{\myheight}{-\headheight}
\addtolength{\myheight}{-1.95cm}
\makeatother

\author{an Author}
\title{a Title}
\subtitle{a subtitle}
\date{\today}

%%% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{frame}{title}
\begin{tikzpicture}
\draw [very thick] (0,0)rectangle(\textwidth,\myheight);
\end{tikzpicture}

\end{frame}

\end{document}

相关内容