![更改包 - 将删除和替换的文本放入(缩写)注释中](https://linux22.com/image/414125/%E6%9B%B4%E6%94%B9%E5%8C%85%20-%20%E5%B0%86%E5%88%A0%E9%99%A4%E5%92%8C%E6%9B%BF%E6%8D%A2%E7%9A%84%E6%96%87%E6%9C%AC%E6%94%BE%E5%85%A5%EF%BC%88%E7%BC%A9%E5%86%99%EF%BC%89%E6%B3%A8%E9%87%8A%E4%B8%AD.png)
我正在使用变更包并在此基础上进行构建这问题。
我基本上想将所有已删除和替换的文本放在 (缩写的) 评论中。我该怎么做?
参见下面的示例。我希望实现该结果,而不必为每个替换和删除的命令输入注释,并且还希望确保注释是缩写的。
\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}
更多说明:
- 在 中
\listofchanges
,changes
使用长度单位px
,这是 pdfTeX 添加的,但 XeTeX 不支持。因此我将其替换px
为pt
。请参阅问题changes/#78
在 GitLab 上。