I am trying to use inline todo notes from the todonotes
package inside figure captions. However I get the following error when I generate the listoffigures
.
! Leaders not followed by proper glue.
<to be read again>
\hfill
l.2 ...inline]{A note in a float}}}{8}{figure.1.1}
I find this strange since the docs say this is one of the intended use cases for inline todo notes (see pg.6)!
Here is my MWE TeX file:
\documentclass[11pt,a4paper,draft,twoside]{scrbook}
\usepackage{fixltx2e}
\usepackage{fontspec}
\usepackage{libertine}
\usepackage{microtype}
\usepackage{graphicx}
\usepackage{float}
\usepackage[backgroundcolor=green!40,textsize=scriptsize,obeyFinal]{todonotes}
\author{Suvayu}
\date{\today}
\title{Title}
\usepackage[draft=false,bookmarks]{hyperref}
\hypersetup{
% hidelinks,
colorlinks,
pagebackref,
linkcolor=black,
}
\usepackage{bookmark} % smarter bookmarks
\begin{document}
\maketitle
\clearpage\null\newpage
\setcounter{tocdepth}{3}
\addcontentsline{toc}{chapter}{\contentsname}
\tableofcontents
\newpage
\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
%% Chapter 1
\chapter{What is the answer to the ultimate question?}
The answer is 42!\todo[inline]{A note \emph{not} in a float}
\begin{figure}[htb]
\centering
\includegraphics[width=\textwidth]{graphics/timelt2ps_hMom_Pt___hMom_Eta___hIPchi2_time.pdf}
\caption{Why 42, and not 43? \todo[inline]{A note in a float}}
\end{figure}
\end{document}
Unfortunately I do not know what is the custom when it comes to included graphics files in MWEs, so I left it out. I guess including any pdf would do.
Some observations:
- when I remove the
\listoffigures
, the error goes away, - when I add a short caption with
\caption[short]{long \todo[inline]{note}}
then the error seems to go away again.
So I guess the problem comes from typesetting the listoffigures
. For the moment I have a workaround, but I would like to understand what is going wrong, and how to resolve similar issues in the future. I'm particularly interested since my search for ! Leaders not followed by proper glue.
led to this page; it makes me even more curious!
Best Answer
First I reduced the provided example a bit more, until it was closer to a minimal working example (MWE)
Then the problem was identified as trying to draw the inserted todonote in the list of figures, where it is not allowed to draw such things.
There are two ways of inserting todonotes in captions. The one I prefer is the following where the todonote is placed outside of the caption.
An alternative approach is to specify a text for the list of figures without the todonote.
Both approaches are given in the example below.