todonotes icon indicating copy to clipboard operation
todonotes copied to clipboard

Enhancements: todo styles and format hook

Open rzach opened this issue 2 years ago • 3 comments

I had some ideas on how implementing the idea to mark accomplished todos (1.7.3 in the manual).

The first idea is to provide a way to define todo styles which can be activated using a key. This can easily be accomplished using:

\newcommand*{\definetodostyle}[2]{%
    \define@key{todonotes}{#1}[]{%
        \setkeys{todonotes}{#2}}}

E.g., then you can say

\definetodostyle{done}{backgroundcolor={black!10},textcolor={black!60}}
\todo[done]{Stuff}

and the note will be greyed out. Or

\definetodostyle{done}{disable}

would simply suppress them. It can also be used as an alternative to defining new commands as suggested in 1.8.14.

A problem is that setkeys always sets the keys given by \presetkeys so if done is used after any other keys, it will overwrite them. So \todo[done,inline]{Stuff} will work but \todo[inline,done]{Stuff} wont.

This would take care of adding a done key that can change anything you can change with keys to todo. You might want to do something else, e.g., strike out the note or add a checkmark at the end. I'd suggest providing a format key that takes a command name as argument, and then use that command to typeset the text in the note and/or the list of todos. E.g.,

\todo[format=sout]{Stuff}

would strike out the text (with the ulem package), or you could do say

\newcommand{\checked}[1]{#1\ \checkmark}
\todo[format=checked]{Stuff}

to add a checkmark at the end. Combine with the above

\definetodostyle{done}{format=checked}

to make \todo[done]{Stuff} do the same. I'm not sure if you'd prefer this to happen both in the LoT and the actual note, just the note, or have two different hooks (noteformat,lotformat).

Would be happy to implement, test, document, and send a pull request if interested.

rzach avatar Jan 22 '23 23:01 rzach

Thanks for the detailed suggestion for improving the todonotes package.

I think that the idea and implementation of the definetodostyle is very elegant and useful. You are very welcome to send a pull request regarding this change, if possible please include a suggestion for updating the documentation as well.

I'd suggest providing a format key that takes a command name as argument, and then use that command to typeset the text in the note and/or the list of todos.

Regarding the format option, I think it is an interesting suggestion. Back in 2009 I added a textsize / size option to the package and todo command respectively. I remember that it was quite difficult to make it work as intended. I would love to see a suggestion for an implementation! Then we can discuss if it needs to be modified.

I'm not sure if you'd prefer this to happen both in the LoT and the actual note, just the note, or have two different hooks (noteformat,lotformat).

With respect to the naming the formatting options, I would suggest to use the following two format and lotformat. The main reason is that I try to keep the option names short.

henrikmidtiby avatar Jan 25 '23 09:01 henrikmidtiby

Sent pull request for the first idea (user defined styles)

rzach avatar Jan 28 '23 03:01 rzach

Also for the flexible formatting

rzach avatar Jan 30 '23 03:01 rzach