Thursday, February 5, 2009

Todonotes

In July the first version of the todonotes package were uploaded to the CTAN network [1]. After that I have received several requests for improvements, some have already been addressed and others are waiting to get time for implementing. To secure the source of the package I have started to use the github.com service, which allow open source projects to get free source code version control using the git software. The repository can be found at [2].

Best
Henrik

[1] http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/todonotes.html
[2] http://github.com/henrikmidtiby/todonotes/tree/master

29 comments:

somebody said...

Hej,

very nice package. However, I've found two bugs:


1. The baseline skip isn't changed according to the size commands if there is no \par token in the note text. (TeX always applies the baseline skip that is active when the \par token is inserted.) Solution: simply insert a \par token in the \todo command—two consecutive \par tokens do no harm. For example, change \renewcommand{\@todonotes@text}{#2}% in line 1042 of the dtx file to \renewcommand{\@todonotes@text}{#2\par}%. Compare:

\documentclass{article}
\usepackage[textsize=tiny]{todonotes}

\begin{document}

\todo{Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.}

\todo{Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\par}

\end{document}


2. \listoftodos should insert a chapter* when \chapter is not undefined and a \section* otherwise, like \listoffigures and the like.

Unknown said...

Hello

I have trouble with the margin when I try to use a4 paper size. With a4 paper the note appear very close to the edge. With a5 paper the note appear partly outside of the paper. Here is a simple test with a5.

\documentclass[a5paper]{article}
\usepackage{hyperref}
\usepackage[colorinlistoftodos, textwidth=4cm, shadow]{todonotes}
%\usepackage{todonotes}

\begin{document}
\todo[noline]{Please stay inside of my sheet!}
\end{document}

And a screenshoot
http://ltgustavsen.googlepages.com/todotest.png

Sorry if this is just a simple user error.

outcast_batgirl said...

Hi,

I spent an age googling in an effort to find a package like yours and am very happy now that I have. I do have a problem with the position of the notes though. I'm using a class written for theses that is double sided and ready for binding, so odd pages have wide left margins and even pages have wide right margins. Unfortunately, the notes appear on the narrow margin sides - I can see notes on odd numbered pages if I make textwidth small but on even pages I can only see the edge of the note box. NB The smaller I make textwidth, the further the notes on even pages get pushed off the left hand side of the page.

Is there an option I can use to correct this?

outcast_batgirl said...

In case it helps, this is the class file I'm using. Sorry it's a bit long.

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{bristolthesis}[2006/05/18 ALPHA]

% Base everything on the report style
\LoadClassWithOptions{report}

% Set margins to 40mm on the binding side and 25mm on all other sides
\setlength{\oddsidemargin}{14.6mm}
\setlength{\evensidemargin}{-0.4mm}
\setlength{\topmargin}{-0.4mm}
\setlength{\headheight}{5mm}
\setlength{\headsep}{7mm}
\setlength{\footskip}{12mm}
\setlength{\textwidth}{145mm}
\setlength{\textheight}{223mm}

% Allow some space between paragraphs so that
\setlength{\parskip}{1.5ex plus 1ex minus 1ex}

% Be very generous on the figures at the top
\renewcommand{\topfraction}{0.9}

% A command to get the date in English format
\renewcommand*{\today}{\number\day\ifcase\day%
\or{st}\or{nd}\or{rd}\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}%
\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}%
\or{st}\or{nd}\or{rd}\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}\or{th}\or{st}\fi%
\space\ifcase\month\or January\or February\or March\or April\or May\or%
June\or July\or August\or September\or October\or November\or December\fi%
\space\number\year}

% Load the package to do the line spacing correctly
\usepackage{setspace}
\newcommand{\defaultspacing}{\onehalfspacing}
%\newcommand{\defaultspacing}{\doublespacing}
\defaultspacing

% Environment for the abstract, acknowledgements, etc
\newenvironment{blankpage}[1][]
{%
\newpage
\thispagestyle{empty}%
\setcounter{page}\@ne
\if\noexpand#1\@empty
\else
\centerline{\textbf{#1}}\vspace{\baselineskip}
\fi
}%
{%
\clearemptydoublepage
\setcounter{page}\@ne
}

% Get all the required information for the header
\newcommand{\headercontents}{}

% Set the header
\newcommand*{\ps@thesisheader}{%
\renewcommand*{\@oddhead}{%
\begin{minipage}{\textwidth}\normalfont%
\textbf{\headercontents}%
\end{minipage}%
}%
\renewcommand*{\@evenhead}{%
\begin{minipage}{\textwidth}\normalfont%
\textbf{\@title \hfill \@author}%
\end{minipage}%
}%
\renewcommand*{\@oddfoot}{%
\begin{minipage}{\textwidth}\normalfont%
\centerline{\thepage}%
\end{minipage}%
}%
\renewcommand*{\@evenfoot}{\@oddfoot}%
\def\chaptermark##1{%
\renewcommand{\headercontents}{\chaptername\ \thechapter\hfill ##1}%
}%
}
\pagestyle{thesisheader}

% Create an empty page with no headings
\newcommand{\clearemptydoublepage}{\newpage{\thispagestyle{empty}\cleardoublepage}}

% Redefine the chapter headings so that they aren't so large
% (copied and changed from report.cls)
\def\@makechapterhead#1{%
\vspace*{30\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\Large\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 10\p@
\fi
\interlinepenalty\@M
\LARGE \bfseries #1\par\nobreak
\vskip 40\p@
}}
\def\@makeschapterhead#1{%
\vspace*{30\p@}%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\LARGE \bfseries #1\par\nobreak
\vskip 40\p@
}}

% Redefine the figure caption to be indented (taken from iopart.cls from IOP)
\newdimen\captionindent
\captionindent = 4pc
\newenvironment{indented}{\begin{indented}}{\end{indented}}
\def\indented{
\list{}{
\itemsep=0\p@
\labelsep=0\p@
\itemindent=0\p@
\labelwidth=0\p@
\leftmargin=\captionindent
\topsep=0\p@
\partopsep=0\p@
\parsep=0\p@
\listparindent=15\p@
}
\small%\footnotesize
\rm
\defaultspacing
}
\let\endindented=\endlist
%\newlength\abovecaptionskip
%\newlength\belowcaptionskip
\setlength\abovecaptionskip{10\p@}
\setlength\belowcaptionskip{0\p@}
\long\def\@caption#1[#2]#3{
\par
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup
\@parboxrestore
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}
\par
\endgroup
}
\long\def\@makecaption#1#2{
\vskip\abovecaptionskip
\begin{indented}
\item[]{\bf #1.} #2
\end{indented}
\vskip\belowcaptionskip
}

% Thick rule lines for tables
\setlength\arrayrulewidth{.5\p@}
\def\Hline{%
\noalign{\ifnum0=`}\fi\hrule \@height 3\arrayrulewidth \futurelet
\@tempa\@xhline}

Patrick said...

Hi Henryk,

you know how much I like your package!

An idea: to number the todonotes automatically, much like you would number equations, adding a number in the top-right corner (say).

Purpose: to ease communication in multiple-author papers, e.g. "what do you mean in todonote 52?"

keep the good work!

cheers,

Patrick.

Henrik Skov Midtiby said...

# Patrick

Hi

It is possible to create a new command based on the todo command, which automatically inserts a todo number in the inserted todonotes.

\newcounter{todocounter}
\newcommand{\todotwo}[2][]
{\stepcounter{todocounter}\todo[#1]{\thetodocounter: #2}}

Does this solve your problem?

Best regards
Henrik

Patrick said...

oh yes absolutely, your method is perfect, why not mention it in the help document? very useful,

I'll start using it immediately!

thanks a lot Henrik

Patrick

Vitaly said...

Hi everybody (who likes todonotes)!
If you have some original way of using todonotes or you can suggest some cool tips of it's usage, please share your experience on github todonotes wiki here:

http://wiki.github.com/henrikmidtiby/todonotes

All this stuff will be in one place.

Henrik Skov Midtiby said...

# Vitaly
Good idea to collect use cases of the todonotes package in the wiki at github.

May I include your example in the documentation?

Vitaly said...

#Henrik

Oh yes absolutely, include it (very pleased to me)!

And what do you think about sorting list of todo notes? Would it be very difficult to implement? I'm very new to LaTeX so I even don't have an idea how to do it...

Henrik Skov Midtiby said...

Hi Vitaly

Sorry for not answering for a while, but I have been busy with my daytime work...

> And what do you think about sorting
> list of todo notes? Would it be very
> difficult to implement? I'm very new to
> LaTeX so I even don't have an idea how
> to do it...
The idea of sorting the listoftodos according to some arbitrary value (due date, priority, ...) is very attractive to me.
In principle [1] it should be possible to do in pure (la)tex, but currently I do not have the skills.

Best
Henrik

[1] http://www.ntg.nl/maps/14/43.pdf

Anonymous said...

Hi!
I find this package very useful. I have a problem when it's interacting with the geometry package and the book class, though: On odd pages, the note is sticking very close to the boundary, while on even pages it is actually partly outside the page. Here is a very simple sample code:

\documentclass[11pt,a4paper]{book}
\usepackage[a4paper,pdftex,textwidth=15cm]{geometry}
\usepackage[shadow]{todonotes}

\begin{document}
\todo{Just a simple test to see whether the note is gonna stay on the page...}
\newpage
\todo{Just a simple test to see whether the note is gonna stay on the page...}
\end{document}

Henrik Skov Midtiby said...

Hi CP

For some reason does the geometry package not set the proper length of \marginparwidth

The following example works for me

Henrik

\documentclass[11pt,a4paper]{book}
\usepackage[a4paper,pdftex,textwidth=15cm]{geometry}
\usepackage[shadow]{todonotes}
\setlength{\marginparwidth}{3cm}

\begin{document}
\todo{Just a simple test to see whether the note is gonna stay on the page...}
\newpage
\todo{Just a simple test to see whether the note is gonna stay on the page...}
\end{document}

Anonymous said...

It works perfectly. Thanks!!!

Manduca said...

Hi Henrik -

Todonotes is terrific - I think I've implemented nearly every suggestion in the documentation too. Thank you for including those.

I have a question that might not be asked by someone with better LaTeX skills: is there a way to prefix the comment text with a reference to the chapter (or section) name or number? It would be useful for the big list of to do's that I print out at the front of the document.

As an aside: I find that even when I use the disable option, i get some problems with spacing. I think this is inevitable: some of my to do notes are at the end of sentence. I also get an error when I typeset with all of the todo notes and all of my figures. To handle these cases, I've worked up a regular expression to create a duplicate document that omits all the todo notes and associated extra spaces.

cat thesis.tex | sed s'/\\todo{[^\]*}//g' | sed 's/ ././g' >no_to_do_thesis.txt

this removes all todo codes and notes. it then removes any instances of a space before a period. caveat scriptor: if you have any decimal numbers that aren't prefixed with zero (like .25) this will mess that formatting up.

other todo type notes can be chained in as well:

cat thesis.tex | sed s'/\\todo{[^\]*}//g' | sed s'/\\missingfigure{[^\]*}//g' | sed 's/ ././g' >no_to_do_thesis.txt

thanks again for this great LaTeX package!

ms

Henrik Skov Midtiby said...

# Manduca
Hi

>> I have a question that might not be asked by someone with better LaTeX skills: is there a way to prefix the comment text with a reference to the chapter (or section) name or number?

This can be achieved using the following code:

\newcommand{\ntodo}[2][]{\todo[#1]{\thesection. #2}}

which defines a new command \ntodo, in which the inserted notes are prepended with the section number.


Regarding your comment about the disable option. I know about the issue, but unfortunately have I no idea of how to get rid of it...

Best
Henrik

Manduca said...

Hi Henrick -

Thanks for your quick answers! I now have a monster command for todo notes:

\newcommand{\sstodo}[2][]
{\addtocounter{todoListItems}{1}
\todo[caption={\protect\hypertarget{todo\thetodoListItems}{}\thesection. #2}, #1]
{\begin{spacing}{1} \hfill \hyperlink{todo\thetodoListItems}{#2} \end{spacing} }}

it links back and forward between the list of todos, is single spaced, and only the entries in the list of todos include the reference to the section number.

i'm perfectly happy with the sed solution to the disable problem.

Tim said...

This package is JUST what I was looking for, thanks!!

I'd love to see the Todo list hyperlinked with something like this http://dsanta.users.ch/resources/hyperref.html

Henrik Skov Midtiby said...

# Tim

The todonotes package can already utilize the functionality of hyperref.

When the hyperref package is loaded before the todonotes package. The entries in the list of todos are links to the inserted todo notes.

It works for me using pdflatex on the following small document.

\documentclass{article}
\usepackage{hyperref}
\usepackage{todonotes}
\begin{document}
\listoftodos
\newpage
\section{Hey}
\todo{One}
\newpage
\section{Hey again}
\todo{Two}
\end{document}

Best regrads,
Henrik Skov Midtiby

vince said...

Hi Im using this nice package to highlight paragraphs by following commands:


\usepackage[bordercolor=white,backgroundcolor=gray!30,linecolor=black,colorinlistoftodos,textwidth=\textwidth]{todonotes}


\newcommand{\rework}[1]{\todo[color=yellow,inline]{#1}}

and then \rework{blah blah blah}.

However, the text in the highlighted box is not justified anymore and it appears as if it becomes left-justified.

Could you hint what can be done to fix this.

Cheers,

Henrik Skov Midtiby said...

Hi Vince

Currently are there no options for setting the justification of the inserted text.

The text is drawn with the tikz package in a "node".
If you supply the option "align=justify" to the node, the text should be justified.
See this example [1].

This should be changed in the todonotes.sty file close to where the @todo command is defined.

Best regards,
Henrik

[1] http://www.texample.net/tikz/examples/polarizing-microscope/

Patrick Toche said...

been using todonotes for years now, great productivity tool.

many thanks.

I couldn't get verbatim to work inside a todonote, can it be made to work?

something like this:

\usepackage{todonotes}
\usepackage{verbatim}

\todo{I am using the notation \verb{\dot{x}} here for $x'$.}

Henrik Skov Midtiby said...

# Patrick
> I couldn't get verbatim to work inside a
> todonote, can it be made to work?
It should be possible, I expect that the problem will only occur when you insert a list of todos. The problem is that only normal text can be inserted in the list of todos.

Try this

\todo[caption={Text to the list of todos}]{I am using the notation \verb{\dot{x}} here for $x'$.}

Best
Henrik

M&M said...

hi, I would be interested if you have a way to include a short note in the margin with a todo{} that could be explained in detailed in the list of todos (with some longer comment than in the note included in the text)

Henrik Skov Midtiby said...

# M and M
Take a look at the caption option for the todo command.

dmp said...

I am having trouble with one todo note being placed on top of another in the margin. A screenshot appears here:

www.reed.edu/~davidp/screenshot.png

In the preamble to my document, I have

\usepackage{marginnote}
\renewcommand{\marginpar}{\marginnote}
\usepackage[color=green!40]{todonotes}

Any help would be appreciated.

Henrik Skov Midtiby said...

#dmp

Some favours the use of the marginnote package, but it can lead to your problems. I would suggest you to disable the renewcommand in the shown code.

Best regards,
Henrik

dmp said...

Thanks. The problem with removing

renewcommand{\marginpar}{\marginnote}

is that I then get errors of the form:

LaTeX Warning: Marginpar on page 43 moved

which is a bit of a hassle when using some editors (such as vim under vim-latex-suite).

Do you happen to know a fix for this?

Thanks.

dmp said...

Answer to previous post for those using vim-latex suite:

Add

let g:Tex_IgnoredWarnings =
\'Underfull'."\n".
\'Overfull'."\n".
\'specifier changed to'."\n".
\'You have requested'."\n".
\'Missing number, treated as zero.'."\n".
\'There were undefined references'."\n".
\'Citation %.%# undefined'."\n".
\'Marginpar'

let g:Tex_IgnoreLevel = 8

to your .vimrc.