Changes

Jump to navigation Jump to search
3,420 bytes added ,  08:12, 11 October 2019
Some documents need to evolve, here is a simple way to track the changes.
< [[Sample documents]]

Some documents need to evolve. Laws change, a client changes their mind.
While working on a project I like to see the changes but when the project is finished I only need the final document.

The following document creates both documents from a single source.
It offers two change histories, one by version number and one by date.
In a normal document you would probably only use one.

<texcode>
% !TEX encoding = UTF-8 Unicode

% Copyright 2018 - 2019 Axel Kielhorn
% Lizenz: CC-BY-SA 4.0 Unported http://creativecommons.org/licenses/by-sa/4.0/deed.de

% Enable to print changes, disable for final document
%\enablemode[change]

\setuppapersize [A4][A4]
\setuplayout [width=middle, backspace=1.5in, cutspace=1.5in,
height=middle, topspace=0.75in, bottomspace=0.75in]

\setupbodyfont[11pt]

% Colo[u]rs
\definecolor[ChrC][red]
\definecolor[ChaC][darkgreen]
\definecolor[ChcC][blue]

% Register for version
\defineregister [changev]
\setupregister [changev] [
indicator=no %% no letter
style=sansbold, %% headings
textstyle=slanted, %% entries
pagestyle=bolditalic, %% page refs
n=1, %% columns
]

% Register for date
\defineregister [changed]
\setupregister [changed] [
indicator=no %% no letter
style=sansbold, %% headings
textstyle=slanted, %% entries
pagestyle=bolditalic, %% page refs
n=1, %% columns
]

% Change marker and short version for register
% by version number
\def\ChangeV#1#2{\changev{#1+#2}%
\doifmode{change}{\inmargin{\tx #1}{\ChcC #2\par}}}
% by date
\def\ChangeD#1#2{\changed{#1+#2}%
\doifmode{change}{\inmargin{\tx #1}{\ChcC #2\par}}}

% Inline change
\def\Changer#1{{\doifmode{change}{\ChrC #1}}} % removed
\def\Changea#1{{\doifmode{change}{\ChaC}#1}} % added
\def\Changec#1#2{{\doifmode{change}{\ChrC #1\ChaC}#2}} % changed

% Paragraph added
\definestartstop[ChangePA][
before={\doifmode{change}{\startsidebar[rulecolor=ChaC]}},
after={\doifmode{change}{\stopsidebar}},
]
% Paragraph removed
\definestartstop[ChangePR][
before={\doifmode{change}{\startsidebar[rulecolor=ChrC]}},
after={\doifmode{change}{\stopsidebar}},
]

\starttext

This is the initial document without version number.

\ChangeV{V. 1.0}{First release}
This is the first released version.

\startChangePA
\ChangeV{V. 2.0}{Source added}
\input knuth
\stopChangePA

\ChangeD{2019-10-10}{ConTeXt Wiki release}
\startChangePA
This paragraph was added or the Wiki release.
\stopChangePA

\ChangeD{2019-10-11}{Translation improved}

Beware of \Changec{tyops}{typos}.

\startChangePA
\ChangeV{V. 2.0}{Global colo[u]rs}
There are now three colo[u]rs \type{ChrC} and \type{ChaC} to
mark removed and added text and \type{ChcC} for the comments.
\stopChangePA

\startChangePR
\ChangeV{V. 3.0}{Obsolete syntax}
The commands \type{\ChangePA} (Paragraph added) and
\type{\ChangePR}(Paragraph removed) mark changed paragraphs.
\stopChangePR

\startChangePA
Added paragraphs are marked by \type{\startChangePA} and \type{\stopChangePA}, removed paragraphs by \type{\startChangePR} and \type{\stopChangePR}
\stopChangePA
Information about the change must be added with \type{ChangeV} or \type{ChangeD} commands.

\startsection[title={History}]

By version nummer:

\placechangev

\blank[big]
By date:

\placechanged

\stopsection
\stoptext
</texcode>

[[Category:Sample documents]]
4

edits

Navigation menu