[comp.text.tex] Integrating RCS and LaTeX

jbtubman@arc.ab.ca (Jim Tubman) (04/18/91)

I have been doing version control on my LaTeX documents using the
Revision Control System (RCS) from Walter F. Tichy of Purdue
University.  RCS has a feature that allows you to put certain
information (such as dates, revision numbers, etc.) into the body of a
text file by including a keyword between dollar signs.  Thus
$Revision$ gets turned into $Revision: 1.2$ in the body of the text
when processed by the RCS programs.

I'd like to use this to put version numbers into my LaTeX documents,
but unfortunately, LaTeX interprets the dollar signs as signifying an
in-text formula.

Has anyone who uses both RCS and LaTeX come up with a good work-around
to this problem that they'd be willing to share?  Thanks.

--Jim Tubman
-- 
-------------------------------------------------------------------------------
James B. Tubman				 Alberta Research Council
Expert Systems Researcher                Advanced Computing & Engineering Dept.
jbtubman@noah.arc.ab.ca			 3rd Floor

hrp@cray.com (Hal Peterson) (04/19/91)

Between the lines of equal signs is some code from the preamble of one
of my documents.  It would be much simpler if I weren't fussy about
the format of the date.

=================================================================
\makeatletter

{\catcode`\$=12
 % Define a LaTeX macro from an RCS keyword.
 \def\@RCS@define$#1: #2 ${\expandafter\gdef\csname RCS#1\endcsname{#2}}
 \@RCS@define$Revision$
 % RCSDate is a special case because the default format---yy/mm/dd---is
 % too ugly for human consumption.
 \def\@RCS@date$#1: #2/#3/#4 #5${\gdef\RCSDate{%
   \@tempcnta#3\@tempcntb#2\relax
   #4\space
   \ifcase\@tempcnta\or January\or February\or March\or April\or May\or June\or
   July\or August\or September\or October\or November\or December\fi
   \space\ifnum\@tempcntb < 100 19\fi#2%
  }
 }
 \@RCS@date$Date$
}

\def\today{\RCSDate}

\makeatother

=================================================================

Unfortunately, there's no way to put it in a .sty file, because then
the RCS information would apply to the .sty file rather than to the
.tex file.
--
Hal Peterson			Internet:  hrp@cray.com
Cray Research, Inc.		Telephone:  +1 612 683 5440
	Laws create nature.	-Andrea Dworkin

metz@donald.iam.unibe.ch (Igor Metz) (04/19/91)

In article <1991Apr17.205440.23660@arc.ab.ca>, jbtubman@arc.ab.ca (Jim Tubman) writes:
|> I'd like to use this to put version numbers into my LaTeX documents,
|> but unfortunately, LaTeX interprets the dollar signs as signifying an
|> in-text formula.

This is really trivial:

    $$Revision$$

-- 
Igor Metz
Institut fuer Informatik und angew. Mathematik, Universitaet Bern, Switzerland.
domainNet: metz@iam.unibe.ch               Phone: (0041) 31 65 49 90
ARPA:      metz%iam.unibe.ch@relay.cs.net  Fax:   (0041) 31 65 39 65

boogaard@fys.ruu.nl (Martin vdBoogaard) (04/19/91)

Jim writes:

% RCS has a feature that allows you to put certain
% information (such as dates, revision numbers, etc.) into the body of a
% text file by including a keyword between dollar signs.
% 
% I'd like to use this to put version numbers into my LaTeX documents,
% but unfortunately, LaTeX interprets the dollar signs as signifying an
% in-text formula.

The most straightforward solution I can think of is to put in your
document e.g. 

  This is \mbox{$$Revision$$} of this document.

LaTeX interprets the part in the \mbox{} as two formulas, both of which
are empty, bracketing a piece of ordinary text. RCS substitutes the 
revision description and after the first `ci -l' you end up with

  This is \mbox{$$Revision: 1.11$$} of this document.

The \mbox{} command is not necessary to fool LaTeX but keeps the word
Revision and the actual revision number in the same box, i.e. on the
same line. The colon within a sentence may not be esthetically pleasing,
though.


Good luck,

-- 
Martin J. van den Boogaard                 |        boogaard@fys.ruu.nl
-----------------------------------------------------------------------
Dept. of Atomic & Interface Physics        |            the Netherlands
Debye Institute--Utrecht University        |        phone +31 30 532904
P.O. Box 80.000, NL-3508 TA Utrecht        |        fax   +31 30 543165
-----------------------------------------------------------------------
some days you wake up and immediately start to worry. nothing in
particular is wrong, it's just the suspicion that forces are aligning
quietly and there will be trouble.            --           Jenny Holzer
-----------------------------------------------------------------------

kris@diku.dk (Kristoffer H. Holm) (04/20/91)

Hi...here is my version of RCS control with TeX: I have the
definitions below in my preamble (i.e., style) file and put

	\RCSrevision$Revision$
	\RCSdate$Date$
	\Draft

in my documents; RCS expands them to something like

	\RCSdate$Date: 1991/04/19 03:08:51 $
	\RCSrevision$Revision: 1.1 $
	\Draft

The good thing about these macros is that they work even before you
have checked in your initial revision, and the effect goes away when
you uncomment the \Draft line (indicating that you have submitted the
paper or whatever).  Also it includes an \ifdraft conditional that you
may use in you document to uncomment things in "final" versions.

NOTE: You might have \today and \eat@ predefined; also your
conventions regarding the \catcode`\@ might be different (I use the
conventions of plain TeX and AmS-TeX; LaTeX users should use
\makeatletter and \makeatother [sic]).

======================================================================
\catcode`\@=11
%%
%% REVISION CONTROL [by kris@diku.dk].
%%
%% \thedate
%% \therevision
%%	These contain the date and revision of this paper, set by the
%%	following revision control commands.  Default to the current date and
%%	to nothing.
%%
%% \RCSdate$...$
%% \RCSrevision$...$
%%	Modify the date and revision of the paper as given by the RCS
%%	variables Date and Revision (not inserted above because then RCS
%%	would interfere with this comment).  Use before \Draft.
%%
%% \Draft
%% \ifdraft...\else...\fi
%%	\Draft prepends ``Draft'' to \therevision and sets \drafttrue.
%%
\edef\today{\ifcase\month\or January\or February\or March\or April\or
  May\or June\or July\or August\or September\or October\or November\or
  December\fi\space\number\day, \number\year}
\def\eat@#1{}
%%
\def\thedate{\today}
\def\therevision{}
%%
\def\RCSdate$Date{%
 \def\next@{%
  \ifx\next$\let\nextii@=\eat@\else\let\nextii@=\RCSdate@\fi\nextii@}%
 \futurelet\next\next@}
\def\RCSdate@: #1/#2/#3 #4 ${\xdef\thedate{%
  \ifcase#2\or January\or February\or March\or April\or
   May\or June\or July\or August\or September\or October\or November\or
   December\fi\space\ignorespaces#3, \ifnum#1<100\relax19\fi#1}}
%%
\def\RCSrevision$Revision{%
 \def\next@{%
  \ifx\next$\let\nextii@=\eat@\else\let\nextii@=\RCSrevision@\fi\nextii@}%
 \futurelet\next\next@}
\def\RCSrevision@: #1 ${\xdef\therevision{[#1]}}
%%
\newif\ifdraft
\def\Draft{\xdef\therevision{Draft \therevision}\drafttrue}
%%
\catcode`\@=\active
======================================================================

Regards,
  Kristoffer H{\o}gsbro Holm                    <kris@diku.dk>
 Computer Science Dept. (TOPPS group), University of Copenhagen
  Universitetsparken 1, DK-2100 Copenhagen {\O}  +45 31396466
-- 

  Kristoffer H{\o}gsbro Holm                    <kris@diku.dk>
 Computer Science Dept. (TOPPS group), University of Copenhagen
  Universitetsparken 1, DK-2100 Copenhagen {\O}  +45 31396466

rjc@cstr.ed.ac.uk (Richard Caley) (04/22/91)

The following definition works for me...

	\def\rcs$#1:#2${\expandafter\gdef\csname rcs#1\endcsname{\mbox{#2}}}


You use it as

	\rcs$Revision: 1.1 $

in the prolog and it defines a macro \rcsRevison containing ` 1.1 '.

I am sure that someone will be able to get rid of those annoying
spaces, at least it means the $s and : etc don't end up in your final
document. 

--
rjc@cstr.ed.ac.uk		_O_
				 |<

tpt@hpindda.cup.hp.com (Tim Temple) (04/24/91)

>> Has anyone who uses both RCS and LaTeX come up with a good work-around
>> to this problem that they'd be willing to share?  Thanks.

>> --Jim Tubman


Since you asked for a work-around rather than a solution, here's mine:

% If you don't want the RCS identifiers here, put in your own values and
% remove the dollar signs.  The extra dollar signs are to trick \Latex{}
% into leaving the RCS identifiers alone; otherwise it would treat them
% as in-line equations.

\date{ \$Date: $ $\$ \$Revision: $ $\$ \\ Printed: \today}

----------
Tim Temple
Hewlett-Packard
(Usual disclarimers apply.)