Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am currently struggling to create fancy-looking section pages in Beamer to achieve the following layout:

section

Based on my question on the matching TOC (fancy-table-of-contents-for-beamer) I came up with the following code which does not look so bad but does to really resemble the given layout. Any idea how to improve the code?

\documentclass[svgnames]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\pgfdeclarehorizontalshading{section shading}{2cm}{
color(0cm)=(LightSlateGrey!15);
color(3cm)=(LightSlateGrey)
}
\pgfdeclarehorizontalshading{subsection shading}{2cm}{
color(0cm)=(red!15);
color(1cm)=(red);
color(3cm)=(green)
}

\usepackage{tikz}
\tikzset{section number/.style={
    draw=none,
    rectangle,    
    left color=gray!40,
    right color=gray!20!black,
    minimum size=3.5em,
    text=white,
  },
  section/.style={
    draw=none,
    rectangle,    
    shading=section shading,
    minimum height=3.5em,
    minimum width=0.9\textwidth,
    text width=0.9\textwidth,
    text=black,
    align=left
  },
  subsection/.style={
    draw=none,
    rectangle,    
    shading=subsection shading,
    minimum height=2em,
    minimum width=0.9\textwidth,
    text width=0.9\textwidth,
    text=black,
    align=left
  }
}

\begin{document}

\frame{

\begin{tabular}{p{1.2cm}p{9cm}} 
\tikz[baseline=-0.5ex]\node[section number]{\bfseries\Large 123}; & \tikz[baseline=-0.5ex]\node[section]{\bfseries\large fxdfsdf}; \\ & \\
& \tikz[baseline=-0.5ex]\node[subsection]{\bfseries fxdfsdf};
\end{tabular}

}

\end{document}

mycode

share|improve this question

1 Answer 1

up vote 8 down vote accepted

Here's one possibility; the section frames are automatically created using \AtBeginSection. I used your colors and shadings, but you can change them easily (and, of course, feel free to make any other changes, according to your needs):

\documentclass[svgnames]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,shadings}

\pgfdeclarehorizontalshading{section shading}{2cm}{
color(0cm)=(LightSlateGrey!15);
color(3cm)=(LightSlateGrey)
}
\pgfdeclarehorizontalshading{subsection shading}{2cm}{
color(0cm)=(red!15);
color(1cm)=(red);
color(3cm)=(green)
}

\tikzset{section number/.style={
    inner sep=0pt,
    draw=none,
    rectangle,    
    left color=gray!40,
    right color=gray!20!black,
    minimum size=3.5em,
    text=white,
    text width=3.5em,
   align=center
  },
  section/.style={
    inner sep=0pt,
    draw=none,
    rectangle,    
    shading=section shading,
    minimum height=3.5em,
    minimum width=0.9\textwidth,
    text width=\the\dimexpr\paperwidth-3.8em\relax,
    text=black,
    align=left
  },
  subsection/.style={
    inner sep=0pt,
    draw=none,
    rectangle,    
    shading=subsection shading,
    minimum height=2em,
    minimum width=0.9\textwidth,
    text width=\the\dimexpr\paperwidth-3.8em\relax,
    text=black,
    align=left
  }
}

\makeatletter
\def\sectionsubtitle#1{\gdef\@sectionsubtitle{#1}}
\AtBeginSection[]{%
\begingroup
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}[remember picture,overlay]
\fill[gray!10] (current page.north west) rectangle (current page.south east);
\fill[left color=red!40,right color=green!15] 
  ( $ (current page.north west) + (0pt,-80pt) $ ) -- 
  ( $ (current page.north west) + (80pt,0pt) $ ) --
  ( $ (current page.north west) + (300pt,0pt) $ ) --
  ( $ (current page.north west) + (0pt,-300pt) $ ) -- 
  cycle;
\fill[left color=LightSlateGrey!40,right color=LightSlateGrey!05] 
  ( $ (current page.north west) + (300pt,0pt) $ ) -- 
  ( $ (current page.north west) + (500pt,0pt) $ ) --
  ( $ (current page.north west) + (0pt,-500pt) $ ) --
  ( $ (current page.north west) + (0pt,-300pt) $ ) -- 
  cycle;
\end{tikzpicture}
}
\begin{frame}
\begin{tikzpicture}[remember picture,overlay]
\node[section number,anchor=west] at (current page.west) {\fontsize{30}{36}\selectfont\two@digits\thesection}; 
\node[section,anchor=east] at (current page.east) (title) 
  {\hfill\parbox[c][3.5em][c]{\the\dimexpr\paperwidth-4.2em\relax}{\fontsize{20}{20}\selectfont\insertsectionhead}\hfill}; 
\node[subsection,below= 2pt of title]  (subtitle) 
  {\hfill\parbox[c][2em][c]{\the\dimexpr\paperwidth-4.2em\relax}{\@sectionsubtitle}\hfill}; 
\end{tikzpicture}
\end{frame}
\gdef\@sectionsubtitle{}
\endgroup
}
\makeatother

\begin{document}

\sectionsubtitle{Test Subtitle One}
\section{Test Section One}
\begin{frame}
Test Frame
\end{frame}

\sectionsubtitle{Test Subtitle Two}
\section{Test Section Two}
\begin{frame}
Test Frame
\end{frame}

\end{document}

enter image description here

All you have to do is to use \sectionsubtitle before each \section command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.