[texhax] How to insert file content into a string?
Micha Hofri
hofri at WPI.EDU
Sun Nov 5 03:15:44 CET 2006
Indeed, Uwe, I have had no difficulty in obtaining the needed last
modification time, so I do not have to remember to post it in the file
(mere mortals do not do this reliably).
Getting the content of that file into a command, as I ask below, was a
puzzle. which I just now realized can be solved by getting the same
script that extracts the filemod time simply put in its output the
entire \renewcommand text...
Here it is:
#!/bin/bash
ls -l --time-style=locale
$1 | awk '{print "\\renewcommand\{\\today\}\{Last modified", $6, $7,
$8"\}"}' > draftdate$1
This is to be done for each compiled file from the make-like file that
does it all. In each file I shall put an \input{} for its own draftdate
file, and use the package prelim2e of Martin Schroeder to include \today
(I doubt I need \today for anything else) and typeset it in a subfooter.
Thanks to all for the suggestions,
--Micha
At 00:30 on 11/05/06 Uwe Lück sent:
: 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