3

I'm using the changes package to keep track of any changes I ( and my co-authors ) made for a peer reviewed journal. Meaning, in response to each of the reviewers' comments, we are using a new author id from the changes package to make it easier (for us) and the reviewer to find our additions and changes to a specific comment. But moreover, we also use a special author id to keep track of linguistic/grammar corrections we made.

  1. But now, when submitting the revised journal, we would like to hide all linguistic/grammar corrections we made ( just show the 'final' state ) to avoid too much different colors and confusion. How I can 'toggle' the 'final' command for specific author id or achieve something similar?

  2. Also I would like to replace all \replaced commands by \added to hide the crossed out text. How can I do this?

\documentclass{article}

\usepackage{changes}
\definechangesauthor[name={Reviewer 1. Comment 1}, color=red]{r11}
\definechangesauthor[name={Reviewer 1. Comment 2}, color=red]{r12}
\definechangesauthor[name={Language/Grammar}, color=black!50!green]{lang}

\begin{document}

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla}.

\end{document}
3

In principle all you have to do is redefine what the macros \added and \replaced does:

  1. For this we create \finalstate that redefines \added and \replaced to be so-called "no-op"s. That is, they literally just gobble their arguments and spit out them out again.

  2. Here we define \convertreplaced to transform \replaced to be equivalent to \added, dropping the replaced text.

You can issue the above commands anywhere in the document (or preamble), and subsequent setting of content will be updated accordingly. To that end, a "final state" document will be achieved when you issue \finalstate in the preamble (before \begin{document}).

enter image description here

\documentclass{article}

\usepackage{changes}
\definechangesauthor[name={Reviewer 1. Comment 1}, color=red]{r11}
\definechangesauthor[name={Reviewer 1. Comment 2}, color=red]{r12}
\definechangesauthor[name={Language/Grammar}, color=black!50!green]{lang}

\newcommand{\finalstate}[1][]{%
  \renewcommand{\added}[2][]{##2}%
  \renewcommand{\replaced}[3][]{##2}}%
\newcommand{\convertreplaced}{%
  \renewcommand{\replaced}[3][]{\added[##1]{##2}}}

\begin{document}

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla}.

\convertreplaced

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla}.

\finalstate

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla}.

\end{document}

The following update adds functionality to manage a list of so-called "final state IDs":

enter image description here

\documentclass{article}

\usepackage{changes,etoolbox,xparse}

\definechangesauthor[name={Reviewer 1. Comment 1}, color=red]{r11}
\definechangesauthor[name={Reviewer 1. Comment 2}, color=red]{r12}
\definechangesauthor[name={Language/Grammar}, color=black!50!green]{lang}

\makeatletter
\renewcommand{\added}[2][\@empty]{%
  \setkeys{Changes@added}{#1}%
  \ifallfinal
    #2%
  \else
    \xifinlist{\Changes@added@id}{\finalstateids}{%
      #2%
    }{%
      \Changes@output%
        {\Changes@Markup@Added{#2}}%
        {#2}%
        {\Changes@added@id}%
        {\Changes@added@remark}%
        {#2}%
        {\changesaddname}%
    }%
  \fi
  \stepcounter{Changes@AddCount\Changes@added@id}%
}
\renewcommand{\deleted}[2][\@empty]{%
  \setkeys{Changes@deleted}{#1}%
  \ifallfinal\else% or \ifallfinal\unskip\else
    \xifinlist{\Changes@deleted@id}{\finalstateids}{}{% or \xifinlist{\Changes@deleted@id}{\finalstateids}{\unskip}{
      \Changes@output%
        {\Changes@Markup@Deleted{#2}}%
        {\@bsphack \expandafter \@esphack}%
        {\Changes@deleted@id}%
        {\Changes@deleted@remark}%
        {#2}%
        {\changesdeletename}%
    }%
  \fi
  \stepcounter{Changes@DeleteCount\Changes@deleted@id}%
}
\renewcommand{\replaced}[3][\@empty]{%
  \setkeys{Changes@replaced}{#1}%
  \ifallfinal
    #2%
  \else
    \xifinlist{\Changes@replaced@id}{\finalstateids}{%
      #2%
    }{%
      \Changes@output
        {{\Changes@Markup@Added{#2}}{\Changes@Markup@Deleted{#3}}}
        {#2}
        {\Changes@replaced@id}
        {\Changes@replaced@remark}%
        {#2}%
        {\changesreplacename}%
    }%
  \fi
  \stepcounter{Changes@ReplaceCount\Changes@replaced@id}%
}
\makeatother

\newcommand{\finalstateids}{}
\newif\ifallfinal
\NewDocumentCommand{\finalstate}{o}{%
  \IfNoValueTF{#1}
    {\allfinaltrue}% All ids are in final state
    {\renewcommand{\do}[1]{\listgadd\finalstateids{##1}}% Add id to final state list
     \docsvlist{#1}}% Process list
}
\newcommand{\clearfinalstateids}{\renewcommand{\finalstateids}{}}

\begin{document}

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla} bla bla \deleted[id=r12]{Bla}.

\bigskip\verb|\finalstate[lang]|:\finalstate[lang]

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla} bla bla \deleted[id=r12]{Bla}.

\bigskip\verb|\finalstate[r12]|:\finalstate[r12]

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla} bla bla \deleted[id=r12]{Bla}.

\bigskip\verb|\clearfinalstateids\finalstate[r11,r12]|:\clearfinalstateids\finalstate[r11,r12]

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla} bla bla \deleted[id=r12]{Bla}.

\bigskip\verb|\finalstate[lang,r11]|:\finalstate[lang,r11]

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla} bla bla \deleted[id=r12]{Bla}.

\bigskip\verb|\clearfinalstateids|:\clearfinalstateids

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla} bla bla \deleted[id=r12]{Bla}.

\bigskip\verb|\finalstate|:\finalstate

Bla bla bla \added[id=lang]{blubb} bla bla \replaced[id=r11]{addition}{Bla} bla bla \deleted[id=r12]{Bla}.

\end{document}

As a side-point, consider updating the \deleted macro to use \unskip rather than just printing nothing, as it will also attempt to remove the preceding space (see the comments above for placement).

  • Thanks for this! One question: the finalstate is now applied to all author ids, right? Is it possible to make it only for specific ones? e.g. r11 in the example above?. Also it seems that the finalstate is actually reverting the old state, right? I was thinking of something like the \usepackage[final]{changes} switch for specific author ids. – bonanza Nov 28 '14 at 7:25
  • 1
    @bonanza: Yes (I'll update this tomorrow). So you're interested in something like \finalstate (for all author ids), but \finalstate[r11] which will keep all other author ids' content in visible, but remove/finalize only author id r11's content. I guess next thing you'll reach for the starts and want to enter something like \finalstate[r11,r12,...] where you supply a list of "finalized author ids". ;) – Werner Nov 28 '14 at 7:31

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.