[Tex/LaTex] Robust way to mark draft text

colortodonotes

When writing documents, I like to 'mark up' draft/partial text (e.g., short summaries of what will go in a section) so that I can clearly see what needs to be adjusted. I know that things like the todonotes package exist (see this question, for example), but I want something that can span arbitrary parts of the document (e.g., multiple paragraphs or even sections with whatever text is in there).

I have been using the color package's \color 'switch' to do this (with an alternate \textcolor based command for short inline bits of text), with commands like this:

\usepackage[usenames,dvips]{color}
\newcommand{\todo}[1]{\textcolor{Purple}{#1}}    
\newcommand{\startToDo}{\color{Purple}}
\newcommand{\stopToDo}{\color{Black}}

However, this has problems in various situations (such as footnotes, URLs, tables), some dependent on the particular other packages used. (See this question and this one.)

Does anyone have any ideas on a robust alternative I could use? I would prefer not to use marginal lines (as used to indicate changes) so that it is clear exactly which bits of text, figures, etc. are included. Differently-coloured text was the obvious choice for me.

EDIT: Since my current \color method does work very nicely as a 'start/end' switch across arbitrary LaTeX constructs (except for the special cases mentioned above), I would only change to something that continues to give me that, but is more robust (especially since this is used to 'highlight' text that I need to adjust/rewrite, and is thus only used when working towards a 'proper' first draft; i.e., convenience of use outweighs absolute correctness since this won't normally be in any public-facing versions of the document).

There's a chance that my outstanding question will get an answer that 'fixes' my explicit \color usage (though I imagine with lots of very arcane low-level TeX) but obviously a pre-existing package or simple LaTeX that achieves the same or similar effect would be better.

Best Answer

Here I use the stackengine package to develop the macros \markabove and \markbelow that uses text lapping to achieve an edit, without affecting the layout of the original document, if you are careful with your % signs. It works in footnotes, too, as shown.

EDITED to allow a TODO like functionality, when your comments are too long to stick directly into the text.

\documentclass{article}
\textheight=6in
\usepackage{xcolor}
\usepackage{stackengine}
\setstackgap{L}{.5\baselineskip}
\newcommand\markabove[2]{{\sffamily\color{red}\hsmash{$\uparrow$}%
  \smash{\toplap{#1}{\scriptsize\bfseries#2}}}}
\newcommand\markbelow[2]{{\sffamily\color{red}\hsmash{$\downarrow$}%
  \smash{\bottomlap{#1}{\scriptsize\bfseries#2}}}}
\usepackage{ifthen}
\newcounter{todoindex}
\setcounter{todoindex}{0}
\newcommand\TODO[1]{%
  \addtocounter{todoindex}{1}%
  \expandafter\def\csname todo\roman{todoindex}\endcsname{#1}%
  \markabove{c}{\Alph{todoindex}}%
}
\newcounter{index}
\newcommand\showTODOs{%
  \vspace{5ex}%
  \rule{10ex}{.5ex}\textcolor{red}{TO-DO LIST}\rule{10ex}{.5ex}\\%
  \setcounter{index}{0}%
  \whiledo{\value{index} < \value{todoindex}}{%
    \addtocounter{index}{1}%
    \markabove{c}{\Alph{index}}  \csname todo\roman{index}\endcsname\\%
  }%
}
\begin{document}
When writing documents\footnote{Note, this is a copy of the OP's
\markbelow{c}{That is the name for the questioner}%
text}, I like to 'mark up'
\markabove{c}{Do you mean like this?}%
draft/partial text (e.g., short summaries
\TODO{I am using the TODO macro for longer notes that do not fit into a single
line, or are otherwise inconvenient to make short}%
of what will go in a section) so that I can clearly see what needs to be adjusted. I know that things like the todonotes package exist (see this question, for example), but I want something
\markbelow{r}{, anything actually,}%
that can span arbitrary parts of the document (e.g., multiple paragraphs or even sections with whatever text is in there).

I have been using the color package's \verb|\color| 'switch'
\TODO{I presume you actually meant that you are using the \textsf{xcolor}
package, since it improves upon the functionality of the former package.}%
to do this (with an alternate \verb|\textcolor| based command for short inline bits of text), with commands like this:

\begin{verbatim}
\usepackage[usenames,dvips]{color}
\newcommand{\todo}[1]{\textcolor{Purple}{#1}}    
\newcommand{\startToDo}{\color{Purple}}
\newcommand{\stopToDo}{\color{Black}}
\end{verbatim}

However, this has problems in various situations (such as footnotes, URLs, tables), some dependent on the particular other packages used. (See this question and this one.)
\markabove{r}{I'm sorry, but the links didn't show}%

Does anyone have any ideas on a robust alternative I could use? I would prefer not to use marginal lines (as used to indicate changes) so that it is clear exactly which bits of text, figures, etc. are included. Differently-coloured
\markbelow{l}{and lapped, I think}%
text was the obvious choice for me.

There's a chance that my outstanding question will get an answer that 'fixes' my explicit \verb|\color| usage (though I imagine with lots of very arcane low-level TeX) but obviously a pre-existing package or simple LaTeX that achieves the same or similar effect would be better.

\showTODOs

\end{document}

enter image description here

Related Question