Changes

From Wiki
Revision as of 00:38, 5 August 2004 by Brooks (talk | contribs) (Added link to downloadable .tex file, changed link to .pdf file slightly.)
Jump to navigation Jump to search

At my work, we have to add some sort of revision history to certain documents.

A downloadable version of the macro is available here, and a PDF example of the output here.

\useregime[il1]
\enableregime[il1]
\useencoding[ffr]
\definehspace[fr][:][.16667em]
\definehspace[fr][;][.16667em]
\definehspace[fr][!][.16667em]
\definehspace[fr][?][.16667em]
\mainlanguage[fr]
\newdimen\BigWidth \BigWidth=18cm
\setupscreens[screen=0.85]
\setupcolors[state=start]
\setupheadertexts[Rév.: \the\RevC]
\def\Vfil{\vskip0pt plus3fil\relax}
\def\In[#1,#2]{\ifx#1\empty\else\in[#1]\fi\if\relax#2\else, \In[#2]\fi}
\def\BigTitle{\centerline{\framed[width=\BigWidth,offset=2mm,
      background=screen]{\bfb\setupinterlinespace\cbox{Title}}}}

\def\startChanges{\hbox to \hsize\bgroup\hss\SetTableToWidth{\BigWidth}%
  \starttable[s1 | c | c | p(95mm) | p(17mm) | p(37mm) |]
  \HL\BL[5]\AR\VL Rév.\VL Date\VL Origine de la mise à jour\VL§ modifié\VL
  Auteur\VL\AR\HL}
\def\stopChanges{\stoptable\hss\egroup}\newcount\RevC
\def\Changes#1#2#3#4{\ifnum\RevC=0\BigTitle\vskip0.5ex\Vfil\startChanges\fi
  \global\advance\RevC by 1\VL\the\RevC\VL#1\VL#2\VL\In[#3,\relax]\VL
  #4\VL\AR\HL}
\def\Destinataires#1{\stopChanges\Vfil
  \def\temp{#1}\ifx\temp\empty\else\noindenting Destinataires:\crlf#1\blank\fi
\centerline{\SetTableToWidth{\BigWidth}%
\bf\starttable[| c | c | c |]
\HL\BL[3]\AR\VL Approbateur\VL Date\VL Visa\VL\AR\HL
\VL\vbox to 2cm{}\VL\VL\VL\AR\HL
\stoptable}\par\page\completecontent}

\starttext
\Changes{1/2/2004}{First version}{}{Peter}
\Changes{3/4/2004}{Some modifications}{sec:S1,sec:S2}{Peter Münster}
\Changes{5/6/2004}{Some other modifications}{sec:S2}{Peter}
%
\Destinataires{Peter, Olivier}

\section[sec:S1]{A section}
some text
\subsection{Bla}
\subsection{Bla}

\section[sec:S2]{Another section}
some text
\stoptext