[texhax] How to insert file content into a string?
Uwe Lück
uwe.lueck at web.de
Sun Nov 5 00:30:54 CET 2006
At 19:06 04.11.06, Micha Hofri wrote:
> We work on a book, and many versions of typeset sections fly back and
>forth. We would like to insert in the output of latex the time the
>compiled file was last modified, ideally into the header or footer. I am
>on a Unix system and can get the string , say "Nov 4 13:05" into a file,
>say filedate, which I could then read with \input{filedate}.
>
>Printing it once is easy, but how can I get it into a header
>definition? Currently that definition includes the predefined \today, so
>it would be enough if I could use this new string in, say, a
>\renewcommand{\today}{...here...}?
[This time from my mind, without checking, so may be wrong:]
Approach no. 1:
The input files `foo.tex' should contain \ProvidesFile{foo}[2006/...].
After \GetFileInfo{foo} from the doc package, \filedate expands
to an alternative to \today that you probably desire.
So replace your \today in your header definition by \filedate.
Disadvantage: I experience day by day that I forget to update
the date in \Provides... ...
OK, a version control system may help here ...
Approach no. 2:
Use the actual "last change" information from the operating
system(s) -- namely [abbreviated]:
ls foo*.tex | fileinfo.log
i.e., pipe a file listing to fileinfo.log. In compiling the most recent
draft version of the entire work, read fileinfo.log with a parsing macro
that defines \timeoffile{foo} to be the "last change" time
for foo.tex. Right before inputting foo.tex, \def\actualinputfile{foo.tex}.
Use \timeoffile{\actualinputfile} instead of your \today in your
definition of the page header.
I think much that there should be a package for drafts and revising
with facilities like these. Some packages contribute to this goal,
but there should be a package merging such approaches.
I have thought on an own package for listing file version informations
-- but these thoughts may be irrelevant for your task.
There is a similar package for making use of file version informations
on
CTAN:/macros/latex/dateiliste
HTH -- Uwe.
More information about the texhax
mailing list