Replace each instance of \added
with \xadded
in your source file. Define \xadded
appropriately. Do the same for the other two change commands. You can do that with awk (as below) or with search and replace in your favorite editor.
version1.tex:
\documentclass{article}
\usepackage{changes}
% Example of what first revision may be
\newcommand{\xadded}[1]{#1}
\newcommand{\xdeleted}[1]{}
\newcommand{\xreplaced}[2]{#1}
\begin{document}
This is \added{new} text. This is more \added{new text with
\emph{embedded} \TeX{} on more than one line.}
This is \deleted{unnecessary}text.
This is \replaced{nice}{bad} text.
\end{document}
version2.tex, after replacement:
\documentclass{article}
\usepackage{changes}
% Example of what first revision may be
\newcommand{\xadded}[1]{#1}
\newcommand{\xdeleted}[1]{}
\newcommand{\xreplaced}[2]{#1}
\begin{document}
This is \xadded{new} text. This is more \xadded{new text with
\emph{embedded} \TeX{} on more than one line.}
This is \xdeleted{unnecessary}text.
This is \xreplaced{nice}{bad} text.
\end{document}
The script I used:
#!/usr/bin/awk
# Rename a few TeX macros
#
{
gsub(/\\added/,"\\xadded",$0);
gsub(/\\deleted/,"\\xdeleted",$0);
gsub(/\\replaced/,"\\xreplaced",$0);
print
}
Leaving my original awkward partial solution for a little while.
Here's the start of awk
program to expand the three macros.
#!/usr/bin/awk
# Expand a few TeX macros
#
# delete the macro name
# leaving the parentheses doesn't hurt
/\\added/ {
sub(/\\added/,"",$0)
}
# delete the macro name and its argument
/\\deleted/ {
sub(/\\deleted.*\}/,"",$0)
}
# should delete the macro name and its SECOND argument
/\\replaced/ {
sub(/\\replaced/,"",$0)
}
{print}
Calling the OP's input file expandsome.tex, the command
$ awk -f expand.awk < expandsome.tex > expanded.tex
produces
documentclass{article}
\usepackage{changes}
% Example of what first revision may be
\begin{document}
This is {new} text.
This is text.
This is {nice}{bad} text.
\end{document}
I haven't yet figured out the regular expression syntax for deleting the second argument to \replace
. I have no time now. If someone wants to contribute then I won't have to find the time tomorrow or the day after ...
This is not a robust solution. If a change spreads over more than one line it will fail. It will also fail for multiple similar changes on any single line.
Your current document has the following errors or problems:
\mathbbC}
-> \mathbb{C}
;
changes
does not define \delete
, only \deleted
;
You need to define the author/id MD
as a "change author" before you can use it, so you need \definechangesauthor[<options>]{MD}
after loading \usepackage{changes}
;
It's not advised to use \\
for a paragraph break. Leave a blank line or issue an explicit \par
. If you don't enjoy the indentation, see Turn off paragraph indention for a single line. Alternatively, \setlength{\parindent}{0pt}
will remove all paragraph indentation in your document.
Here is a complete minimal example:
\documentclass{article}
\usepackage{amssymb,changes}
\definechangesauthor{MD}
\begin{document}
Analysis is all about the theory behind Calculus. In this course, we do not
take for granted such notions as what the set~$\mathbb{R}$ of real numbers
is; rather we carefully define~$\mathbb{R}$ by `building' it out of other
sets---beginning with the set~$\mathbb{N}$ of Natural Numbers. Numbers and
number systems (\textit{i.e.\/}\ $\mathbb{N}$, $\mathbb{Z}$,
$\mathbb{Q}$,~$\mathbb{R}$ and~$\mathbb{C}$) are the `building-blocks' of
Analysis. Here in this book, we do not merely state the properties of the
Real Number System, but we derive them.
However, \deleted[id=MD,remark=blah blah blah]{Would you like any toast?}
before we do that (and we shall in Chapter 1), we first
\deleted[id=MD,remark=blah blah blah]{present} this introductory
chapter---Chapter~0---in order to give the reader the tools needed to carry
on this study of the branch of mathematics known as Analysis. Here, we
present a `brief' review of Mathematical Logic, Set Theory, Functions, and
Relations; and we `informally' define a few sets of which we shall make
frequent use of in Analysis. All of them (or most of them) shall be dealt
with more formally in the next chapter.
\end{document}
Best Answer
Here is a version that produces the required result:
Output:
The
\Changes@Markup@Deleted
macro is what produces the highlighted replaced text (based on whatever style is set). We just define it to ignore its argument such that the produced text is always empty.