0

I am trying to build a wrap around beamer frame so that all characteristics of a frame are maintained, but the only difference will be the right and left margin. These would change if the frame (page) is odd or even.

For now I am not interested in overlays.

\documentclass[t]{beamer}

% For testing
\usepackage{blindtext}
\newcommand{\dummytext}{ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9}

% Command to easily set lengths
\newcommand{\newsetlength}[2]{\newlength{#1}\setlength{#1}{#2}}

\newsetlength{\myleftmargin}{15mm} % margin left frame
\newsetlength{\myrightmargin}{5mm} % margin right frame

\setbeamersize{text margin left=10mm,text margin right=10mm}

% Required to defined the environment
\usepackage{environ}

% https://tex.stackexchange.com/questions/6143/if-then-else-for-odd-page-even-page
\RequirePackage[strict]{changepage}

\newcounter{varframefootnote}
\newcounter{difffootnotevarframefootnote}
\newsetlength{\varframefootnotebottomamount}{\dimexpr\ht\strutbox+\dp\strutbox\relax}
\newsetlength{\varframefootnotebottomspace}{0pt}

\makeatletter

% Frame with variable margins
\NewEnviron{varframe}[1][]{%
  \setcounter{varframefootnote}{\value{footnote}}
  % In this implementation, overlays are disabled
  % To process all options, implement the same as lines 573-577 from 'beamerbaseframe.sty'
  % Beamer manual, page 58
  % \begin{frame}<overlay specification>[<default overlay specification>][options]{title}{subtitle}
  \begin{frame}<*>[<*>][#1]{}{}%
    \checkoddpage\ifoddpage\else%
      \setlength{\@tempdima}{\myleftmargin}%
      \setlength{\myleftmargin}{\myrightmargin}%
      \setlength{\myrightmargin}{\@tempdima}%
    \fi%
    % https://tex.stackexchange.com/questions/160825/modifying-margins-for-one-slide
    % https://tex.stackexchange.com/questions/330921/how-do-i-make-a-horizontal-line-span-most-of-the-document-up-to-the-margins
    \makebox[\linewidth][c]{\hbox to \paperwidth {%
      \setlength{\hsize}{\dimexpr\paperwidth-\myleftmargin-\myrightmargin\relax}%
      \setlength{\textwidth}{\hsize}%
      \setlength{\linewidth}{\hsize}%
      \hskip\myleftmargin%
      \vbox {%
        \vskip0pt%
        \vskip\dp\strutbox% from the top
        \vskip0.25pt%
        \vbox to \dimexpr\paperheight-\headheight-\footheight-\dp\strutbox-\ht\strutbox\relax {%
          % The text box itself
          % A fixed height is required for the '\vfill' to work inside 'varframe'
          % \textheight + \headheight + \footheight = \paperheight
          \BODY%
          \vskip-\dp\strutbox%
          \vskip1.75pt%
          % The following code leaves the room for the footnotes
          \setcounter{difffootnotevarframefootnote}{%
            \numexpr\value{footnote}-\value{varframefootnote}\relax}%
          \setlength{\varframefootnotebottomspace}{\value{difffootnotevarframefootnote}\varframefootnotebottomamount}%
            \global\varframefootnotebottomspace=\varframefootnotebottomspace%
          \vskip\varframefootnotebottomspace%
        }%
        \vskip-\varframefootnotebottomspace% adjust footnotes
        \vskip0pt%
      }%
      \hskip\myrightmargin%
      \hfill%
      }%
    }%
  \end{frame}%
}
\makeatother

\begin{document}

\begin{varframe}
  \blindtext
\end{varframe}

\begin{frame}
  \blindtext
\end{frame}

\begin{varframe}
  \blindtext
  \dummytext\footnote{\dummytext}
  \dummytext\footnote{\dummytext}
\end{varframe}

\begin{frame}
  \blindtext
  \dummytext\footnote{\dummytext}
  \dummytext\footnote{\dummytext}
\end{frame}

\begin{varframe}
  \blindtext
  \vfill
  \blindtext
\end{varframe}

\begin{frame}
  \blindtext
  \vfill
  \blindtext
\end{frame}

\begin{varframe}
  \blindtext
  \dummytext\footnote{\dummytext}
  \vfill
  \blindtext
  \dummytext\footnote{\dummytext}
\end{varframe}

\begin{frame}
  \blindtext
  \dummytext\footnote{\dummytext}
  \vfill
  \blindtext
  \dummytext\footnote{\dummytext}
\end{frame}

\end{document}

I am expecting that the text occupies the same space (i.e., the \textwidth is the same in both cases using frame or varframe above). But clearly it is not and some other problems appear with footnotes and \vfill. Also it shall work independenty if the frame is [t] or not (.eg., [c]).

I suspect that I shall use somewhere the macro \beamer@calculateheadfoot defined internally by beamer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.