8

In the following MWE, I am trying to put the first frame as a list of todos over the whole presentation. However, I got an error

Undefined control sequence. \contentsline

So, what is wrong in this code?

\documentclass{beamer}
\usetheme{metropolis}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{todonotes}

\title{Title}
\author{Author}

\begin{document}

\begin{frame}{List of Todos}
    \listoftodos
\end{frame}

\maketitle

\begin{frame}{Table of contents}
    \setbeamertemplate{section in toc}[sections numbered]
    \tableofcontents[hideallsubsections]
\end{frame}

\section{Section 1}
\begin{frame}
    \todo[inline]{1st ToDo}
\end{frame}

\section{Section 2}
\begin{frame}
    \todo[inline]{2nd ToDo}
\end{frame}

\end{document}
1
  • 1
    It looks like \listoftodos is incompatible with beamer. Source.
    – thiagowfx
    Commented Sep 1, 2017 at 4:07

1 Answer 1

2

If you do not need all the features from todonotes you can simply implement some basic functionalities yourself:

\documentclass{beamer}
\usetheme{metropolis}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tcolorbox}

\newcounter{todo}
\newtcbox{\mytodobox}{colback=orange,colframe=orange!75!black}

\newcommand\todo[1]{%
    \refstepcounter{todo} 
    \mytodobox{\hypertarget{todo\thetodo}{#1}}
    \addcontentsline{tod}{subsection}{\protect\hyperlink{todo\thetodo}{\thetodo~#1}\par} 
}%

\makeatletter
\newcommand\listoftodos{%
    \@starttoc{tod}}
\makeatother

\title{Title}
\author{Author}

\begin{document}

    \begin{frame}{List of Todos}
        \listoftodos
    \end{frame}

    \maketitle

    \begin{frame}{Table of contents}
        \setbeamertemplate{section in toc}[sections numbered]
        \tableofcontents[hideallsubsections]
    \end{frame}

    \section{Section 1}
    \begin{frame}
        \todo{1nd ToDo}
    \end{frame}

    \section{Section 2}
    \begin{frame}
        \todo{2nd ToDo}
    \end{frame}

\end{document}

enter image description here

8
  • Many thanks for your answer. Is it possible to make the entries in this list hyperlinks (without color or frame around them) to the respective todos?
    – Diaa
    Commented Jun 7, 2016 at 22:30
  • 1
    @DiaaAbidou Sorry, but I am unable to do so. I tried \newcommand\todo[1]{% \refstepcounter{todo} \mytodobox{\hypertarget{todo\thetodo}{#1}} \addcontentsline{tod}{subsection}{\hyperlink{todo\thetodo}{\thetodo~#1}\par} }% but this just generates a bunch of errors.... too late at night to think about that. Commented Jun 8, 2016 at 0:27
  • I highly appreciate your willingness to help.
    – Diaa
    Commented Jun 8, 2016 at 0:31
  • 1
    @DiaaAbidou See the edit, its now clickable :) a simple \protect was missing. Commented Jun 8, 2016 at 15:28
  • 1
    @samcarter: Explicit \hyperlinks in \addcontentsline always require a \protect.
    – user31729
    Commented Jun 8, 2016 at 16:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .