![如何让 latexdiff 显示文本标题的标记?](https://linux22.com/image/322559/%E5%A6%82%E4%BD%95%E8%AE%A9%20latexdiff%20%E6%98%BE%E7%A4%BA%E6%96%87%E6%9C%AC%E6%A0%87%E9%A2%98%E7%9A%84%E6%A0%87%E8%AE%B0%EF%BC%9F.png)
有没有办法让 latexdiff 突出显示 captionof 中的更改?
例如 orig.tex:
\documentclass{article}
\usepackage{caption}
\captionsetup{parindent=\parindent}
\usepackage[demo]{graphicx}
% make demo figure
\makeatletter
\AtBeginDocument{%
\def\Ginclude@graphics#1{%
\begingroup\fboxsep=-\fboxrule
\fbox{\rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}{0pt}%
\rule{0pt}{\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}\endgroup}}
\makeatother
\begin{document}
\noindent
\begin{minipage}[c]{\linewidth}
\centering
\includegraphics{}
\captionof{figure}[Title]{\textbf{Title}
Paragraph 1 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text
Paragraph 2 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text}
\label{fig:angio}
\end{minipage}
\end{document}
new.tex:
\documentclass{article}
\usepackage{caption}
\captionsetup{parindent=\parindent}
\usepackage[demo]{graphicx}
% make demo figure
\makeatletter
\AtBeginDocument{%
\def\Ginclude@graphics#1{%
\begingroup\fboxsep=-\fboxrule
\fbox{\rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}{0pt}%
\rule{0pt}{\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}\endgroup}}
\makeatother
\begin{document}
\noindent
\begin{minipage}[c]{\linewidth}
\centering
\includegraphics{}
\captionof{figure}[Title]{\textbf{Title}
New Paragraph 1 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text
New Paragraph 2 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text}
\label{fig:angio}
\end{minipage}
\end{document}
通过执行 latexdiff orig.tex new.tex > diff.tex 生成的 diff.tex
\documentclass{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL indent.tex Sun Nov 8 17:48:39 2015
%DIF ADD indent2.tex Sun Nov 8 17:49:21 2015
\usepackage{caption}
\captionsetup{parindent=\parindent}
\usepackage[demo]{graphicx}
% make demo figure
\makeatletter
\AtBeginDocument{%
\def\Ginclude@graphics#1{%
\begingroup\fboxsep=-\fboxrule
\fbox{\rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}{0pt}%
\rule{0pt}{\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}\endgroup}}
\makeatother
\newlength{\savedparindent}
% Save \parindent
\AtBeginDocument{\setlength{\savedparindent}{\parindent}}
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF
\begin{document}
\noindent
\begin{minipage}[c]{\linewidth}
\centering
\includegraphics{}
\DIFdelbegin %DIFDELCMD < \captionof{figure}[Title]{\textbf{Title}
%DIFDELCMD <
%DIFDELCMD < Paragraph 1 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text
%DIFDELCMD <
%DIFDELCMD < Paragraph 2 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text}
%DIFDELCMD < %%%
\DIFdelend \DIFaddbegin \captionof{figure}[Title]{\textbf{Title}
New Paragraph 1 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text
New Paragraph 2 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text}
\DIFaddend \label{fig:angio}
\end{minipage}
\end{document}
当我打开生成的 diff.pdf 时,输出中没有标记。有没有办法让 \DIFadd{} 标记在 captionof 中工作(甚至手动)?
答案1
latexdiff 不了解 \captionof,并且谨慎行事,不标记未知命令的参数。
您可以使用 --append-textcmd 选项来告诉 latexdiff 解析任何给定命令的最后一个参数。
latexdiff --append-textcmd=captionof old.tex new.tex > diff.tex