[texhax] Adding Color to Text Effortlessly

Susan Dittmar Susan.Dittmar at gmx.de
Wed May 25 09:50:25 CEST 2011


Quoting Boris Veytsman (borisv at lk.net):
> IK> From: Iraj Kalantari <I-Kalantari at wiu.edu>
> IK> Date: Tue, 24 May 2011 17:02:42 -0500
> 
> IK> Experts,
> 
> IK> Say I am co-authoring a paper with someone.
> IK> Say I get a draft of the work but I want to add revisions.
> 
> IK> Is there a way for me to add my revisions *in the source file* and 
> IK> have the changes to appear in color in the pdf file, without adding the command of 
> IK> \color{blue}  {... changes' ...} \color{black},
> IK> so that my co-author would spot them quickly?
> 
> Take a look at latexdiff (http://www.ctan.org/pkg/latexdiff)

latexdiff can do a lot more than the suggestion I'm about to make. You will
need perl though. If you only want to mark changes by hand, perhaps
something like

\usepackage{xcolor}

%%%%%%%%%%%%%%%%% markup changes: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% "StandardColor" is just a color name so you can use this system within
%%% colored text if you re-define StandardColor within this colored block
%%% aswell:
\definecolor{StandardColor}{named}{black}
%%% change markers (I use date codes):
\definecolor{2011-05-25}{blue}
\definecolor{2011-05-26}{green}
%%% those same change markers, use those for the final version:
%\definecolor{2011-05-25}{StandardColor}
%\definecolor{2011-05-26}{StandardColor}
%%% mark change: \CHANGE{change identifier}{text}
\newcommand{\CHANGE}[2]{\color{#1}#2\color{StandardColor}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

With this, you could put changes inside \CHANGE{marker}{text}. By changing
the color definitions in the header, you can easily decide which changes
you want highlighted.

I did not test this code. So I do not know if 2011-05-25 is acceptable as
color name. If not, you will have to either restrict yourself to change
markers acceptable to color definitions, or make the color choice within
the \CHANGE macro via \ifthenelse constructs.

This still needs balanced braces/groups inside the \CHANGE command, which
made me refrain from using it when I last considered it. I'll have a look
at latexdiff someday soon, perhaps that's a good alternative for me, at
least on my linux box.

Hope this helps,

	Susan


More information about the texhax mailing list