如何在投影仪框架中垂直对齐文本

如何在投影仪框架中垂直对齐文本

继续上一个问题如何仅在框架的第一张幻灯片上显示框架标题,文本对齐存在问题。问题是我尝试为图片等每一帧设置 bottomsep 和 top sep 在此处输入图片描述

因此对于文本,需要从底部和顶部设置 4 pt 的缩进,如图所示,这样还允许为每个部分分出一个新的内容页(单独的标题页是新讲座的标题)。

TeX 示例代码:

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


\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usefonttheme{professionalfonts}
\usepackage{concmath}
\usefonttheme{serif}
\usepackage{setspace}
\usepackage{indentfirst}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{ragged2e}
\usepackage{etoolbox}
\usepackage{lipsum}

% 1. Line spacing 1.15
\setstretch{1.0}

% 2. Indent margin 1.25 cm
\setlength{\parindent}{1.15cm}

% 3. Indentation between adjacent paragraphs 12pt (double)
\setlength{\parskip}{4pt}
\setlength{\emergencystretch}{3em}

\expandafter\def\expandafter\normalsize\expandafter{%
    \normalsize
    \setlength\abovedisplayskip{4pt}
    \setlength\belowdisplayskip{4pt}
    \setlength\abovedisplayshortskip{4pt}
    \setlength\belowdisplayshortskip{4pt}
}


\makeatletter
\long\def\beamer@@frametitle[#1]#2{%
  \ifblank{#2}{}{%
    \ifnum\beamer@autobreakcount<2
    \gdef\insertframetitle{{%
      #2%
    }}%
    \gdef\beamer@frametitle{#2}%
    \gdef\beamer@shortframetitle{#1}%
    \fi%
  }%
}


\newcommand{\repar}{\vspace{-4pt}}
\renewcommand{\indent}{\hspace*{20pt}}

\setbeamertemplate{frametitle}[default][center]

%% Set the left and right margins
\setbeamersize{text margin left=2em,text margin right=2em}


%% FONTS
\setbeamerfont{title}{size=\LARGE}
\setbeamerfont{subtitle}{size=\Large}
\setbeamerfont{frametitle}{size=\Large}
\setbeamerfont{block title}{size=\normalsize}
\setbeamerfont{footline}{size=\normalsize}

%% COLOURS
%% If you'd like everything to have the same colour
\usebeamercolor{structure}
\setbeamercolor{normal text}{fg=black}
\setbeamercolor{structure}{bg=black!20,fg=black}

%% Add a line after the frametitle
% \addtobeamertemplate{frametitle}{}{\vspace*{-1ex}\rule{\textwidth}{1pt}}


%% Remove default navigation symbols (We'll add the ones we need in the footline
\setbeamertemplate{navigation symbols}{}

\setbeamertemplate{section in toc}[sections numbered]


%% And before the footline... actually we'd like to re-define
%% the footline
\setbeamertemplate{footline}{%
   %% Beamer headlines and footlines are always full-paperwidth, so if you want the horizontal line to
   %% not span it entirely you'll need to do a bit of arithmetic
   \centering
   \begin{minipage}{\dimexpr\paperwidth-\beamer@leftmargin-\beamer@rightmargin\relax}
   \vspace{-4ex}
   \centering
   \rule{\linewidth}{1pt} \vskip 1pt
   \usebeamerfont{footline}%
   \usebeamercolor{footline}%
   %% The frame number smack in the middle
   % \hfill\insertpagenumber/\inserttotalframenumber
   \hfill\insertpagenumber
   \hfill%
   %% ONLY the navigation symbols we want at the far right.
   %% We use an \llap so that it takes up zero width, and doesn't throw the page number off-centre!
   \llap{\insertframenavigationsymbol\insertbackfindforwardnavigationsymbol}\par
   \end{minipage}\vskip1pt
}

\define@key{beamerframe}{t}[true]{% top
  \beamer@frametopskip=4pt%
  \beamer@framebottomskip=4pt%
  \beamer@frametopskipautobreak=4pt%
  \beamer@framebottomskipautobreak=4pt
%
}

\makeatother

\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=false,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}


\title{\textbf{Linear Algebra}}
\author{Author}
\date{August 2023}

\apptocmd{\frame}{}{\justifying}{}

\begin{document}

\begin{frame}
\thispagestyle{empty}
  \titlepage
\end{frame}

\begin{frame}[allowframebreaks,allowdisplaybreaks]\frametitle{Outlist}
    \tableofcontents[sections=1]
    \tableofcontents[sections=2] 
    \tableofcontents[sections=3]
    \tableofcontents[sections=4]
    \tableofcontents[sections=5]
    \tableofcontents[sections=6]
    \tableofcontents[sections=7]
    \tableofcontents[sections=8]
    \tableofcontents[sections=9]
    \tableofcontents[sections=10]
    \tableofcontents[sections=11]
\end{frame}

\section{Introduction}

\subsection{Intro}

\begin{frame}[allowframebreaks,allowdisplaybreaks,t] \frametitle{Intro}
\lipsum[1-2]
\end{frame}

\subsection{Intro II}

\begin{frame}[allowframebreaks,allowdisplaybreaks] \frametitle{Intro II}
\lipsum[1-5]
\end{frame}

\section{Mathematics}

\section{Mathematics II}

\section{Mathematics III}

\begin{frame}[allowframebreaks,allowdisplaybreaks]
\frametitle{Readable Mathematics III}
\lipsum[1-6]
\end{frame}

\section{Mathematics IV}

\section{Mathematics V}

\section{Mathematics VI}

\section{Mathematics VII}

\section{Mathematics VIII}

\section{Mathematics IX}

\section{Mathematics X}

\end{document}

我尝试设置顶部跳过,但这没有效果

\define@key{beamerframe}{t}[true]{% top
  \beamer@frametopskip=4pt%
  \beamer@framebottomskip=4pt%
  \beamer@frametopskipautobreak=4pt%
  \beamer@framebottomskipautobreak=4pt
%
}

我的故障排除: 如何使投影仪框架中的文本垂直对齐,同时顶部和底部跳过 4pt,并在页面上更正文本对齐?

答案1

两个半问题:

  • \vspace{-4ex}使得您的脚注比实际尺寸小得多。因此,文本被打印在了脚注上。

  • \define@key{beamerframe}{t}[true]{% top
      \beamer@frametopskip=4pt%
      \beamer@framebottomskip=4pt%
      \beamer@frametopskipautobreak=4pt%
      \beamer@framebottomskipautobreak=4pt
    }
    

    您取消了任何拉伸内容的可能性。在正常[t]框架中,bottomskip 可拉伸以填充页面的剩余部分。

    如果您想同时在顶部和底部对齐文本,这更像是[s]可拉伸框架而不是[t]op 框架对齐。但是,您需要在页面中提供一些其他可拉伸材料,特别是因为您基本上覆盖了所有其他长度以进行固定而没有任何拉伸(\parskip\abovedisplayskip等等)。如果框架内没有任何可拉伸的东西,您的最后一行恰好与框架底部对齐的可能性就很小。

  • 您可能已经改进了t帧对齐,但实际上从未将其用于任何帧。


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

\usefonttheme{professionalfonts}
\usepackage{concmath}
\usefonttheme{serif}

\usepackage{ragged2e}
\usepackage{lipsum}

\setbeamertemplate{frametitle}[default][center]

%% Set the left and right margins
\setbeamersize{text margin left=2em,text margin right=2em}

\setbeamerfont{frametitle}{size=\Large}
\setbeamerfont{footline}{size=\normalsize}
\setbeamercolor{structure}{bg=black!20,fg=black}

%% Remove default navigation symbols (We'll add the ones we need in the footline
\setbeamertemplate{navigation symbols}{}

\makeatletter
\define@key{beamerframe}{s}[true]{% stretch
  \beamer@frametopskip=4pt\relax%
  \beamer@framebottomskip=4pt plus 0.001fill\relax%
  \beamer@frametopskipautobreak=\beamer@frametopskip\relax%
  \beamer@framebottomskipautobreak=\beamer@framebottomskip\relax%
}

%% And before the footline... actually we'd like to re-define
%% the footline
\setbeamertemplate{footline}{%
   %% Beamer headlines and footlines are always full-paperwidth, so if you want the horizontal line to
   %% not span it entirely you'll need to do a bit of arithmetic
   \centering
   \begin{minipage}{\dimexpr\paperwidth-\beamer@leftmargin-\beamer@rightmargin\relax}
%   \vspace{-4ex}
   \centering
   \rule{\linewidth}{1pt} \vskip 1pt
   \usebeamerfont{footline}%
   \usebeamercolor{footline}%
   %% The frame number smack in the middle
   % \hfill\insertpagenumber/\inserttotalframenumber
   \hfill\insertpagenumber
   \hfill%
   %% ONLY the navigation symbols we want at the far right.
   %% We use an \llap so that it takes up zero width, and doesn't throw the page number off-centre!
   \llap{\insertframenavigationsymbol\insertbackfindforwardnavigationsymbol}\par
   \end{minipage}\vskip1pt
}

\long\def\beamer@@frametitle[#1]#2{%
  \ifblank{#2}{}{%
    \ifnum\beamer@autobreakcount<2
    \gdef\insertframetitle{{%
      #2%
    }}%
    \gdef\beamer@frametitle{#2}%
    \gdef\beamer@shortframetitle{#1}%
    \fi%
  }%
}
\makeatother


\title{\textbf{Linear Algebra}}
\author{Author}
\date{August 2023}

\apptocmd{\frame}{}{\justifying}{}

\begin{document}

\begin{frame}[s,allowframebreaks]
\frametitle{Readable Mathematics III}
\lipsum[2]
\vfill
\lipsum[2]
\lipsum[2]
\vfill
\lipsum[2]
\end{frame}

\end{document}

在此处输入图片描述

相关内容