最近需要在latex中修改论文,并保留修改痕迹,收集总结了以下三种实现方式。
法一:使用changes宏包
我觉得最方便最有效的方式。在导言区加入如下代码,可以一键生成保留/禁用修订的方式。
% 修订痕迹保留 法一
\usepackage[defaultcolor=red]{changes} %使用changes宏包
%\usepackage[final]{changes} %禁用修订,输出最终修订完成的版本
\definechangesauthor[name={Author}, color=red]{A} %修订作者
文中需要增删的地方,采用相应的命令\added{}和\deleted{}就够用了。
法二:
参考链接latex实现pdf中带有注释或批注。
导言区加入如下代码:
% 修订痕迹保留 法二
\usepackage{xargs} % Use more than one optional parameter in a new commands
% \usepackage[pdftex,dvipsnames]{xcolor} % Coloured text etc.
%
% \usepackage[colorinlistoftodos,prependcaption,textsize=tiny]{todonotes}
\newcommandx{\unsure}[2][1=]{\todo[linecolor=red,backgroundcolor=red!25,bordercolor=red,#1]{#2}}
\newcommandx{\change}[2][1=]{\todo[linecolor=blue,backgroundcolor=blue!25,bordercolor=blue,#1]{#2}}
% \newcommandx{\thiswillnotshow}[2][1=]{\todo[disable,#1]{#2}}
%
正文中在需要添加批注的地方,使用相应的命令\unsure{}和\change{}即可,链接里说的蛮详细。
法三:使用marginpar命令
代码更复杂一点,但是可以更细致的调大小、位置等参数。参考边注 新样式。
在导言区加入:
% 修订痕迹保留 法三
\usepackage{tikz}
\newcommand{\annmark}[1]{%
\textcolor{red}{#1}%
}%
\newcommand{\ann}[1]{%
\begin{tikzpicture}[remember picture, baseline=-0.75ex]%
\node[coordinate] (inText) {};%
\end{tikzpicture}%
\marginpar{%
\renewcommand{\baselinestretch}{1.0}%
\begin{tikzpicture}[remember picture]%
\definecolor{orange}{rgb}{1,0.5,0}%
\draw node[fill=red!20,text width=\marginparwidth] (inNote){\footnotesize#1};%
\end{tikzpicture}%
}%
\begin{tikzpicture}[remember picture, overlay]%
\draw[draw = orange, thick]
([yshift=-0.2cm] inText)
-| ([xshift=-0.2cm] inNote.west)
-| (inNote.west);%
\end{tikzpicture}%
}%
% \setlength{\marginparwidth}{1cm}
% \renewcommand{\baselinestretch}{1.3}
\setlength{\marginparwidth}{1.4cm}
\setlength{\marginparsep}{0.3cm}