更改包 - 将删除和替换的文本放入(缩写)注释中

更改包 - 将删除和替换的文本放入(缩写)注释中

我正在使用变更包并在此基础上进行构建问题。

我基本上想将所有已删除和替换的文本放在 (缩写的) 评论中。我该怎么做?

参见下面的示例。我希望实现该结果,而不必为每个替换和删除的命令输入注释,并且还希望确保注释是缩写的。

\documentclass{article}

\usepackage{changes}

\makeatletter
\setdeletedmarkup{\@gobble{#1}}
\makeatother

\begin{document}
Alas my love you do me \replaced[comment={(replaced): wrong}]{wrong}{right}, 
to cast me off\deleted[comment={(deleted): discourteously}]{discourteously}.
For I have loved you \replaced[comment={(replaced): well}]{badly}{well} \added{and poorly}, 
delighted in your \replaced[comment={(replaced): company}]{company}{corporation}.

To repeat: \deleted[comment={(deleted): Alas my love you do[...]}]{Alas my love you do me wrong, to cast me off discourteously.}

\listofchanges

\end{document}

在此处输入图片描述

答案1

部分尝试:

  • comment={...}已自动设置。
  • 调整了边注的字体大小。
  • \truncateto{<num>}{<text>}提供截断<text>以保留最多<num>单词。希望这能有所帮助。
\documentclass{article}

% control the fontsize
\PassOptionsToPackage{textsize=scriptsize}{todonotes}

\usepackage{changes}
\usepackage{xpatch}

%\usepackage{unravel}
%\unravelsetup{max-action=1000, max-input=1000, max-output=1000}
\providecommand\unravel[1]{#1}


% auto insert "comment"
\makeatletter
\xpatchcmd\replaced
  {\setkeys{Changes@replaced}{#1}}
  {\setkeys{Changes@replaced}{comment={(replaced): \protect\truncateto{6}{#2}}, #1}}
  {}{\fail}
\xpatchcmd\deleted
  {\setkeys{Changes@deleted}{#1}}
  {\setkeys{Changes@deleted}{comment={(deleted): \protect\truncateto{6}{#2}}, #1}}
  {}{\fail}

% fix \listofchanges
\xpatchcmd\ChangesListline
  {0px}
  {0pt}
  {}{\fail}


\newcounter{truncate}
\newcounter{truncate@max}

% truncate #2 to leave at most first #1 words
\def\truncateto#1#2{%
  \setcounter{truncate}{0}%
  \setcounter{truncate@max}{#1}%
  \truncate@loop{#2}%
}

\def\truncate@loop#1{%
  \ifnum\c@truncate=\c@truncate@max
    \def\next{[...]}% tail
  \else
    \in@{ }{#1}%
    \ifin@
      \stepcounter{truncate}%
      \truncate@split#1\@nil
    \else
      \def\next{#1}%
    \fi
  \fi
  \next
}

\def\truncate@split#1 #2\@nil{%
  \def\next{#1 \truncate@loop{#2}}%
}
\makeatother

\makeatletter
\setdeletedmarkup{\@gobble{#1}}
\makeatother


\begin{document}
Alas my love you do me \replaced{wrong}{right}, 
to cast me off\deleted{discourteously}.
For I have loved you \replaced{badly}{well} \added{and poorly}, 
delighted in your \replaced{company}{corporation}.

To repeat: \deleted{Alas my love you do me wrong, to cast me off discourteously.}

\listofchanges
\end{document}

在此处输入图片描述

更多说明:

  • 在 中\listofchangeschanges使用长度单位px,这是 pdfTeX 添加的,但 XeTeX 不支持。因此我将其替换pxpt。请参阅问题changes/#78在 GitLab 上。

相关内容