# beamer margins in custom template

I have made a beamer template and I want to change the margins, especially the one of the main body block, from the template itself. I have read about \voffset and all the other margins from another post, I tried them but they didn't work as they push the title also down. Also using shrink fails due to the margins. I can use \vspace within the frames in the tex file but this is hardly elegant and a good solution IMO.

Find below the template file (beamerthemeMedian.sty):

%% Filename: beamerthemeMedian.sty
\mode<presentation>
\RequirePackage{pgfcomp-version-0-65, textpos, xcolor, tikz}

% % WHAT I HAVE TRIED!
%\voffset=2cm
%\topmargin=2cm

\setlength{\leftmargini}{4mm}

\newcommand{\MedianLine}{%
\ifnum \insertpagenumber=1
\else
\raisebox{-15mm}[0pt][0pt]{%
\begin{pgfpicture}{0mm}{0mm}{0mm}{0mm}
\pgfsetlinewidth{3mm}
\color{yellow}
\pgfline{\pgfpoint{-1cm}{0mm}}{\pgfpoint{-0.1cm}{0mm}}%
\pgfsetlinewidth{3mm}
\color{yellow}
\pgfline{\pgfpoint{0mm}{0mm}}{\pgfpoint{12cm}{0mm}}%
\end{pgfpicture}}
\fi}

\setbeamertemplate{frametitle}{
\vspace*{4mm}\hspace*{0mm}\insertframetitle}

\mode
<all>


and a minimal example that uses it and demonstrates the issues:

\documentclass{beamer}
\usetheme{Median}

\usepackage{mwe}

\begin{document}
\frame{\titlepage}

\frame[shrink=5]{\frametitle{When [shrink] and no vspace}
%\vspace{0.75cm}
\begin{itemize}
\item lorem ipsum
\end{itemize}
}

\frame[shrink=5]{\frametitle{When [shrink] and no vspace}
\begin{itemize}
\item lorem ipsum
\end{itemize}
}

\frame[shrink=5]{\frametitle{When [shrink] and vspace; not elegant}
\vspace{0.75cm}
\begin{itemize}
\item lorem ipsum
\end{itemize}
}

\frame{\frametitle{Using an image; no vspace}
\begin{figure}
\includegraphics[width=4cm]{example-image}
\end{figure}
\begin{itemize}
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\end{itemize}
}

\frame{\frametitle{Using an image; with vspace; not elegant}
\vspace{0.75cm}
\begin{figure}
\includegraphics[width=4cm]{example-image}
\end{figure}
\begin{itemize}
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\item lorem
\end{itemize}
}
\end{document}

• Welcome to TeX.SX! I tried the code and it doesn't work, even with some adjustments :( – RicoRally Nov 20 '14 at 20:22
• Welcome to TeX.SX! It is great that you have provided code but it is rather a lot for a minimal working example (MWE). Please try to reduce it to just that needed to reproduce the problem. And, as @RicoRally says, don't forget to compile your MWE before posting it to check that it compiles and produces the (un)intended output! – cfr Nov 20 '14 at 23:15
• @RicoRally Thank you. I think it must have failed due to missing image... I have put one which if you downloaded please rename it as foo.png or use any foo.png image of yours. All files go in the same directory. – John Smith Nov 21 '14 at 15:54
• @cfr Thank you. I really tried to provide a minimal example showcasing the problem... unfortunately, the minimal is not truly minimal in this case... but any other cuts would not demonstrate the problem as shown in the images. – John Smith Nov 21 '14 at 15:55
• It seems really unlikely the problem depends on \modulecode or your colour choices. Minimising your example will make it more likely you'll receive help because people will not have to go through a bunch of irrelevant bits to find the problem. If the issue really does depend on something like your definition of \modulecode and you don't know how to repair it, add that information to your question. – cfr Nov 21 '14 at 16:24

A quick and dirty solution is to add a \vspace{} after the frametitle

% Now that we have changed the headline, we will need to orient the frame titles in a way that the come at the right stop just above the horizontal line.
\setbeamertemplate{frametitle}{
\vspace*{4mm}\hspace*{0mm}\insertframetitle \vspace*{1cm}}


Full code:

%% beamerthemeMedian.sty
%% Author: Yiannis Gatsoulis
%% Date: November 2014

%% Preamble
\mode<presentation>
\RequirePackage{pgfcomp-version-0-65, textpos, xcolor, tikz}

%\voffset=2cm
%\topmargin=2cm

%% Variables
\newcommand\modulecode[1]{\def\insertmodulecode{#1}}
\modulecode{}

\newcommand\modulelongname[1]{\def\insertmodulelongname{#1}}
\modulelongname{}

\newcommand\moduleshortname[1]{\def\insertmoduleshortname{#1}}
\moduleshortname{}

\newcommand\handoutname[1]{\def\inserthandoutname{#1}}
\handoutname{}

\newcommand\titlesmallboxtext[1]{\def\inserttitlesmallboxtext{#1}}
\titlesmallboxtext{\inserthandoutname}

\newcommand\titlebigboxtext[1]{\def\inserttitlebigboxtext{#1}}
\titlebigboxtext{\inserttitle}

\newcommand\titleverybigboxtext[1]{\def\inserttitleverybigboxtext{#1}}
\titleverybigboxtext{\insertmodulecode: \insertmoduleshortname}

%% Colors
%\definecolor{ColorBgCanvas}{RGB}{230,230,250}
\definecolor{ColorBgCanvas}{RGB}{255,255,255}
\definecolor{ColorMain}{rgb}{0, 0, 0} % (rgb - 0, 0, 0) is nothing but black

\definecolor{ColorBigBox}{RGB}{41,65,113}
\definecolor{ColorBigBoxText}{RGB}{255, 255, 255}
\definecolor{ColorSmallBox}{RGB}{116,140,188}
\definecolor{ColorSmallBoxText}{RGB}{255, 255, 255}

% This sets the colour of the title of the presentation and titles of all the slides in the presentation to black.
\setbeamercolor{frametitle}{fg = ColorMain}
\setbeamercolor{title}{fg = ColorMain}

\setbeamercolor{section in toc}{fg = ColorMain}
\setbeamercolor{section in toc shaded}{fg = ColorMain}

% The colour of all the items, subitems and and subsubitems are set to black.
% NOTE: Setting the color black for all the items also sets in black for other environemnts like enumerate
\setbeamercolor{item}{fg = ColorMain}
\setbeamercolor{subitem}{fg = ColorMain}
\setbeamercolor{subsubitem}{fg = ColorMain}

% This sets the color for each item heading of the description environment.
%\setbeamercolor{description item}{fg = Descitem}

% colours for captions for figures and tables.
\setbeamercolor{caption}{fg = ColorMain}
\setbeamercolor{caption name}{fg = ColorMain}

% In addition, we can also change the background colour of the slides depending on pur requirement.
%\setbeamercolor{background canvas}{bg=ColorBgCanvas}

% the colour of the text
\setbeamercolor{normal text}{fg=ColorMain}

%% Boxes
% Standard block
\setbeamercolor{block title}{bg=ColorSmallBox, fg=ColorSmallBoxText}
\setbeamercolor{block body}{bg=white}

% Example block
\setbeamercolor{block title example}{bg=ColorSmallBox, fg=ColorSmallBoxText}
\setbeamercolor{block body example}{bg=white}

%%%%
%% Font theme
% Here we are using default fonts
\usefonttheme{professionalfonts}

%\setbeamerfont{}{size=\Large}
%\setbeamerfont{normal text}{size=\Large}

% Font of the frame titles
\setbeamerfont{frametitle}{size=\Large}

%%%%
%% Inner theme
\useinnertheme{rectangles}

%% Lists
\setlength{\leftmargini}{4mm}
\setbeamertemplate{itemize item}{\tikz{\draw[color=ColorSmallBox, semithick] rectangle(.18,.18);}}
%\setbeamertemplate{itemize/enumerate body begin}{\normalsize}
\setbeamertemplate{itemize subitem}{\tikz{\draw[color=ColorBigBox, ultra thick] rectangle(.15,.15);}}
\setbeamertemplate{itemize subsubitem}{\tikz{\draw[color=ColorSmallBox, semithick, fill] rectangle(.12,.12);}}
\setbeamertemplate{sections/subsections in toc}[square]

% The default option for enumerate environment removes the circles around the numbers provided by the "rounded" inner theme. Just simple numbers remain.
\setbeamertemplate{enumerate items}[default]
\setbeamerfont{enumerate item}{size=\small}

%%%%
%% Outer theme
\newcommand{\MedianLine}{%
\ifnum \insertpagenumber=1
\else
\raisebox{-15mm}[0pt][0pt]{%
\begin{pgfpicture}{0mm}{0mm}{0mm}{0mm}
\pgfsetlinewidth{3mm}
\color{ColorSmallBox}
\pgfline{\pgfpoint{-1cm}{0mm}}{\pgfpoint{-0.1cm}{0mm}}%
\pgfsetlinewidth{3mm}
\color{ColorBigBox}
\pgfline{\pgfpoint{0mm}{0mm}}{\pgfpoint{12cm}{0mm}}%
\end{pgfpicture}}
\fi}

% Include the line that we just created in the headline

% Now that we have changed the headline, we will need to orient the frame titles in a way that the come at the right stop just above the horizontal line.
\setbeamertemplate{frametitle}{
\vspace*{4mm}\hspace*{0mm}\insertframetitle \vspace*{1cm}}

%% Footline
\newcommand{\Ffootline}{%
\ifnum \insertpagenumber=1
\else
\insertmodulecode: \insertmoduleshortname % The left end of the footline
\hfill
\inserthandoutname~\inserttitle % The center
\hfill
\insertsection~~~~\insertframenumber % And the right end
\fi
}

\setbeamertemplate{footline}{%
\usebeamerfont{structure}
\Tiny\hspace*{4mm} \Ffootline \hspace{4mm}
\end{beamercolorbox}}

% We declare the image that will be used as the logo
%\pgfdeclareimage[width = 0.40\paperwidth]{big}{leeds_logo.png}

%% Title page
\setbeamertemplate{title page}{
%\begin{textblock*}{12cm}(6cm,-4.75cm)
%\colorbox{ColorBgCanvas}{%
%\begin{minipage}[t][3cm][b]{10cm}
%\pgfuseimage{big}
%\end{minipage}}
%\end{textblock*}

\begin{textblock*}{12cm}(2.15cm,1cm)
\colorbox{ColorBgCanvas}{%
\begin{minipage}[t][3cm][b]{10cm}
{\color{black}\Large\inserttitleverybigboxtext}
\end{minipage}}
\end{textblock*}

\begin{textblock*}{3cm}(-1cm,5cm)
\colorbox{ColorSmallBox}{%
\begin{minipage}[t][6mm][c]{2.75cm}
{\color{ColorSmallBoxText}\small\inserttitlesmallboxtext}
\end{minipage}}
\end{textblock*}

\begin{textblock*}{10cm}(2.15cm,5cm)
\colorbox{ColorBigBox}{%
\begin{minipage}[t][6mm][c]{10cm}
{\color{ColorBigBoxText}\small\inserttitlebigboxtext}
\end{minipage}}
\end{textblock*}
}

\mode
<all>

• Thank you very much. If you see that's what I am using now and demonstrating it with \vspace statements in the .tex file rather than the template... of course putting it in the template is universal and actually does not get affected when shrinking a frame. I was hoping if there was a more elegant solution that uses the margins, as that's what they are supposed to do, but certainly your suggestion is a valid one. +1 – John Smith Nov 22 '14 at 17:29
• That's exactly why I called this solution "quick and dirty" :) – user36296 Nov 24 '14 at 9:21