Beamer:绘制一个不覆盖导航栏的矩形

Beamer:绘制一个不覆盖导航栏的矩形

我试图在半个幻灯片空间上绘制一个蓝色填充的矩形。但是,我不希望它覆盖导航栏。下图说明了当前的情况:

标题页

在此处输入图片描述

第一部分的第一张幻灯片。我希望导航栏出现在这张幻灯片中。

我希望导航栏出现在这张幻灯片中。

第一部分的内容

在此处输入图片描述

以下是此案例的 MWE

    \documentclass{beamer}

% To make the navigation bullets appear
\usepackage{remreset}
\makeatletter
    \@removefromreset{subsection}{section}
\makeatother
\setcounter{subsection}{1}

\useoutertheme[subsection=false]{smoothbars}
\setbeamercolor{section in head/foot}{fg=white, bg=black}
\setbeamertemplate{section in head/foot shaded}{\color{white!50!black}\insertsectionhead}

\setbeamertemplate{frametitle}[default][colsep=-4bp,rounded=false,shadow=false]


\setbeamercolor{frametitle}{fg=white,bg=blue}

\setbeamercovered{transparent}
\setbeamertemplate{navigation symbols}{} %remove navigation symbols
\setbeamercovered{invisible} %No transparent layers

\usepackage{tikz}
\usepackage{pdfrender}

\title{My Presentation}
\author[My short name]{\bfseries My name}
\institute{University}
\date[19/05/15]{\today}

\begin{document}
{   
\setbeamertemplate{section in head/foot shaded}[default][100]
\frame{ % This is the title slide where I'd like to highlight the sections
  \frametitle{}
  \setbeamertemplate{footline}{} 
  \maketitle  
}
}

\section{First section}
    {
    \setbeamertemplate{footline}{}
    \frame{
        \begin{tikzpicture}[remember picture,overlay]
\fill[blue]
  ([yshift=0pt]current page.west) rectangle (current page.north east);
\node[anchor=center]
  at ([yshift=10pt,xshift=0pt]current page.center) 
  {\parbox[t]{\textwidth}{\centering%
 \usebeamerfont{author}\textcolor{white}{%
    \textpdfrender{
    TextRenderingMode=FillStroke,
    FillColor=white,
    LineWidth=.1ex,
    }{\insertsection}}}};
\end{tikzpicture}
\addtocounter{framenumber}{-1}
    }
    }
    \frame{\frametitle{My Frame Title}}\frame{}

\section{Second section}
{
    \setbeamertemplate{footline}{}
    \frame{
        \begin{tikzpicture}[remember picture,overlay]
\fill[blue]
  ([yshift=0pt]current page.west) rectangle (current page.north east);
\node[anchor=center]
  at ([yshift=10pt,xshift=0pt]current page.center) 
  {\parbox[t]{\textwidth}{\centering%
 \usebeamerfont{author}\textcolor{white}{%
    \textpdfrender{
    TextRenderingMode=FillStroke,
    FillColor=white,
    LineWidth=.1ex,
    }{\insertsection}}}};
\end{tikzpicture}
\addtocounter{framenumber}{-1}
    }
    }
    \frame{}\frame{}\frame{}

\section{Third section}
{
    \setbeamertemplate{footline}{}
    \frame{
        \begin{tikzpicture}[remember picture,overlay]
\fill[blue]
  ([yshift=0pt]current page.west) rectangle (current page.north east);
\node[anchor=center]
  at ([yshift=10pt,xshift=0pt]current page.center) 
  {\parbox[t]{\textwidth}{\centering%
 \usebeamerfont{author}\textcolor{white}{%
    \textpdfrender{
    TextRenderingMode=FillStroke,
    FillColor=white,
    LineWidth=.1ex,
    }{\insertsection}}}};
\end{tikzpicture}
\addtocounter{framenumber}{-1}
    }
    }\frame{}\frame{}\frame{}

\section{Conclusion}
\frame{}
\end{document}

有人知道这种情况下该如何处理吗?

最好的,温贝托

答案1

为了不让矩形覆盖幻灯片上的标题,您可以yshift=-\headheight向矩形添加一个。第一部分中的代码将如下所示:

\section{First section}
    {
    \setbeamertemplate{footline}{}
    \frame{
        \begin{tikzpicture}[remember picture,overlay]
\fill[blue]
  ([yshift=0pt]current page.west) rectangle ([yshift=-\headheight]current page.north east);
\node[anchor=center]
  at ([yshift=10pt,xshift=0pt]current page.center) 
  {\parbox[t]{\textwidth}{\centering%
 \usebeamerfont{author}\textcolor{white}{%
    \textpdfrender{
    TextRenderingMode=FillStroke,
    FillColor=white,
    LineWidth=.1ex,
    }{\insertsection}}}};
\end{tikzpicture}
\addtocounter{framenumber}{-1}
    }
    }

这会将矩形的顶部向下移动并露出标题。这是我使用该代码得到的结果:

蓝框移位示例

答案2

如果您希望矩形仅显示在section框架上,您可以使用\AtBeginSection定义如何定义部分框架的命令。

由于矩形覆盖了标题,因此您可以将background绘制的矩形放置在标题之前。

这样,您就不必为每个部分页面插入代码。

在下面的代码中,请注意从\setbeamertemplate{background}到命令\end{frame}内部的行\AtBeginSection被插入到本地范围{ }。否则,背景将在所有框架中使用。

也许更好的解决方案是定义一个新的背景,\defbeamertemplate然后在\usebeamertemplate里面调用它\AtBeginSection,但我不知道该怎么做。

\documentclass{beamer}

% To make the navigation bullets appear
\usepackage{remreset}
\makeatletter
    \@removefromreset{subsection}{section}
\makeatother
\setcounter{subsection}{1}

\useoutertheme[subsection=false]{smoothbars}
\setbeamercolor{section in head/foot}{fg=white, bg=black}
\setbeamertemplate{section in head/foot shaded}{\color{white!50!black}\insertsectionhead}

\setbeamertemplate{frametitle}[default][colsep=-4bp,rounded=false,shadow=false]


\setbeamercolor{frametitle}{fg=white,bg=blue}

\setbeamercovered{transparent}
\setbeamertemplate{navigation symbols}{} %remove navigation symbols
\setbeamercovered{invisible} %No transparent layers

\AtBeginSection[]{%
    {\setbeamertemplate{background}{
    \begin{tikzpicture}[remember picture,overlay]
    \fill[blue]
        ([yshift=0pt]current page.west) rectangle (current page.north east);
    \node[anchor=center]
        at ([yshift=10pt,xshift=0pt]current page.center) 
        {\parbox[t]{\textwidth}{\centering%
            \usebeamerfont{author}\textcolor{white}{%
                    \textpdfrender{
                        TextRenderingMode=FillStroke,
                        FillColor=white,
                        LineWidth=.1ex,
                    }{\insertsection}}}};
    \end{tikzpicture}}
    \begin{frame}
    \end{frame}}
    \addtocounter{framenumber}{-1}
}

\usepackage{tikz}
\usepackage{pdfrender}

\title{My Presentation}
\author[My short name]{\bfseries My name}
\institute{University}
\date[19/05/15]{\today}

\begin{document}
{   
\setbeamertemplate{section in head/foot shaded}[default][100]
\frame{ % This is the title slide where I'd like to highlight the sections
  \frametitle{}
  \setbeamertemplate{footline}{} 
  \maketitle  
}
}

\section{First section}

\frame{\frametitle{My Frame Title}}
\frame{}\frame{}

\section{Second section}
\frame{}\frame{}\frame{}

\section{Third section}
\frame{}\frame{}\frame{}

\section{Conclusion}
\frame{}
\end{document}

在此处输入图片描述

第二版:\defbeamertemplate

现在我明白了如何使用\defbeamertemplate。此命令用于定义模板并为其指定名称以供进一步引用。

在前面的代码中,\AtBeginSection可以替换为:

\defbeamertemplate{background}{blue half}{
    \begin{tikzpicture}[remember picture,overlay]
    \fill[blue]
        ([yshift=0pt]current page.west) rectangle (current page.north east);
    \node[anchor=center]
        at ([yshift=10pt,xshift=0pt]current page.center) 
        {\parbox[t]{\textwidth}{\centering%
            \usebeamerfont{author}\textcolor{white}{%
                    \textpdfrender{
                        TextRenderingMode=FillStroke,
                        FillColor=white,
                        LineWidth=.1ex,
                    }{\insertsection}}}};
    \end{tikzpicture}}

\AtBeginSection[]{%
    {\setbeamertemplate{background}[blue half]
    \begin{frame}
    \end{frame}
    \addtocounter{framenumber}{-1}}
}

其中,为called\defbeamertemplate{background}{blue half}{...}定义了一个模板,稍后将在with 中使用。请注意引入 name 以及在help中本地应用更改。backgorundblue half\AtBeginSection\setbeamertemplate{background}[blue half][]{...}

相关内容