When using the color package in its switch form (\color cf. \textcolor), things can get confused using certain packages, with footnotes, and with section headings. The section headings issue was discussed in another of my questions but, even with the \zcolor robust command definition suggested by David Carlisle (the color author) there, this still causes problems with footnotes, and the longtable and hyperref packages.
See the LaTeX source below:
(a) Footnotes from coloured text lose their colour.
(b) hyperref URLs within footnotes get the colour back! (This doesn't happen if using the url package instead.)
(c) Floating longtables can/will get the color of text on the page they float to, even when defined in a non-coloured area. (Using table and tabular doesn't have this problem. I used the afterpage package to force the table to be on the next page, and assume the problem still exists if it 'naturally' did.)
\documentclass[11pt,a4paper,twoside,notitlepage]{article}
%\usepackage{url} % URLs in footnotes consistent (no color) if use this instead
\usepackage{hyperref}
\usepackage{breakurl}
\usepackage[usenames,dvips]{color}
\usepackage{lipsum}
\usepackage{afterpage}
\usepackage{longtable}
\newcommand{\startToDo}{\color{Purple}}
\newcommand{\stopToDo}{\color{Black}}
\author{Stuart Rossiter}
\title{Color weirdness test}
\date{4th November 2013}
\begin{document}
\maketitle
\startToDo % Works with titles
\section{Wibble Wobble}
\lipsum[1-4]
What about footnote weirdness?\footnote{A profound footnote that should be
colored with a URL:
\url{http://wibblewobble.org}.}
\stopToDo
\lipsum[1-3]
\afterpage{ % Just to force it to be on page with colored text
\begin{longtable}{ccc} % Table is OK if use normal table and tabular
%\begin{table}
%\begin{tabular}{ccc}
a & b & c \\
d & e & f \\
\caption{An astonishing table that shouldn't be coloured.}
%\end{tabular}
%\end{table}
\end{longtable}
}
\section{Wobble Wibble}
\startToDo
\lipsum
\stopToDo
\end{document}
I guess my question is:
Can my use of color be 'fixed' to work robustly in all such scenarios?
(David's answer to my other question suggests color is fundamentally problematic in such contorted constructs, and can't be 'fixed' itself.)
As the \startToDo and \stopToDo (custom) macros suggest, I use color to mark-up to-do text. I'll ask a separate question about better alternatives (that avoid these colour issues).
\afterpage{{\normalcolor \begin{longtable}....}}– David Carlisle Nov 04 '13 at 15:56