1

In continuation of the previous question How to show the frametitle only on the first slide of a frame , there was a problem with text alignment. The problem is that I am trying set bottomsep and top sep for every frame such as pictures enter image description here

so for the text, it is necessary to set indents of 4 pt from the bottom and top, as shown in the figure, so that there is also allow break a new page of content for each section (a separate title page is the title of a new lecture).

TeX exmaple code:

\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}

and I try to to set top skip, but this no effect

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

And my troubleshooting: How to align text vertically in beamer frame with this top and bottom skip 4pt and correct text aligment at the page?

2
  • 1
    You are mixing two unrelated problems: 1) how to set the top/bottom margins and 2) how to influence the break point of allowframebreaks (which is an evil option, you will get much better result if you split the frames yourself) Commented Aug 22, 2023 at 15:11
  • @samcarter_is_at_topanswers.xyz It just seems to me that if you set the alignment correctly, then the page break will automatically be corrected.
    – Alex
    Commented Aug 22, 2023 at 15:14

1 Answer 1

2

Two and a half problems:

  • The \vspace{-4ex} made your footline way smaller than it actually is. Consequently, text was printed over it.

  • with

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

    you take away any possibility to stretch the content. In a normal [t] frame, the bottomskip is stretchable to fill the remainder of the page.

    If you want to align your text simultaneously at the top and bottom, this resembles more a [s]tretchable frame instead of a [t]op frame alignment. However you will need to provide some other stretchable material within your page, in particular as your are basically overwriting all other lengths to be fixed without any stretch (\parskip, \abovedisplayskip etc.). Without anything stretchable within the frame, chances are pretty slim that your last line will coincidently align with the bottom of the frame.

  • you might have refined the t frame alignment, but you never actually use if for any of your frames.


\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}

enter image description here

5
  • If i have page this solution work perfectly, but for next page, without title sidebar, text not have vertical (top skip) 4pt (second image). Probably, it highly dependent on the content itself. Thank you so much for explaining the mechanism for adjusting indents and formatting text on a frame!
    – Alex
    Commented Aug 22, 2023 at 16:29
  • @Alex Works fine for me, even with the evil framebreak option Commented Aug 23, 2023 at 11:36
  • I'm sorry, I may not have quite just correctly understood the concept of the work of a document of this class, your example, if copied completely, works in the same way, however, for second slide, if you do not intentionally break the text, there is no indent of 4 pt from the top border of the frame, probably I should to manually track transition between each slide.
    – Alex
    Commented Aug 23, 2023 at 19:55
  • @Alex Doing the break manually is a much better idea! You can get rid of the evil frame breaks and use the much more powerful overlays instead to split your frame into multiple slides. You will still have to manually add some stretchable material to each and every slide with all your fixed lengths. Commented Aug 23, 2023 at 20:01
  • @ samcarter_is_at_topanswers.xyz When there is a lot of content, i.e. the course of lectures is the same, then of course, this causes difficulties, because such problems are not considered in the classic template, the transition to a new page is organized correctly. And in this case, for the second slide, the top indent is still not 4 pt, and I can't set it manually either...
    – Alex
    Commented Aug 23, 2023 at 20:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .