21

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

  • 2
    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
  • 1
    @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
  • 1
    @Lucas: Please come down ;-) – user31729 Dec 28 '15 at 18:16
22

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}

\newif\ifproofread




\newcommand{\changemarker}[1]{%
\ifproofread
\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}

enter image description here

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

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}

enter image description here

9
 \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
8

What about the changes package?

\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%
\deleted[id=FM,remark={Be polite, please.}]{ and idiot} 
that you will be fired \added[id=DC]{ soon}. 
\replaced{Have a nice day!}{ That's all.}
\newpage\footnotesize
\listofchanges[style=summary]
\end{document}

mwe

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:

mwe2

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}
...
\added[id=A]{accepted addition}
4

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.

This is (for this kind of workflow) easy to use, as one does not actually ever interfere with the markup of the document, hence no need to take back annotations added for a previous round. Instead, it automatically provides a LaTeX source where all the changes are highlighted (with your choice of many possible styles).

  • This is true, but not really what the asker is looking for. The person the asker is working with may require red text in the output rather than looking at source files. – Null Dec 29 '15 at 21:19
  • @Null but this is exactly what latexdiff results in when the output is compiled, e.g. into a PDF, s. last pages at ctan.space-pro.be/tex-archive/support/latexdiff/doc/… . Or am I missing something there? – Shadow Jan 7 '16 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.