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.

My presentation consist of multiple sections. Some sections consist of subsection and some not. I want beamer to display the TOC before every subsection and before every section which consists of no other subsection.

Currently, i write in the preamble:

\AtBeginSection[] {
    \begin{frame}<beamer>
    \frametitle{Inhalt} %
    \tableofcontents[currentsection]  
    \end{frame}
}

\AtBeginSubsection[] {
    \begin{frame}<beamer>
    \frametitle{Inhalt} %
    \tableofcontents[currentsubsection]  
    \end{frame}
}

As a result, if a section consist of subsecitons beamer displays the TOC twice before the first subsection in a section, one time for the section and one time for the subsection. That is ugly in my opinion. What can i do?

share|improve this question
    
Duplicate question stackoverflow.com/questions/2795478/… –  Julian Dec 7 '12 at 11:29
add comment

1 Answer 1

You can very simply use TeX conditionals. The only drawback (or feature) is that for section with subsections, in the first ToC does not "shade" the latter subsections. Basically, we tell LaTeX: At section, make ToC and remember false. At subsection, if you see true make ToC, and remember true.

\documentclass{beamer}

\newif\iflattersubsect

\AtBeginSection[] {
    \begin{frame}<beamer>
    \frametitle{Inhalt} %
    \tableofcontents[currentsection]  
    \end{frame}
    \lattersubsectfalse
}

\AtBeginSubsection[] {
    \iflattersubsect
    \begin{frame}<beamer>
    \frametitle{Inhalt} %
    \tableofcontents[currentsubsection]  
    \end{frame}
    \fi
    \lattersubsecttrue
}

\title{TITLE}
\author{AUTHOR}

\begin{document}

\begin{frame}\maketitle\end{frame}

\section{SECT I}
\subsection{I.1}
\begin{frame}I.1\end{frame}

\subsection{I.2}
\begin{frame}I.2\end{frame}

\section{SECT II}
\begin{frame}II frame 1\end{frame}
\begin{frame}II frame 2\end{frame}

\section{SECT III}
\subsection{III.1}
\begin{frame}III.1\end{frame}

\subsection{III.2}
\begin{frame}III.2\end{frame}

\end{document}
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.