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 red \tableofcontents from \part commands in Beamer, and it was very helpful. However, I wanted the part titles to be links pointing to the pages the part began. The example without this works just fine:

    \documentclass{beamer}
    \usepackage[T1]{fontenc}
    \usepackage[latin1]{inputenc}
    \usepackage[english]{babel}
    \usepackage{tikz}
    \usetikzlibrary{arrows,shapes,decorations.pathreplacing}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{kerkis}
    \usetheme{Darmstadt}

    \makeatletter
    \AtBeginPart{%
      \addtocontents{toc}{\protect\beamer@partintoc{\the\c@part}{\beamer@partnameshort}{\the\c@page}}%
    }
    %% number, shortname, page.
    \providecommand\beamer@partintoc[3]{%
      \ifnum\c@tocdepth=-1\relax
        % requesting onlyparts.
        \makebox[6em]{Part #1:} #2
        \par
      \fi
    }
    \define@key{beamertoc}{onlyparts}[]{%
      \c@tocdepth=-1\relax
    }
    \makeatother%

    \begin{document}

    \title[Short Title]{Long Title}
    \subtitle[Short Subtitle]{Long Subtitle}
    \date{\today}
    \author{Tom B.}
    \subject{Math. Questions.}

    \begin{frame}[t]
        \titlepage
    \end{frame}

    \begin{frame}[t]
        \frametitle{Overview}
        \tableofcontents[onlyparts]
    \end{frame}

        \part{Beginners}

    \begin{frame}[t,shrink=0]
        \frametitle{\insertpart}
        \tableofcontents[subsectionstyle=hide]
    \end{frame}

            \section[Nat Num]{Natural Numbers}

    \begin{frame}[t]
        \frametitle{\insertsection}
        \tableofcontents[sectionstyle={show/hide}]
    \end{frame}

                \subsection{Add}

    \frame{easy example for calculating with natural numbers...}

                \subsection{Subtract}

    \frame{easy example for calculating with natural numbers...}            

    \end{document}

I thought I just use \ref and \label to achieve this. So I changed one line:

\makebox[6em]{Part #1:} \ref{#2}

And I added one other after the \part command (and I thought about using \AtBeginPart for automation):

\part{Beginners}
\label{\insertpart}

But if I compile this (MikTeX 2.9, pdfTeX 3.1415926-1.40.11), I get 74 errors. Could anyone be so kind to explain to me why, and even better, tell me how to fix it, or provide an alternative to achieve linked parts?

Edit: Hmm, the problem appears to be \includepart. When I use

\makebox[6em]{Part #1:} \textcolor{green!30!blue}{\hyperlink{#2}{#2}}

and

\frame{\partpage \hypertarget{Beginners}{}}

instead it works. As I don't intend to put lots of parts, it is not too much of a pain to set them manually, but it is not very neat. Also, it seems to clash whenever I use \insertpart. The beamer manual states that it is a useful command for \partpage, so probably you can only use \insertpage when redefining \partpage?

share|improve this question
add comment

2 Answers

Would this solution be ok?

\begin{frame}
\frametitle{Outline}
\tableofcontents
\tableofcontents[part=1]
\tableofcontents[part=2]
%....
\end{frame}
share|improve this answer
add comment
up vote 0 down vote accepted

Ok, I got it, it was not that involving after all:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usetheme{Darmstadt}
\usepackage{hyperref}

\makeatletter
\AtBeginPart{%
  \addtocontents{toc}{\protect\beamer@partintoc{\the\c@part}{\beamer@partnameshort}{\the\c@page}}%
}
%% number, shortname, page.
\providecommand\beamer@partintoc[3]{%
  \ifnum\c@tocdepth=-1\relax
    % requesting onlyparts.
    \makebox[6em]{Part #1:} \textcolor{green!30!blue}{\hyperlink{#2}{#2}}
    \par
  \fi
}
\define@key{beamertoc}{onlyparts}[]{%
  \c@tocdepth=-1\relax
}
\makeatother%

\newcommand{\nameofthepart}{}
\newcommand{\nupart}[1]%
    {   \part{#1}%
        \renewcommand{\nameofthepart}{#1}%
        \frame{\partpage \hypertarget{\nameofthepart}{}}%
    }

\begin{document}

 \title[Short Title]{Long Title}
    \subtitle[Short Subtitle]{Long Subtitle}
    \date{\today}
    \author{Tom B.}
    \subject{Math. Questions.}

\begin{frame}[t]
    \titlepage
\end{frame}

\begin{frame}[t]
    \frametitle{Overview}
    \tableofcontents[onlyparts]
\end{frame}

    \nupart{Beginners}

    \nupart{Advanced}

    \nupart{Pros}
\end{document}

Basically all I had to do was creating a \nupart command that provides a macro containing the chapter name at a later point. It also automatically inserts the hyperlink, so the linking is achieved by simply using \nupart instead of \part.

share|improve this answer
add comment

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.