自定义模板中的投影仪边距

自定义模板中的投影仪边距

我制作了一个 beamer 模板,我想从模板本身更改边距,尤其是主体块的边距。我从另一篇文章中读到了 \voffset 和所有其他边距,我试过了,但它们不起作用,因为它们也会将标题向下推。此外,由于边距的原因,使用 shrink 也会失败。我可以在 tex 文件的框架内使用 \vspace,但在我看来,这并不优雅,也不是一个很好的解决方案。

找到下面的模板文件(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>

以及使用它并演示问题的最小示例:

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

答案1

\vspace{}一个快速而肮脏的解决方案是在框架标题后添加一个

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

在此处输入图片描述

完整代码:

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

相关内容