Thursday, April 17, 2008

Todo notes in Latex as a package

The package has been updated, find the new version at http://midtiby.blogspot.com/2008/07/todonotes-version-2008-07-28.html.

I have transformed the previously described script into a latex package (pheww, this is my first package, so there may exists some rough edges ...). The source for the package is given below.

The package currently takes three arguments
* disable = [true, false] if false the package will only define empty commands, so no output from the embedded todo commands are generated, but you document will compile
* color = [color values accepted by pgf] Defines the background color of the todonotes and the line connecting the todo note with the place it was inserted in the test.
* bordercolor = [color values accepted by pgf] Defines the border color of the todonotes.

I use the following line to import the package to a document.

\usepackage[
disable=false,
color=orange!80,
bordercolor=black]
{todonotes}

I hope that someone will find this usefull.

Henrik


======= begin: todonotes.sty ========
% Part: Identification
\ProvidesPackage{todonotes}

% Part: The package loading part
\RequirePackage{xkeyval}
\RequirePackage{hyperref}
\RequirePackage{tikz}

% Part: Initial code
\newcommand{\@backgroundcolor}{orange}
\newcommand{\@bordercolor}{black}

% Part: The declaration of options
\define@boolkey{todonotes.sty}%
[todo]{disable}{}
\define@key{todonotes.sty}%
{color}{\renewcommand{\@backgroundcolor}{#1}}
\define@key{todonotes.sty}%
{bordercolor}{\renewcommand{\@bordercolor}{#1}}
\ProcessOptionsX

% Part: The main code part
\iftododisable
\newcommand{\listoftodos}{}
\newcommand{\todo}{}
\else
\newcommand{\listoftodos}
{\section*{Todo list} \@starttoc{tdo}}
\newcommand{\l@todo}
{\@dottedtocline{1}{0em}{2.3em}}

\tikzstyle{notestyle} = [draw=\@bordercolor,
fill=\@backgroundcolor, text width = 3cm]
\tikzstyle{notestyleleft} = [notestyle]
\tikzstyle{connectstyle} = [draw = \@backgroundcolor, thick]

\newcommand{\todo}[1]{%
% Add to todo list
\addcontentsline{tdo}{todo}{\protect{#1}}%
%
% Remember where we are
\begin{tikzpicture}[remember picture, baseline=-0.75ex]%
\node [coordinate] (inText) {};%
\end{tikzpicture}%
%
% Make the margin par
\marginpar {% Draw note in right margin
\tikz[remember picture] \draw node[notestyle] (inNote) {#1};%
\begin{tikzpicture}[remember picture, overlay]%
\draw[connectstyle]
([yshift=-0.2cm] inText)
-| ([xshift=-0.2cm] inNote.west)
-| (inNote.west);
\end{tikzpicture}%
}%
}%
\fi
======= end: todonotes.sty ========

2 comments:

Unknown said...

This whole information is absolutely interesting. i like this blog because is easily understandable, and that is invaluable to the readers. Beyond all doubt La Tex will be very useful for everybody who want to prove it.
buy viagra

Unknown said...

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. notes du web