# How can I temporarily change text colour?

I'm making corrections to a report and the examiner would like my amendments highlighted in red. Of course, if(!) they are accepted, I would then have to produce an unmarked (black text) pdf.

Rather than put \color{red} before each section of text I would like to highlight, and then remove each instance later, is there a way I can put a marker before such text (e.g. \tempcolour) that can then be controlled in the document header? (e.g. tempcolour = red/black)

Thanks a lot

• Welcome to TeX.SX! We appreciate a working document, at the moment this question is a little bit unclear. A \color{...} is durable until another change will occur. It's better to wrap in a group or a command – user31729 Dec 28 '15 at 10:19
• Hi Christian - sorry I was just trying to be brief! I would've wrapped in all the affected text yes. – jshep Dec 28 '15 at 10:38
• That's what I've done and you can switch off here and there, where appropiate, using \proofreadtrue or \proofreadfalse (or remove the \changemarker wrapper finally for the approved portions – user31729 Dec 28 '15 at 10:38
• @Shep: Welcome from me, too, and a warm advice: take care to add an MWE. Even if you think it's unnecessary cos you only need a very short input or hint to go on and there are plenty of non-MWE advice around. From experience, if you don't and instead point out to these two points, all hell might break loose and you may well be exaggeratively defamed and boycotted. Please spare that yourself. – Lucas Dec 28 '15 at 17:46
• @Lucas: Please come down ;-) – user31729 Dec 28 '15 at 18:16

Something like this?

Define a conditional named, say \ifproofread and set to true for those parts that are not yet confirmed/accepted. If the proof read mode is false, the \changemarker expands to the usual (black) text.

Another way is to use \color{red} some text \normalcolor but this requires the resetting every time after the text. (Ah, just seen, Herbert does use this approach in his answer!)

\documentclass{article}

\usepackage[x11names]{xcolor}

\newcommand{\changemarker}[1]{%
\textcolor{red}{#1}%
\else
#1%
\fi
}

\begin{document}
\proofreadfalse  % All is accepted so far

Here is something. \changemarker{And this is added by me}

\proofreadtrue  % From now one, this is not yet confirmed.

Here is something. \changemarker{And this is added by me and was not yet accepted}

\end{document}


• This is interesting! – Alenanno Dec 28 '15 at 12:18

You can define \change and \stopchange commands:

\documentclass{article}

\usepackage{xcolor}

\usepackage{lipsum}

\makeatletter
\DeclareRobustCommand{\change}{%
\@bsphack
\leavevmode
\color{red}%
\@esphack
}
\DeclareRobustCommand{\stopchange}{%
\@bsphack
\normalcolor
\@esphack
}
\makeatother

\begin{document}

Some words \change \lipsum*[2] \stopchange and again normal color

Some words \lipsum*[2] and again normal color

\change Also at start of paragraphs and going across line breaks
without any particular problem \stopchange with color returning normal.

Also at start of paragraphs and going across line breaks
without any particular problem with color returning normal.

\end{document}


 \usepackage{xcolor}
\usepackage{xspace}
\newcommand\mycolor{\color{red}\xspace}
...
foo \mycolor bar \normalcolor baz


later you can change the macro \mycolor to use black instead of red. You can also define \mycolor with an argument:

 \usepackage{xcolor}
\newcommand\mycolor[1]{\textcolor{red}{#1}}
...
foo \mycolor{bar} baz


\documentclass[twocolumn]{article}
\usepackage[margin=1.5cm, columnsep=1cm,
paperwidth=14cm, paperheight=10cm]{geometry} % just for the MWE layout
\usepackage[xcolor={divpdf,grey},authormarkup=none]{changes}
\definechangesauthor[name={Exempli Gratia},color=orange]{EG}
\definechangesauthor[name={Dean Cavalier},color=green!50!black]{DC}
\definechangesauthor[name={Fran Meanbash}, color=red]{FM}
\begin{document}
\replaced[id=EG]{You are}{He is} so inefficient%
that you will be fired \added[id=DC]{ soon}.
\replaced{Have a nice day!}{ That's all.}
\newpage\footnotesize
\listofchanges[style=summary]
\end{document}


To hide all the changes if they are accepted, simply add the final option to the package,
i.e., \usepackage[final, ....]{changes} and you will have this:

Note that in the draft version (default) you can also turn out globally the markup of deleted/added changes with addedmarkup=none, deletedmarkup=none and turn black individual changes providing a id of a fake author associated with color black:

\definechangesauthor[name={Accepted}, color=black]{A}
...

If the intention is to help tracking changes rather than highlighting parts of the text, keeping the LaTeX source under a version control system (git, mercurial, subversion,...) and using the latexdiff script (included in the main distributions, or available from this git repository) to generate a source file with changes highlighted.