![latexdiff 和 endfloat 之间的冲突](https://linux22.com/image/340133/latexdiff%20%E5%92%8C%20endfloat%20%E4%B9%8B%E9%97%B4%E7%9A%84%E5%86%B2%E7%AA%81.png)
当我发布原始问题时,我还没有找到冲突的根源,后来发现冲突是由 引起的\endfloat
。
原始问题
我刚开始使用,latexdiff
因为我意识到它可以很好地完成我尝试手动完成的事情,例如,强调新版本 tex 文件的新部分。
我尝试使用默认参数,它运行得很好(我只是遇到了问题,因为存在\SIrange
只有两个参数的命令,这显然引起了一些麻烦)。
然后我尝试更改标记样式,但只有使用CFONT
(默认样式除外)才有效。由于我对 感兴趣BOLD
,所以我正在尝试找到一种方法来克服这个问题。
错误内容如下
! Output loop---100 consecutive dead cycles.
\clearpage ...rite \m@ne {}\vbox {}\penalty \\@Mi
l.104 \efloatseparator
工作版本序言中添加的命令如下
\providecommand{\DIFaddtex}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdeltex}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE
而非工作版本的则是这些
\providecommand{\DIFaddtex}[1]{{\bf #1}} %DIF PREAMBLE
\providecommand{\DIFdeltex}[1]{} %DIF PREAMBLE
其余的都一样。\DIFdeltex
(或派生的命令)可能包括引文、缩写词、参考文献等,我怀疑其中一个坏家伙造成了麻烦。
知道如何使BOLD
基于的解决方案发挥作用吗?
已编辑问题
我想我找到了问题所在。在剥离部分代码以发布 MWE 时,我意识到问题发生在我的文档的新版本中删除图形时。出于某种原因,此类问题与 的使用有关endfloat
。
鉴于我的 MWE 如下老的版本
\documentclass{article}
\usepackage[american]{babel}
\usepackage[acronym,shortcuts]{glossaries}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{natbib}
\usepackage{siunitx}
% Move figures to the end
%\usepackage{endfloat}
% Acronyms
\newacronym{MNA}{MNA}{my nice acronym}
% ------------------------------------
\begin{document}
\section{My section}
\label{sec:mysec}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things). This is nonsense.
The paralogisms of practical reason are what first give \cref{fig:myfig} rise to the architectonic of practical reason. As will easily be shown in the next section, reason would \SIrange{0}{1}{}.
%
\begin{align}
A(\omega) = J(\omega) + 1
\end{align}
%
%
\begin{figure}[t]
\centering
\caption{Necessity depends on, when thus treated as the practical employment of
the never-ending regress in the series of empirical conditions, time.}
\label{fig:myfig}
\end{figure}
%
My final comment
\end{document}
以下是我的新的版本
\documentclass{article}
\usepackage[american]{babel}
\usepackage[acronym,shortcuts]{glossaries}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{natbib}
\usepackage{siunitx}
% Move figures to the end
%\usepackage{endfloat}
% Acronyms
\newacronym{MNA}{MNA}{my nice acronym}
% ------------------------------------
\begin{document}
\section{My section}
\label{sec:mysec}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things \cref{sec:mysec}).
The paralogisms of practical reason are what first give rise to the architectonic of practical reason. As will easily be shown in the next section \ac{MNA}, reason would not be enough \citep{latexcompanion} \SIrange{0}{2}{}.
%
\begin{align}
A(\omega) = J(\omega) + 2
\end{align}
%
My final comment
\bibliographystyle{apalike}
%
\begin{thebibliography}{}
\bibitem[Gossens et~al., 1993]{latexcompanion}
Michel Goossens, Frank Mittelbach, and Alexander Samarin.
\newblock The \LaTeX\ Companion.
\newblock {Addison-Wesley, Reading, Massachusetts}, 1993.
\end{thebibliography}
%
\end{document}
跑步时
latexdiff -t BOLD old.tex new.tex > diff.tex
搞砸endfloat
了如何latexdiff
处理新的缺失数字;这是代码片段没有包endfloat
(figure
环境已被有效删除)
%DIF <
\DIFdelbegin %DIFDELCMD < \begin{figure}[t]
%DIFDELCMD < \centering
%DIFDELCMD < %%%
%DIFDELCMD < \caption{%
{%DIFAUXCMD
\DIFdelFL{Necessity depends on, when thus treated as the practical employment of
the never-ending regress in the series of empirical conditions, time.}}
%DIFAUXCMD
%DIFDELCMD < \label{fig:myfig}
%DIFDELCMD < \end{figure}
%DIFDELCMD < %%%
%DIF <
这是代码片段和包endfloat
(figure
环境不会被删除)
%DIF <
\DIFdelbegin %DIFDELCMD <
\begin{figure}
[t]
%DIFDELCMD < \centering
%DIFDELCMD < %%%
%DIFDELCMD < \caption{%
{%DIFAUXCMD
\DIFdelFL{Necessity depends on, when thus treated as the practical employment of
the never-ending regress in the series of empirical conditions, time.}}
%DIFAUXCMD
%DIFDELCMD < \label{fig:myfig}
%DIFDELCMD <
\end{figure}
%DIFDELCMD < %%%
%DIF <
另一个问题是,如果我使用\SIrange{0}{1}
,即不带第三个参数,\SIrange{0}{1}{}
编译也会因错误而退出。
我不知道这有多大帮助,但我想与那些可能遇到类似问题的人分享。干杯
答案1
endfloat 的问题是一个影响 latexdiff 当前版本和旧版本(1.2.0 及更早版本)的错误。
您必须在函数 postprocess() 中修补 latexdiff 脚本中的两行:
# eliminate whitespace before and after
s/^(\s*)(\\(?:begin|end)\{(?:figure|table)\})(\s*)$/$2/mg;
# split lines with remaining characters before float enviroment commmand
- s/^(.+)(\\(?:begin|end)\{(?:figure|table)\})/$1\n$2/mg;
+ s/^([^%]+)(\\(?:begin|end)\{(?:figure|table)\})/$1\n$2/mg;
# split lines with remaining characters after float enviroment conmmand
- s/(\\(?:begin|end)\{(?:figure|table)\})(.+)$/$1\n$2/mg;
+ s/^((?:[^%]+)\\(?:begin|end)\{(?:figure|table)\}(?:\[[a-zA-Z]+\])?)(.+)((?:%.*)?)$/$1\n$2$3/mg;
}
或者,从 latexdiff github 站点获取最新版本,或等待下一个版本(请注意,github 版本处理了一些转义 % 符号的病理情况,而 patch 没有处理)
答案2
我想我找到了问题所在。在剥离部分代码以发布 MWE 时,我意识到问题发生在我的文档的新版本中删除图形时。出于某种原因,此类问题与 的使用有关endfloat
。
鉴于我的 MWE 如下老的版本
\documentclass{article}
\usepackage[american]{babel}
\usepackage[acronym,shortcuts]{glossaries}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{natbib}
\usepackage{siunitx}
% Move figures to the end
%\usepackage{endfloat}
% Acronyms
\newacronym{MNA}{MNA}{my nice acronym}
% ------------------------------------
\begin{document}
\section{My section}
\label{sec:mysec}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things). This is nonsense.
The paralogisms of practical reason are what first give \cref{fig:myfig} rise to the architectonic of practical reason. As will easily be shown in the next section, reason would \SIrange{0}{1}{}.
%
\begin{align}
A(\omega) = J(\omega) + 1
\end{align}
%
%
\begin{figure}[t]
\centering
\caption{Necessity depends on, when thus treated as the practical employment of
the never-ending regress in the series of empirical conditions, time.}
\label{fig:myfig}
\end{figure}
%
My final comment
\end{document}
以下是我的新的版本
\documentclass{article}
\usepackage[american]{babel}
\usepackage[acronym,shortcuts]{glossaries}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{natbib}
\usepackage{siunitx}
% Move figures to the end
%\usepackage{endfloat}
% Acronyms
\newacronym{MNA}{MNA}{my nice acronym}
% ------------------------------------
\begin{document}
\section{My section}
\label{sec:mysec}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things \cref{sec:mysec}).
The paralogisms of practical reason are what first give rise to the architectonic of practical reason. As will easily be shown in the next section \ac{MNA}, reason would not be enough \citep{latexcompanion} \SIrange{0}{2}{}.
%
\begin{align}
A(\omega) = J(\omega) + 2
\end{align}
%
My final comment
\bibliographystyle{apalike}
%
\begin{thebibliography}{}
\bibitem[Gossens et~al., 1993]{latexcompanion}
Michel Goossens, Frank Mittelbach, and Alexander Samarin.
\newblock The \LaTeX\ Companion.
\newblock {Addison-Wesley, Reading, Massachusetts}, 1993.
\end{thebibliography}
%
\end{document}
跑步时
latexdiff -t BOLD old.tex new.tex > diff.tex
搞砸endfloat
了如何latexdiff
处理新的缺失数字;这是代码片段没有包endfloat
(figure
环境已被有效删除)
%DIF <
\DIFdelbegin %DIFDELCMD < \begin{figure}[t]
%DIFDELCMD < \centering
%DIFDELCMD < %%%
%DIFDELCMD < \caption{%
{%DIFAUXCMD
\DIFdelFL{Necessity depends on, when thus treated as the practical employment of
the never-ending regress in the series of empirical conditions, time.}}
%DIFAUXCMD
%DIFDELCMD < \label{fig:myfig}
%DIFDELCMD < \end{figure}
%DIFDELCMD < %%%
%DIF <
这是代码片段和包endfloat
(figure
环境不会被删除)
%DIF <
\DIFdelbegin %DIFDELCMD <
\begin{figure}
[t]
%DIFDELCMD < \centering
%DIFDELCMD < %%%
%DIFDELCMD < \caption{%
{%DIFAUXCMD
\DIFdelFL{Necessity depends on, when thus treated as the practical employment of
the never-ending regress in the series of empirical conditions, time.}}
%DIFAUXCMD
%DIFDELCMD < \label{fig:myfig}
%DIFDELCMD <
\end{figure}
%DIFDELCMD < %%%
%DIF <
另一个问题是,如果我使用\SIrange{0}{1}
,即不带第三个参数,\SIrange{0}{1}{}
编译也会因错误而退出。
我不知道这有多大帮助,但我想与那些可能遇到类似问题的人分享。干杯