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

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


\[\int_0^1 \dfrac{dx}{\sqrt{1-x} \sqrt[4]{2x-x^2 \sqrt{3}}} = \dfrac{2 \sqrt{2} \pi }{3 \sqrt[8]{3}}\]

For $\alpha, \beta, \gamma \in (0,1)$ satisfying $\alpha+\beta+\gamma = 1$ and 
$\mu \in \mathbb{C} \setminus [1,\infty)$, define

$$
F_{\alpha\beta}(\mu) = \int_0^1\frac{dx}{x^\alpha(1-x)^\beta(1-\mu x)^\gamma}
\quad\text{ and }\quad
\Delta = \frac{\Gamma(1-\alpha)\Gamma(1-\beta)}{\Gamma(1+\gamma)}
$$
When $|\mu| < 1$, we can rewrite the integral $F_{\alpha\beta}(\mu)$ as

$$\begin{align}
F_{\alpha\beta}(\mu) 
= & \int_0^1 \frac{1}{x^\alpha(1-x)^{\beta}}\left(\sum_{n=0}^{\infty}\frac{(\gamma)_n}{n!}\mu^n x^n\right) dx
= \sum_{n=0}^{\infty}\frac{(\gamma)_n}{n!}\frac{\Gamma(n+1-\alpha)\Gamma(1-\beta)}{\Gamma(n+1+\gamma)}\mu^n\\
= & \Delta\sum_{n=0}^{\infty}\frac{(\gamma)_n (1-\alpha)_n}{n!(\gamma+1)_n}\mu^n
= \Delta\gamma \sum_{n=0}^{\infty}\frac{(1-\alpha)_n}{n!(\gamma+n)}\mu^n
\end{align}$$

This implies 

$$\mu^{-\gamma} \left(\mu\frac{\partial}{\partial \mu}\right) \mu^{\gamma} F_{\alpha\beta}(\mu) =  
\Delta\gamma \sum_{n=0}^{\infty}\frac{(1-\alpha)_n}{n!}\mu^n
= \Delta\gamma\frac{1}{(1-\mu)^{1-\alpha}}
$$
and hence

$$F_{\alpha\beta}(\mu) 
= \Delta\gamma \mu^{-\gamma} \int_0^\mu \frac{\nu^{\gamma-1}d\nu}{(1-\nu)^{1-\alpha}}
= \Delta\gamma \int_0^1 \frac{t^{\gamma-1} dt}{(1-\mu t)^{1-\alpha}}
= \Delta \int_0^1 \frac{dt}{(1 - \mu t^{1/\gamma})^{1-\alpha}}$$

Notice if we substitute $x$ by $y = 1-x$, we have

$$F_{\alpha\beta}(\mu) = \int_0^1 \frac{dy}{y^\beta(1-y)^\alpha(1-\mu - \mu y)^{\gamma}}
= \frac{1}{(1-\mu)^\gamma} F_{\beta\alpha}(-\frac{\mu}{1-\mu})$$

Combine these two representations of $F_{\alpha\beta}(\mu)$ and let $\omega = \left(\frac{\mu}{1-\mu}\right)^{\gamma}$, we obtain

$$F_{\alpha\beta}(\mu) = \frac{\Delta}{(1-\mu)^{\gamma}}\int_0^1 \frac{dt}{( 1 + \omega^{1/\gamma} t^{1/\gamma})^{1-\beta}} = \frac{\Delta}{\mu^\gamma}\int_0^\omega \frac{dt}{(1 + t^{1/\gamma})^{1-\beta}}$$

Let $(\alpha,\beta,\gamma) = (\frac14,\frac12,\frac14)$ and $\mu = \frac{\sqrt{3}}{2}$, the identity we want to check becomes

$$\frac{\Gamma(\frac34)\Gamma(\frac12)}{\Gamma(\frac54) (\sqrt{3})^{1/4}}\int_0^\omega \frac{dt}{\sqrt{1+t^4}} \stackrel{?}{=} \frac{2\sqrt{2}}{3\sqrt[8]{3}} \pi\tag{*1}$$

Let $K(m)$ be the complete elliptic integral of the first kind associated with modulus $m$. i.e.

$$K(m) = \int_0^1 \frac{dx}{\sqrt{(1-x^2)(1-mx^2)}}$$
It is known that $\displaystyle K(\frac12) = \frac{8\pi^{3/2}}{\Gamma(-\frac14)^2}$. In term of $K(\frac12)$, it is easy to check $(*1)$ is equivalent to

$$\int_0^\omega \frac{dt}{\sqrt{1+t^4}} \stackrel{?}{=} \frac23 K(\frac12)\tag{*2}$$

To see whether this is the case, let $\varphi(u)$ be the inverse function of above integral.
More precisely, define $\varphi(u)$ by following relation:

$$u = \int_0^{\varphi(u)} \frac{dt}{\sqrt{1+t^4}}$$

Let $\psi(u)$ be $\frac{1}{\sqrt{2}}(\varphi(u) + \varphi(u)^{-1})$. It is easy to check/verify
$$
\varphi'(u)^2 = 1 + \varphi(u)^4
\implies
\psi'(u)^2 = 4 (1 - \psi(u)^2)(1 - \frac12 \psi(u)^2)
$$

Compare the ODE of $\psi(u)$ with that of a Jacobi elliptic functions with modulus $m = \frac12$, we find

$$\psi(u) = \text{sn}(2u + \text{constant} | \frac12 )\tag{*3}$$

Since we are going to deal with elliptic functions/integrals with $m = \frac12$ only,
we will simplify our notations and drop all reference to modulus, i.e 
$\text{sn}(u)$ now means $\text{sn}(u|m=\frac12)$ and $K$ means $K(m = \frac12)$.

Over the complex plane, it is known that $\text{sn}(u)$ is doubly periodic with
fundamental period $4 K$ and $2i K$. It has two poles at $i K$ and $(2 + i)K$ in the fundamental domain.
When $u = 0$, we want $\varphi(u) = 0$ and hence $\psi(u) = \infty$. So the constant
in $(*3)$ has to be one of the pole. For small and positive $u$, we want $\varphi(u)$ and hence $\psi(u)$ to be positive. This fixes the constant to $i K$. i.e.

$$\psi(u) = \text{sn}(2u + iK )$$

and the condition $(*2)$ becomes whether following equality is true or not.

$$\frac{1}{\sqrt{2}} (\omega + \omega^{-1}) \stackrel{?}{=} \text{sn}( \frac43 K + i K)\tag{*4}$$

Notice $ 3( \frac43 K + i K) = 4 K + 3 i K $ is a pole of $\text{sn}(u)$. if one repeat
apply the addition formula for $\text{sn}(u+v)$

$$\text{sn}(u+v) = \frac{\text{sn}(u)\text{cn}(v)\text{dn}(v)+\text{sn}(v)\text{cn}(u)\text{dn}(u)}{1-m\,\text{sn}(u)^2 \text{sn}(v)^2}$$

One find in order for $\text{sn}(3u)$ to blow up, $\text{sn}(u)$ will be a root of
following polynomial equation:
$$3 m^2 s^8-4 m^2 s^6-4 m s^6+6 m s^4-1 = 0$$
Substitute $m = \frac12$ and $s = \frac{1}{\sqrt{2}}(t+\frac{1}{t})$ into this, the equation $\omega$ need to satisfy is given by:

$$(t^8 - 6 t^4 - 3)(3 t^8 + 6 t^4 - 1 ) = 0$$

One can check that $\omega = \sqrt[4]{\frac{\sqrt{3}}{2-\sqrt{3}}}$ is indeed a root of this polynomial. As a result, the original equality is valid.



论文投出之后,如果好消息,通常是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.

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在LaTeX实现算法的高亮显示,你可以使用`algorithm2e`宏包。首先,你需要在导言区使用`\usepackage{algorithm2e}`来引入该宏包。接下来,你可以使用`algorithm`环境来定义你的算法,并使用`\caption`命令来添加标题。为了使用高亮显示,你可以使用`minted`宏包,并在编译时添加选项`-shell-escape`。在算法的代码部分,你可以使用`minted`环境,并指定代码的语言,如`\begin{minted}{python}`,然后在其输入代码。为了添加注释,你可以使用`\tcc{注释}`或`\tcp{注释}`命令。如果你想自定义注释的样式,可以使用`\SetAlgorithmName`命令来设置算法的名称和自动引用的名称。请参考下面的示例代码: ```latex \documentclass{article} \usepackage{algorithm2e} \usepackage{minted} \begin{document} \begin{algorithm} \caption{示例算法} \SetAlgorithmName{算法}{算法}{算法} \KwData{输入数据} \KwResult{输出结果} \tcc{算法主体} \For{$i \leftarrow 1$ \KwTo $n$}{ 计算 $a_i = b_i + c_i$\; \tcp{这是一个注释} } \end{algorithm} \end{document} ``` 在这个示例,我们使用了`algorithm2e`宏包来定义算法环境,并使用`minted`宏包来高亮显示代码。我们使用`\SetAlgorithmName`命令设置了算法的名称和自动引用的名称。在算法主体,我们使用了`\For`命令来表示循环,并使用`\tcp`命令添加了一个注释。你可以根据需要修改代码的内容和注释样式。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Latex algorithm2e 算法伪代码 官方介绍文档.pdf](https://download.csdn.net/download/yyl424525/12045988)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [latex代码高亮显示宏包minted用法](https://blog.csdn.net/xenonhu/article/details/88978672)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [用LaTex写伪代码(使用algorithm2e包)](https://blog.csdn.net/amnesiagreen/article/details/120609867)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值