我使用该changes
软件包来跟踪我(和我的合著者)对同行评审期刊所做的任何更改。这意味着,为了回应每个审阅者的评论,我们正在使用author id
该changes
软件包中的新内容,以便(对我们而言)和审阅者更容易找到我们对特定评论的添加和更改。但此外,我们还使用特殊内容author id
来跟踪我们所做的语言/语法更正。
但是现在,在提交修订后的期刊时,我们想隐藏我们所做的所有语言/语法更正(仅显示“最终”状态),以避免过多的不同颜色和混淆。我如何才能“切换”特定作者 ID 的“最终”命令或实现类似功能?
我也想更换全部
\replaced
命令\added
隐藏划掉的文本。我该怎么做?
\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}
答案1
原则上,您所要做的就是重新定义宏\added
并\replaced
执行的操作:
为此,我们
\finalstate
重新定义\added
了\replaced
所谓的“无操作”。也就是说,它们实际上只是吞噬它们的参数,然后再次将其吐出。这里我们定义
\convertreplaced
变换\replaced
等同于\added
,删除被替换的文本。
您可以在文档(或前言)的任何地方发出上述命令,后续的内容设置将相应更新。为此,当您\finalstate
在前言(之前\begin{document}
)发出时,将实现“最终状态”文档。
\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}
以下更新添加了管理所谓“最终状态 ID”列表的功能:
\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}
作为一个侧重点,考虑更新\deleted
要使用的宏\unskip
而不是仅仅打印任何内容,因为它还将尝试删除前面的空格(有关位置,请参阅上面的注释)。