现在的位置: 首页 > 综合 > 正文

如何对LaTeX文档中的所作的修改进行高亮显示

2014年09月05日 ⁄ 综合 ⁄ 共 4599字 ⁄ 字号 评论关闭

http://www.peteryu.ca/tutorials/publishing/latexdiff

论文投出之后,如果好消息,通常是minor/major revision难免; 很少有文不加点直接接受的.

修改的时候为了方便编辑和审稿人,高亮显示文档中改动的部分是专业的.

MS word的comment 审阅修订中"对比compare文档"功能是很方便的. 

但是在LaTeX中如何实现? -- 实际上是对tex源代码的两个版本的对比,

如果安装了CTeX,只需要两点:

(1) 确保latexdiff-so.exe等文件所在的bin文件夹也被添加到系统环境变量path中(可能要手动自己添加,否则只能在该文件夹下使用latexdiff-so.exe命令行是郁闷的)

(2)再安装ActivePerl,安装的时候选择把ActivePerl添加到系统环境变量path中即可;

windows下activeperl 5.16的下载地址,可以从这里进入:
点击打开链接
:或直接用下面的下载链接:

64位系统: http://downloads.activestate.com/ActivePerl/releases/5.16.3.1604/ActivePerl-5.16.3.1604-MSWin32-x64-298023.msi

32位系统: http://downloads.activestate.com/ActivePerl/releases/5.16.3.1604/ActivePerl-5.16.3.1604-MSWin32-x86-298023.msi

命令行cmd.exe中输入:

>> latexdiff-so old_tex_source.tex new_tex_source.tex > difference.tex

然后用同样方法编译difference.tex 即可

(比如LaTeX 1次> BibTeX 一次>> LaTeX 2次>> dvi2ps 1次>> ps2pdf 完成;)

尝试之后,发现对使用了gnuplot绘图的命令支持不好,如果有相应的改动,可能无法通过编译. 但其它的则鲜有例外.

Track changes and highlight revisions in LaTeX documents
with latexdiff

WHEN several
authors are editing a paper, it is sometimes necessary to quickly highlight what changes have been made in a particular version of the paper compared to previous versions. Word processors have long had revision tracking features for this but some LaTeX authors
are unaware that there is a handy utility called latexdiff that
can also highlight changes between two revisions by comparing two LaTeX documents:

latexdiff can highlight and show changes between two versions of a LaTeX document.

This page briefly describes this program. While LaTeX authors can use revision control software like software developers to track changes, there are cases where this is not convenient. For example, grad students may revise papers, get feedback from their advisor
and then revise the paper again (I know I did). The advisor just wants to see quickly and with formatting what changes were made on the manuscript without learning how to use revision control software. latexdiff provides a way to do this. It performs a “diff”
(like the Unix utility) on the two documents and then creates a new LaTeX document where the changes are made clear.

Prerequisites

  • Ensure that the latexdiff program
    is in your system path. Windows users with MiKTeX will find that it already comes with latexdiff: there are several latexdiff*.exe files
    in MiKTeX's bin directory.
    I usually use latexdiff-so.exe.
  • Make sure that Perl is on the system
    path, as it is required by latexdiff to run.

Usage

Obviously you need to have two versions of your document to compare. latexdiff can be run with the following command:

latexdiff-so old_version.tex new_version.tex > differences.tex

The resulting differences.tex file
can be run through LaTeX to produce the version with revisions highlighted.

It has been pointed out to me that the file names should not have spaces or else you will have to enclose them in quotes.

Additional Tips

Sometimes latexdiff produces wrong output that will give an error when you run LaTeX on the file. In the cases I have seen, you simply need to go to the place where the error occurs and make sure that the various commands that latexdiff adds are properly closed.
For example, you may have to add some \DIFaddend to
unclosed \DIFadd commands.

The program does not necessarily handle complex math equations properly but I have found that it is enough to do the job most of the time. It also has a number of command line options that I have not had to use yet.

Finally, if your document is split up into sections, it might be best to split the LaTeX files up into a file per section so the diffprocess
can work more smoothly. I have been particularly lazy and have not done this for my journal submissions but it is probably a good idea.

Discussion

Glenna Jenkins2013/09/06
12:36
Hi Peter: I am an editor who revises economic documents. Many of my clients write their documents in LaTex. I use a MacBook Pro and prefer to do mark-up in 'track changes'. I am considering downloading MacTex so that I can accommodate clients without asking
them to convert their documents to Word. Would LaTexdiff work for this of should I consider LyX? I would really appreciate your help on this one.
Thanks so much,
Glenna Jenkins
Peter Yu2013/09/09
01:49
I think you could use any PDF markup tool to do this if your clients can generate PDF from their LaTeX documents. Otherwise, latexdiff could work for this, but keep in mind it's simply going to mark the differences between documents and not necessarily give
you a way to leave comments. So you'd edit their LaTeX file and then run latexdiff to highlight the differences.
Salman2014/06/03
09:38
Hi Peter! How do you go on to accept the changes made using this method? For my specific case, i have to show the reviewers where I have incorporated their comments in my thesis and finally accept them all.
Regards
Salman
Peter Yu2014/06/06
01:02
You have to keep in mind this just highlights the changes between two versions of your document. Let's say you start with version 1. Your reviewers give you comments and you make version 2. You use latexdiff to highlight changes between V1 and V2. Then you
give V2 and the highlighted file to the reviewers. When you make V3, you can then compare the differences between V2 and V3.

抱歉!评论已关闭.