From fc416931f4cc4fc8797c441d7a68b37ad37a153f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 13 Jan 2006 00:11:01 +0000 Subject: vhistory git-svn-id: svn://tug.org/texlive/trunk@1440 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/vhistory/sets.sty | 426 ++++++++++++++++++++++ Master/texmf-dist/tex/latex/vhistory/vhistory.sty | 330 +++++++++++++++++ 2 files changed, 756 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/vhistory/sets.sty create mode 100644 Master/texmf-dist/tex/latex/vhistory/vhistory.sty (limited to 'Master/texmf-dist/tex/latex/vhistory') diff --git a/Master/texmf-dist/tex/latex/vhistory/sets.sty b/Master/texmf-dist/tex/latex/vhistory/sets.sty new file mode 100644 index 00000000000..2a16a869cbc --- /dev/null +++ b/Master/texmf-dist/tex/latex/vhistory/sets.sty @@ -0,0 +1,426 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% PACKAGE: sets %% +%% FILE: sets.sty %% +%% %% +%% AUTHOR: Jochen Wertenauer %% +%% VERSION: 1.0 %% +%% DATE: 2005-02-17 %% +%% %% +%% LICENSE: This program may be distributed and/or modified under the %% +%% conditions of the LaTeX Project Public License, either version 1.2 %% +%% of this license or (at your option) any later version. %% +%% The latest version of this license is in %% +%% http://www.latex-project.org/lppl.txt %% +%% and version 1.2 or later is part of all distributions of LaTeX %% +%% version 1999/12/01 or later. %% +%% %% +%% This program consists of the file sets.sty (this file). %% +%% %% +%%--------------------------------------------------------------------------%% +%% DESCRIPTION (see separate file for more information): %% +%% This package allows basic usage of sets. A set has the structure: %% +%% set --> {contents} %% +%% contents --> element(|element)* %% +%% contents --> \epsilon %% +%% A element can consist of strings and command tokens. Command tokens %% +%% will not be expanded before you call \listset. Command tokens with %% +%% parameters (in {}) are not allowed, i.e. \textbf{Test} would result in %% +%% lots of errors. Defining a macro \boldTest %% +%% \newcommand{\boldTest}{\textbf{Test}} %% +%% and using that macro would solve the problem. Commands like like "A %% +%% work fine. Of course an element cannot contain the character | (but %% +%% you can "hide" it in a command like \boldTest, too). %% +%% Another forbidden element is the command \endset. %% +%% In this package a set is normally sorted and contains no duplicates %% +%% unless you explicitly want it as it is by using \newsetsimple (but %% +%% several operations will return a sorted set without duplicates). %% +%% An empty set cannot be destinguished from a set that contains only %% +%% the an empty string, i.e. {} is an empty set. %% +%% %% +%% INTERFACE: %% +%% Constructors: %% +%% \newset, \newsetsimple %% +%% Inspectors: %% +%% \sizeofset, \listset, \iselementofset %% +%% Modificators: %% +%% \deleteduplicates, \sortset %% +%% \unionsets, \intersectsets, \minussets %% +%% OTHER COMMANDS: %% +%% \setseparator %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{sets} + +%% Helper Methods ------------------------------------------------------------ + +\let \xpa \expandafter +\def \xxpa{\xpa\xpa\xpa} + +%% Appends #1 to the definition of macro #2. +\def \sets@append #1\to#2{\xpa \def \xpa #2\xpa{#2#1}} + +%% Removes the first character of the content of #2 and stores the result in +%% #1. Note that \xpa\xpa\xpa cannot be replaced by \xxpa here! +\def \sets@gobblefirst #1#2{% + \xxpa \def \xpa\xpa\xpa #1\xpa\xpa\xpa {\xpa\@gobble #2}} + +%% Deletes everthing to the next occurance of > inludung the >. +\def \sets@erasetobrace #1>{} + +%% A do-while construct based on the macro of Alois Kabelschacht. +%% +%% Syntax: +%% \loop +%% ... +%% \if ... +%% \repeat +\def \sets@loop #1\repeat{% + \def \iterate {#1\xpa \iterate\fi}% + \iterate \let\iterate\relax} + +\long\def \sets@ReturnFi #1\fi{\fi #1} +\long\def \sets@ReturnII #1\fi\fi{\fi\fi #1} +\long\def \sets@ReturnIII #1\fi\fi\fi{\fi\fi\fi #1} + +\long\def \sets@ReturnElseIII #1\else#2\fi\fi\fi{\fi\fi\fi #1} + +\long\def \sets@Returntrue #1\fi{\fi \iftrue} +\long\def \sets@Returnfalse #1\fi{\fi \iffalse} + +\newif \ifsets@less \newif \ifsets@greater + +%% Compares to strings. Result will be in \ifgreater and \ifless. +%% #1 and #2 are compared as they are. There will be no expansion. +%% The comparison is based on the position of the symbols in the +%% ASCII table. Therefore the comparison is case sensitive (B`#3 + \ifx |#1 \sets@lesstrue \else \sets@greatertrue \fi%(1) + \else + \ifx |#1\else + \sets@ReturnIII{\sets@compI#2\\#4\relax}% + \fi + \fi + \fi +} +%----------------------------------------------------------------------------- + + + +%% Create a new set ---------------------------------------------------------- + +%% Creates a new set. The set will be sorted and will contain no duplicate +%% elements. +%% +%% Example: \newset{\myset}{Alice|Bob|Charly} +\def \newset #1#2{% + \def #1{#2}% + \sortset{#1}{#1}% + \deleteduplicates{#1}{#1}% +} + +%% Simple constructor of a set. There is no sorting or duplicate detection +%% done by this macro. +%% +%% Example: \newsetsimple{\myset}{Alice|Bob|Charly} +\def \newsetsimple #1#2{\def #1{#2}} +%----------------------------------------------------------------------------- + + + +%% Size determination -------------------------------------------------------- + +%% Stores the size of set #1 in the LaTeX counter #2. #2 has to be existing. +\def \sizeofset #1\is#2{% + \setcounter{#2}{0}% + \xpa\sets@sizeofset #1|\endset{#2}% +} + +% Helper method for \sizeofset. Recursively calls itself. Implemented straight +% forward. +\def \sets@sizeofset #1|#2\endset#3{% + \def \sizetemps@t {#1}% + \ifx \sizetemps@t\empty\else + \stepcounter{#3}% + \def \sizetemps@t{#2}% + \ifx\sizetemps@t\empty\else + \sets@ReturnII{\sets@sizeofset #2\endset{#3}}% + \fi + \fi +} +%----------------------------------------------------------------------------- + + + +%% Printing a set ------------------------------------------------------------ + +%% The content of this macro will be used to separate the elements of the set. +\def \setseparator{,\ } + +%% Prints the contents of set #1. Elements will be separated by \setseparator. +\def \listset #1{\xpa\sets@listset #1|\endset} + +%% Helper method for \listset. +\def \sets@listset #1|#2\endset{% + \def \temps@t{#2}% + #1% + \ifx\temps@t\empty{}\else + \setseparator + \sets@ReturnFi{\sets@listset #2\endset}% + \fi +} +%----------------------------------------------------------------------------- + + + +%% Testing for membership ---------------------------------------------------- + +%% This macro tests, if #1 is included in set #2. Can be used in constructs +%% like \if \iselementofset{...}{...} ... \else ... \fi. It has complexity +%% O(1), assuming that the pattern matching is done in O(1), too. +%% +\def \iselementofset #1#2{% + 00\fi + \begingroup + \def \lookup ##1|#1|##2\endset{% + \def \temp{##2}% + \ifx \temp\empty + \endgroup + \sets@Returnfalse + \else + \endgroup + \sets@Returntrue + \fi}% + \xpa\lookup \xpa |#2|#1|\endset% +} +%----------------------------------------------------------------------------- + + + +%% Duplicate detection: ------------------------------------------------------ + +%% This macro finds alle duplicate elements in the SORTED set #1 and removes +%% them. The result set (still sorted) is stored in #2. +\def \deleteduplicates #1#2{\xpa\sets@duplicates#1|\endset#2} + +%% Helper method for \deleteduplicates. Does some preparations and catches the +%% special case of an set with size <= 1. Parameter #3 is the result set. +\def \sets@duplicates #1|#2\endset#3{% + \def #3{}% Clear #3 + \def \temps@t{#2}% + \ifx \temps@t\empty% Has the set more than one element? + \def #3{#1}% Just one element! + \else% More than one element + \sets@ReturnFi{\sets@duplicatesI#1|#2\endset#3}% + \fi +} + + +%% Called by \sets@duplicates, if the sorted set contains two or more elements. It +%% checks, if two elements, which are directly following each other are equal. +%% If yes, the first one will not be part of the result set, which is stored +%% in #4. +\def \sets@duplicatesI #1|#2|#3\endset#4{% + \def\temps@ti{#1}% + \def\temps@tii{#2}% + \def\temps@tiii{#3}% + \ifx \temps@tii\empty % Is #2 empty? + \def #4{#1}% A set with one element has no duplicates + \else % #2 not empty --> at least two elements (left) + \ifx \temps@tiii\empty% Is #3 empty? + % The set contains two elements, so work is nearly done. + % An additional | was inserted at the beginning. It has to be gobbled + % away. + \ifx \temps@ti\temps@tii % #1=#2 + \sets@append{|#1}\to#4% + \sets@gobblefirst{#4}{#4}% + \else + \sets@append{|#1|#2}\to#4% + \sets@gobblefirst{#4}{#4}% + \fi + \else % #3 not empty --> at least three elements (left) + \ifx \temps@ti\temps@tii + \sets@ReturnElseIII{\sets@duplicatesI #2|#3\endset#4}% + \else + \sets@append{|#1}\to#4% + \sets@ReturnIII{\sets@duplicatesI #2|#3\endset#4}% + \fi + \fi + \fi +} +%----------------------------------------------------------------------------- + + + +%% Sorting a set ------------------------------------------------------------- +\newcounter{s@tlength} % LaTeX-counter used by \sortset. + +%% Takes an unsorted set #1, sorts it and stores the result in #2. If #1 has +%% less than two elements, sorting is unneccessary, otherwise \sets@sortset is +%% called. +%% +%% Syntax \sortset +\def \sortset #1#2{% + \sizeofset#1\is{s@tlength}% + \ifnum 2>\value{s@tlength}\relax + \let #2 #1% + \else + \sets@sortset #1#2% + \fi +} + +%% Called by \sortset. This macro represents the outer loop of the bubblesort +%% algorithm. Bubblesort has O(n^2) and is stable. +%% +\def \sets@sortset #1#2{% + \let \sorttemps@t #1% + \sets@loop + \xpa\sets@bubblesortRun \sorttemps@t|\endset\sorttemps@t + \addtocounter{s@tlength}{-1}% + \ifnum 1<\value{s@tlength}\relax + \repeat + \let #2 \sorttemps@t +} + +%% Called by \sets@sortset. Does some preparation for \sets@bubblesortRunI and +%% removes the first character of the result. #4 is the result set. +\def \sets@bubblesortRun #1|#2|#3\endset#4{% + \def\temps@t{}% + \sets@bubblesortRunI #1|#2|#3\endset\temps@t% + \sets@gobblefirst{#4}{\temps@t}% +} + +%% Called by \sets@bubblesortRun and recursively by itself. +%% This recursive macro represents the inner loop of "normal" bubblesort. +%% #4 is the result set. +\def \sets@bubblesortRunI #1|#2|#3\endset#4{% + \def\temps@tii{#2}% + \def\temps@tiii{#3}% + \ifx \temps@tii\empty + \sets@append{|#1}\to#4% + \else + \ifx \temps@tiii\empty + \sets@compStrings{#2}{#1}% + \ifsets@greater + \sets@append{|#1|#2}\to#4% + \else + \sets@append{|#2|#1}\to#4% + \fi + \else + \sets@compStrings{#2}{#1}% + \ifsets@greater + \sets@ReturnElseIII{% + \sets@append{|#1}\to#4% + \sets@bubblesortRunI#2|#3\endset#4}% + \else + \sets@ReturnIII{% + \sets@append{|#2}\to#4% + \sets@bubblesortRunI#1|#3\endset#4}% + \fi + \fi + \fi +} +%----------------------------------------------------------------------------- + + + +%% Set manipulation ---------------------------------------------------------- + +%% Takes two sets #1 and #2 and performs a union operation. #1 and #2 do not +%% have to be sorted and may contain duplicate elements. +%% The result is stored in #3. It contains the elements of #1 and #2 and is +%% sorted. Duplicates are removed. +\def \unionsets #1#2\to#3{% + \let\uniont@mpi=#1% + \let\uniont@mpii=#2% + \ifx \uniont@mpi\empty + \let \uniontemps@t=\uniont@mpii + \else + \let \uniontemps@t=\uniont@mpi + \ifx \uniont@mpii\empty \else + \xpa\sets@append\xpa{\xpa|#2}\to\uniontemps@t + \fi + \fi + \sortset{\uniontemps@t}{\uniontemps@t}% + \deleteduplicates{\uniontemps@t}{#3}% +} +%----------------------------------------------------------------------------- + + +%% Takes two sets #1 and #2 and performs an intersect operation. The result is +%% stored in #3. #3 contains only elements that have been in both sets #1 and +%% #2. #1 and #2 don't have to be sorted, but if #1 is sorted, #3 will be +%% sorted, too. If #1 contains duplicates, #3 may also contain duplicates. +\def \intersectsets #1#2\to#3{% + \def \tempinters@ct{}% + \xpa \sets@intersectsets #1|\endset#2\tempinters@ct + \ifx \tempinters@ct\empty + \def #3{}% + \else + \sets@gobblefirst{#3}{\tempinters@ct}% + \fi +} + +%% #1 and #2 are parts of set #1 of \intersectsets. #3 is #2 of \intersectsets +%% #4 is the result set +\def \sets@intersectsets #1|#2\endset#3#4{% + \if \iselementofset{#1}{#3}% + \sets@append{|#1}\to#4% + \fi + \def \tempinters@cti{#2}% + \ifx \tempinters@cti\empty \else + \sets@ReturnFi{\sets@intersectsets #2\endset#3#4}% + \fi +} +%----------------------------------------------------------------------------- + + +%% Takes two sets #1 and #2 and performs a minus operation, i.e. all elements +%% of #1 that are in #2, too, are removed. The result is saved in #3. If #1 is +%% sorted, #3 will be sorted, too. +%% +%% This macro is implemented like \intersectsets. The only difference is, that +%% an element will only be part of #1 if it is NOT in #2. In \intersectsets it +%% will be part if it is in #2. +\def \minussets #1\minus#2\to#3{% + \def \@tempminus{}% + \xpa \sets@minussets #1|\endset#2\@tempminus + \ifx \@tempminus\empty + \def #3{}% + \else + \sets@gobblefirst{#3}{\@tempminus}% + \fi +} + +%% Syntax like \sets@intersectsets, but of course different semantics. +\def \sets@minussets #1|#2\endset#3#4{% + \if \iselementofset{#1}{#3}\else + \sets@append{|#1}\to#4% + \fi + \def \temp@minus{#2}% + \ifx \temp@minus\empty \else + \sets@ReturnFi{\sets@minussets #2\endset#3#4}% + \fi +} +%----------------------------------------------------------------------------- + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput diff --git a/Master/texmf-dist/tex/latex/vhistory/vhistory.sty b/Master/texmf-dist/tex/latex/vhistory/vhistory.sty new file mode 100644 index 00000000000..4ec66de33f8 --- /dev/null +++ b/Master/texmf-dist/tex/latex/vhistory/vhistory.sty @@ -0,0 +1,330 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% PACKAGE: vhistory %% +%% FILE: vhistory.sty %% +%% %% +%% AUTHOR: Jochen Wertenauer %% +%% VERSION: 1.1 %% +%% DATE: 2005-04-12 %% +%% %% +%% LICENSE: This program may be distributed and/or modified under the %% +%% conditions of the LaTeX Project Public License, either version 1.2 %% +%% of this license or (at your option) any later version. %% +%% The latest version of this license is in %% +%% http://www.latex-project.org/lppl.txt %% +%% and version 1.2 or later is part of all distributions of LaTeX %% +%% version 1999/12/01 or later. %% +%% %% +%% This program consists of the file vhistory.sty (this file). %% +%% %% +%%--------------------------------------------------------------------------%% +%% DESCRIPTION (For better documentation see the seperate file.): %% +%% This package allows the creation to create a version history, where %% +%% the changes that have been made to a document are listed. %% +%% The version number of the last entry in the history is accessible (see %% +%% below) with the command \vhCurrentVersion, its date with \vhCurrentDate. %% +%% These commands can can be used for headers or title pages for example. %% +%% The list of all Authors is also available. It is stored in the set %% +%% \vhAllAuthorsSet. It can be printed using \vhListAllAuthors. There is %% +%% another command to list authors: \vhListAllAuthorsLong. This command %% +%% regards all elements in the authorset as commands (those elements do NOT %% +%% have the \ as first character) and expands them (see example below). %% +%% The sorting is based on the shortcuts and not on the expansion text! %% +%% %% +%% Note: The commands mentioned above work even before the version his- %% +%% tory specified. Therefore you need two runs of LaTeX. If 'N/A' is dis- %% +%% played instead of the correct number, you forgot the second run. %% +%% %% +%% OPTIONS: %% +%% - tocentry: If provided, the version history will show up in the table %% +%% of contents. By default it will not be added. %% +%% - nochapter: If provided, vhHistory will not start a new chaper/section %% +%% Use this option, if \section is undefined! %% +%% - owncaptions: You have to specify your own names for the captions. Use %% +%% this option if you are using a language that is not %% +%% supported. %% +%% %% +%% REQUIRED PACKAGES: %% +%% - sets: Works well with version 0.6 or higher %% +%% - ltxtable: Works well with version 0.2 from 1995-12-11 %% +%% ltxtable requires tabularx and longtable. Versions %% +%% - 2.07 (1999-01-07) of tabularx and %% +%% - 4.10 (2000-10-22) of longtable %% +%% worked fine. %% +%% %% +%% EXAMPLE OF USAGE: %% +%% For a better documentation see the seperate file. %% +%% %% +%% \usepackage{vhistory} %% +%% ... %% +%% \newcommand{\AH}{Alice Hosle} % NOTE: All names are invented. %% +%% \newcommand{\XY}{Mr. X} %% +%% \newcommand{\CR}{Charles Richards} %% +%% ... %% +%% \begin{document} %% +%% ... %% +%% \date{Version \vhCurrentVersion from \vhCurrentDate} %% +%% \author{\vhListAllAuthorsLong} %% +%% ... %% +%% \begin{versionhistory} %% +%% % Note the syntax of \vhEntry! Authors are separated by `|' %% +%% \vhEntry{0.1}{2004-04-23}{AH|XY}{Structure of chapters.} %% +%% \vhEntry{0.2}{2004-04-24}{AH|CR}{Chapter introduction completed} %% +%% \vhEntry{1.0}{2004-05-30}{XY}{spelling corrected} %% +%% \end{versionhistory} %% +%% ... %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{vhistory} +\RequirePackage{ltxtable, sets} + +%% Helper methods ------------------------------------------------------------ +\let \xpa=\expandafter +\let \nxp=\noexpand + +\long\def \vh@ReturnFi #1\fi{\fi #1} + +%% Copied from the TeXbook +\def \vh@Ifundefined #1{\expandafter\ifx\csname#1\endcsname\relax} + +%% Prints the content of macro #1 without expansion. +\long \def \vh@verbprint #1{\xpa\vh@eraseToBrace\meaning #1} + +%% This macro writes #2 verbatim to the (open) file #1. +\long \def \vh@verbwrite #1#2{% + \long \def \vh@verbtemp{#2}% + \xpa\write\xpa#1\xpa{\xpa\vh@eraseToBrace \meaning\vh@verbtemp}% +} + +%% Deletes everything before the next > e.g. "macro ->". Used by \vh@verbprint +\def \vh@eraseToBrace #1>{} +%% --------------------------------------------------------------------------- + +%% Multilanguage support ----------------------------------------------------- +\def \vh@setcaptions{% + \ifnum \vh@owncaptions=0% Defined by the options + \vh@EnglishCaptions %Default + \vh@Ifundefined{l@ngerman}\else + \ifnum \language=\l@ngerman\relax + \vh@GermanCaptions + \fi + \fi + \vh@Ifundefined{l@german}\else + \ifnum \language=\l@german\relax + \vh@GermanCaptions + \fi + \fi + \vh@Ifundefined{l@austrian}\else + \ifnum \language=\l@austrian\relax + \vh@GermanCaptions + \fi + \fi + \fi +} + +\def \vh@EnglishCaptions{% + \def\vhhistoryname{History of versions}% + \def\vhversionname{Version}% + \def\vhdatename{Date}% + \def\vhauthorname{Author(s)}% + \def\vhchangename{Changes}% +} + +\def \vh@GermanCaptions{% + \def\vhhistoryname{Versionshistorie}% + \def\vhversionname{Version}% + \def\vhdatename{Datum}% + \def\vhauthorname{Autor(en)}% + \def\vhchangename{\"Anderungen}% +} +%% --------------------------------------------------------------------------- + +%% -- Options ---------------------------------------------------------------- +\def \vh@tocentry{0} % By default, there will be no entry in the toc +\def \vh@nochapter{0} % By default, a new chapter will be started +\def \vh@owncaptions{0} % By default, the build in captions are used. + +\DeclareOption{tocentry}{\def \vh@tocentry{1}} +\DeclareOption{nochapter}{\def \vh@chapter{}} +\DeclareOption{owncaptions}{\vh@setcaptions \def \vh@owncaptions{1}} + +%% This macro starts a new chapter. If \chapter is undefined, \section is +%% used (To work with document class article). The option nochapter will +%% redefine this macro to {}. +%% +\def \vh@chapter{% + \vh@Ifundefined{chapter} + % Since chapter is undefined, we try section. If section is + % undefined, too we've got a problem. The User should use the option + % nochapter in this case. + \ifnum \vh@tocentry=1\relax + \section{\vhhistoryname}% + \else + \section*{\vhhistoryname}% + \fi + \else + \ifnum \vh@tocentry=1\relax + \chapter{\vhhistoryname}% + \else + \chapter*{\vhhistoryname}% + \fi + \fi +} + +\ProcessOptions +%% --------------------------------------------------------------------------- + + +%% Informations accessible to the user --------------------------------------- + +%% This macro will expand to the current version number +\def \vhCurrentVersion{N/A} + +%% This macro will expand to the date of the last change +\def \vhCurrentDate{N/A} + +%% This set will contain all authors mentioned in the version history. +\newsetsimple \vhAllAuthorsSet{} + +%% Just a shortcut :-) +\def \vhListAllAuthors{\listset{\vhAllAuthorsSet}} + +%% Prints the contents of \vhAllAuthorsSet but regards the elements as +%% commands. Instead of XY, the definition of the command \XY will be used. +%% If \XY is undefined, \relax is used. +\def \vhListAllAuthorsLong{\xpa\vh@longlistset \vhAllAuthorsSet|\endset} + +%% Helper method for \vhListAllAuthorsLong. +\def \vh@longlistset #1|#2\endset{% + \def \vh@tempset{#2}% + \csname #1\endcsname % Create command and expand + \ifx\vh@tempset\empty{}\else + \setseparator + \vh@ReturnFi{\vh@longlistset #2\endset}% + \fi +} + +%% --------------------------------------------------------------------------- + + +%% -- Read file \jobname.hst, if existing ------------------------------------ +\IfFileExists{\jobname.hst}% +{\typeout{Reading file \jobname.hst...}\input{\jobname.hst}} % File exists +{\typeout{File \jobname.hst not found.}} % File doesn't exist. +%% --------------------------------------------------------------------------- + + +%% The environment versionhistory. +%% +%% At first the macro \decl@revhEntry will be called to allow the user to add +%% entries to the version history. Second step is to write the tables's head. +%% Third step is to delete previous contents of vhAllAuthorsSet. Now the +%% captions of the actual language are loaded. Last step is to start a new +%% chapter if the user wanted a new chapter. +%% At the end of the version history, the table's foot is written to the +%% \@verfile. Then the .hst file is written. Afterwards the command \vhEntry +%% is undeclared to prevent the user from making nonsense. The last step is +%% to load the table as a LTXtable, if the file exists. +%% +\newenvironment{versionhistory}{% + \vh@declarevhEntry + \vh@writeTable + \newsetsimple \vhAllAuthorsSet{}% + \vh@setcaptions + \vh@chapter +}{ + \vh@writeEndTable + \vh@writeHstFile + \vh@undeclarevhEntry + \IfFileExists{\jobname.ver}{% file exists + \LTXtable{\textwidth}{\jobname.ver}}% + {\@latex@warning{Rerun LaTeX to get the history of versions.}}% +} + + +% This file contains the table that is the history of versions. +\newwrite \vh@verfile + +%% This macro is called, when the environment versionhistory begins. It +%% declares the macro vhEntry, which is used to add entries to the version +%% history. Parameters are: +%% #1: version number +%% #2: date +%% #3: author(s) +%% #4: changes +%% The content of the parameters is written to the file that contains the +%% table with the history of versions. +%% +\def \vh@declarevhEntry{% + \long \gdef \vhEntry ##1##2##3##4{% + \gdef \vhCurrentVersion{##1}% Update version number + \gdef \vhCurrentDate{##2}% Update date + \vh@add{##3}% + \vh@verbwrite \vh@verfile {##1}% + \vh@verbwrite \vh@verfile { & ##2}% + \vh@verbwrite \vh@verfile { & \listset{##3}}% + \vh@verbwrite \vh@verfile { & ##4\\} + }% +} + + +%% Helper macro, called by vhEntry. This macro unions the given author +%% list with the global list of authors. +%% +\def \vh@add #1{% + \newsetsimple{\vh@EntrySet}{#1}% Define a temporary set + \unionsets{\vhAllAuthorsSet}{\vh@EntrySet}\to{\vhAllAuthorsSet}% + \global\let\vhAllAuthorsSet=\vhAllAuthorsSet% Results must be global +} + + +%% This macro is called, when the environment versionHistory is left. It +%% redefines the macro vhEntry, which will now produce an error message. +%% +\def \vh@undeclarevhEntry{% + \long\gdef \vhEntry ##1##2##3##4{% + \errhelp{\vhEntry can only be used in the versionHistory environment.}% + \errmessage{This command is not accessible here.}}% +} + + +%% This macro writes the current version number/date and the set of Authors to +%% the file \jobname.hst. Unwanted expansion of macros must be prevented here. +%% +\def \vh@writeHstFile{% + \newwrite \vh@hstfile% + \openout \vh@hstfile=\jobname.hst% + \write \vh@hstfile {% + \def \nxp\vhCurrentVersion{\vh@verbprint\vhCurrentVersion}}% + \write \vh@hstfile {% + \def \nxp\vhCurrentDate{\vh@verbprint\vhCurrentDate}}% + \write \vh@hstfile {% + \nxp\newsetsimple \nxp\vhAllAuthorsSet{\vh@verbprint\vhAllAuthorsSet}}% + \closeout \vh@hstfile% +} + + +%% This macro is called at the beginning of a versionhistory environment. It +%% writes the head of the resulting table to the file \jobname.ver. The table +%% itself is a LTXtable, i.e. a longtable with the parameterset of tabularx. +%% +\def \vh@writeTable{% + \openout \vh@verfile=\jobname.ver% + \vh@verbwrite \vh@verfile% + {\begin{longtable}{ll>{\hsize=.5\hsize}X>{\hsize=1.5\hsize}X}}% + \vh@verbwrite \vh@verfile {\textbf{\vhversionname}}% + \vh@verbwrite \vh@verfile { & \textbf{\vhdatename}}% + \vh@verbwrite \vh@verfile { & \textbf{\vhauthorname}}% + \vh@verbwrite \vh@verfile { & \textbf{\vhchangename}\\[1ex]}% +} + + +%% This macro writes the end of the table that \vh@writeTable has begun. +%% +\def \vh@writeEndTable{% + \vh@verbwrite \vh@verfile{\end{longtable}}% + \closeout \vh@verfile% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput -- cgit v1.2.3