[Tex/LaTex] beamer margins in custom template

beamermarginstemplates

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
%\headsep=2cm
%\headheight=3cm

\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{headline}[text line]{\MedianLine}

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

Best Answer

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

enter image description here

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
%\headsep=2cm
%\headheight=3cm

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

% In case you choose to display the Table of Contents, or the Outline slide.
\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}

% Alert block
\setbeamercolor{block title alerted}{bg=ColorSmallBox, fg=ColorSmallBoxText}
\setbeamercolor{block body alerted}{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
\setbeamertemplate{headline}[text line]{\MedianLine}


% 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}
\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex]{title in head/foot}%
\Tiny\hspace*{4mm} \Ffootline \hspace{4mm}
\end{beamercolorbox}}


%% Remove the navigation symbols
\setbeamertemplate{navigation symbols}{}


% 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>
Related Question