Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get the current source file date instead of \today ?

328 views
Skip to first unread message

Timothy Madden

unread,
Sep 16, 2011, 12:59:17 PM9/16/11
to
Hello

I would like to add the document creation date in my document, and I
would like to insert the last modified date of the current source file
in the LaTeX output, instead of \today which merely outputs the
compilation (processing) date.

Is there a way to get the current source file timestamp ?

Thank you,
Timothy Madden

José Carlos Santos

unread,
Sep 16, 2011, 4:31:47 PM9/16/11
to
It seems that the getfiledate package does just that.

Best regards,

Jose Carlos Santos

coo...@nospamverizon.net

unread,
Sep 16, 2011, 4:46:04 PM9/16/11
to
Great suggestion, but I'm wondering if you (or anyone else) knows how to
parse the information from \getfiledate and embed it in a different
construct.

For example, for one of my books, I want to put the filedate in the
lower right-handed corner of the first page of each chapter. At present,
I do this using the fancyhdr package -- using

\usepackage{fancyhdr}

\fancypagestyle{plain}{%
%\fancyhf{} % clear all header and footer fields
\fancyhead[R]{}
\fancyhead[L]{}
\fancyfoot[R]{\footnotesize{\sffamily\dotdate\today}}
\fancyfoot[L]{\footnotesize{\sffamily\copyright~Author~(2011)}}


Works fine, except this gives me the compilation date, and not the file
date. However, when I try something like


\usepackage{fancyhdr}

\fancypagestyle{plain}{%
%\fancyhf{} % clear all header and footer fields
\fancyhead[R]{}
\fancyhead[L]{}
\fancyfoot[R]{\footnotesize{\getfiledate[putprefix=false,notime=true,boxed=false]}
% date in lower right
\fancyfoot[L]{\footnotesize{\sffamily\copyright~Cooch~(2011)}}
\renewcommand{\footrulewidth}{0.25pt}
\renewcommand{\headrulewidth}{0pt}}


it doesn't work, presumably because the final argument for \getfiledate
is missing. It's supposed to be

\getfiledate[options]{dir/filename.ext}

What I'm stuck with is how to make the final argument implicit, given
the compilation sequence. For example, when I compile the book, it needs
to know the name or number of the chapter, so that I don't have to
explicitly hard code it into the preceding \fancyhdr code for each chapter.

Any suggestions?

Thanks!

Timothy Madden

unread,
Sep 16, 2011, 6:07:34 PM9/16/11
to
\getfiledate wants the name of the file as an argument. How do I get the
name of the current LaTeX source file ?

Also, I would like the date of the file to appear formatted just as
\today formats the current date. Can I do that with \getfiledate ?

Thank you,
Timothy Madden

Enrico Gregorio

unread,
Sep 16, 2011, 6:43:12 PM9/16/11
to
Timothy Madden <termin...@gmail.com> wrote:

\documentclass[a4paper]{article}
\usepackage{filemod}
\renewcommand*{\thefilemoddate}[3]{\printmonth{#2} #3, #1}
\renewcommand*{\thefilemodtime}[4]{\unskip}
\newcommand*{\printmonth}[1]{\ifcase#1\relax\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}

\begin{document}

\today

\filemodprint{\jobname.tex}

\end{document}

Ciao
Enrico

coo...@nospamverizon.net

unread,
Sep 16, 2011, 7:59:53 PM9/16/11
to
On 9/16/2011 6:43 PM, Enrico Gregorio wrote:
> Timothy Madden<termin...@gmail.com> wrote:
>
This still seems to be a problem, since it looks as though it requites
the name of the file to be passed to the function \filemodprint. What I
(and perhaps others) need is for this to work on the 'current' file,
whatever its name is. So, either there is a variable we can assign to
the name of the current/active file, or some form of this (and related
functions) that implicitly works only on the active/open file.

Ahmed Musa

unread,
Sep 16, 2011, 8:35:25 PM9/16/11
to
>
> it doesn't work, presumably because the final argument for \getfiledate
> is missing. It's supposed to be
>
> \getfiledate[options]{dir/filename.ext}
>
> What I'm stuck with is how to make the final argument implicit, given
> the compilation sequence. For example, when I compile the book, it needs
> to know the name or number of the chapter, so that I don't have to
> explicitly hard code it into the preceding \fancyhdr code for each chapter.
>

Please can you give the order in which the chapters are compiled, eg, are they standalone or included into the main document with some command(s)?

coo...@nospamverizon.net

unread,
Sep 16, 2011, 10:30:10 PM9/16/11
to
Included into the document using a skeleton file. Something like the
following, where I'm working only with 'chapter 4'.

\begin{document}


% use following to set chapter number for individual chapters
% use n-1 for chapter n
\setcounter{chapter}{3}

%\maketitle

\frontmatter
\mainmatter
%\includefrom{lect1&2/}{lect1_book}
%\includefrom{lect1&2/}{lect2_book}
%\includefrom{lect3&4/}{lect3_book}
\includefrom{lect3&4/}{lect4_book}
%\includefrom{lect5&6/}{lect5_book} % intro to LV competition models
%\include{lect5&6/lect6_book} % more on competition models


\end{document}

Ahmed Musa

unread,
Sep 17, 2011, 9:47:36 AM9/17/11
to

> Included into the document using a skeleton file. Something like the
> following, where I'm working only with 'chapter 4'.
>
> \begin{document}
>
>
> % use following to set chapter number for individual chapters
> % use n-1 for chapter n
> \setcounter{chapter}{3}
>
> %\maketitle
>
> \frontmatter
> \mainmatter
> %\includefrom{lect1&2/}{lect1_book}
> %\includefrom{lect1&2/}{lect2_book}
> %\includefrom{lect3&4/}{lect3_book}
> \includefrom{lect3&4/}{lect4_book}
> %\includefrom{lect5&6/}{lect5_book} % intro to LV competition models
> %\include{lect5&6/lect6_book} % more on competition models
>
>
> \end{document}

Please let's get a few points clear:

1. Does the command \includefrom exist or is it arbitrary (given for the sake of illustration only)? If it exists, what is it?

2. Do you need the date of last modification of file 'lect<i>_book', i=1,...,n, as the file is being included? If yes, where will the result be printed, or do you simply need it in a macro?

coo...@nospamverizon.net

unread,
Sep 17, 2011, 11:33:13 AM9/17/11
to comp.t...@googlegroups.com, Ahmed Musa
On 9/17/2011 9:47 AM, Ahmed Musa wrote:
>
>> Included into the document using a skeleton file. Something like the
>> following, where I'm working only with 'chapter 4'.
>>
>> \begin{document}
>>
>>
>> % use following to set chapter number for individual chapters
>> % use n-1 for chapter n
>> \setcounter{chapter}{3}
>>
>> %\maketitle
>>
>> \frontmatter
>> \mainmatter
>> %\includefrom{lect1&2/}{lect1_book}
>> %\includefrom{lect1&2/}{lect2_book}
>> %\includefrom{lect3&4/}{lect3_book}
>> \includefrom{lect3&4/}{lect4_book}
>> %\includefrom{lect5&6/}{lect5_book} % intro to LV competition models
>> %\include{lect5&6/lect6_book} % more on competition models
>>
>>
>> \end{document}
>
> Please let's get a few points clear:
>
> 1. Does the command \includefrom exist or is it arbitrary (given for the sake of illustration only)? If it exists, what is it?
>

Its based on the import package, which I (and many others) use to handle
complicated nesting of figures (amongst other things) amongst multiple
chapters, which are often scattered over multiple directories.

> 2. Do you need the date of last modification of file 'lect<i>_book', i=1,...,n, as the file is being included? If yes, where will the result be printed, or do you simply need it in a macro?


All I want is the time stamp of the last time a particular lecture was
modified. I don't want the date of the current compilation, but the time
at which the files being included into the larger document were
modified. How that happens I don't particularly much care (macro or
otherwise).

coo...@nospamverizon.net

unread,
Sep 17, 2011, 2:49:22 PM9/17/11
to Timothy Madden
Tried the following, making use of the currfile and getfiledate
packages, which seems like it should work, but doesn't.

\usepackage{getfiledate}
\usepackage{currfile}

then, try something like

\getfiledate[putprefix=false,notime=true,boxed=false]{\currfilepath}

But this doesn't seem to work. If I pass the current file name (and
path) in explicitly to getfiledate, like

\getfiledate[putprefix=false,notime=true,boxed=false]{/path/filname.tex}

it works (more or less -- still wrestling with formatting). But using
\currfilepath doesn't seem to work at all.

I think the reason that \currfilepath doesn't work is that it doesn't
seem to generate the fill path. If I take a look at what is returned by
\currfilepath, it is simply the name of the file. No path information. I
think I confirm this by looking at \currfiledir, which returns nothing
(blank). Maybe it just doesn't play well with included files, or some such.

Heiko Oberdiek

unread,
Sep 17, 2011, 4:00:25 PM9/17/11
to
coo...@NOSPAMverizon.net wrote:

> \usepackage{getfiledate}
> \usepackage{currfile}
>
> then, try something like
>
> \getfiledate[putprefix=false,notime=true,boxed=false]{\currfilepath}
>
> But this doesn't seem to work. If I pass the current file name (and
> path) in explicitly to getfiledate, like
>
> \getfiledate[putprefix=false,notime=true,boxed=false]{/path/filname.tex}
>
> it works (more or less -- still wrestling with formatting). But using
> \currfilepath doesn't seem to work at all.
>
> I think the reason that \currfilepath doesn't work is that it doesn't
> seem to generate the fill path. If I take a look at what is returned by
> \currfilepath, it is simply the name of the file. No path information. I
> think I confirm this by looking at \currfiledir, which returns nothing
> (blank). Maybe it just doesn't play well with included files, or some such.

Files can be given by a relative path with an empty directory part.
There is nothing wrong with this.
Thus make a complete example that shows the problem.

--
Heiko Oberdiek

Robin Fairbairns

unread,
Sep 17, 2011, 7:16:46 PM9/17/11
to
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=filename discusses ways
to keep hold of the "current file"

\pdffilemoddate{<filename>} gives you the information you want.

i don't know how you get presentable information from the command.
--
Robin Fairbairns, Cambridge
my address is @cl.cam.ac.uk, regardless of the header. sorry about that.

coo...@nospamverizon.net

unread,
Sep 17, 2011, 7:48:51 PM9/17/11
to
Fine, remember -- you asked for it. ;-)

Consider the following directory structure:

docroot - chapter1
- chapter2
- chapter3

In /chapter1 there is the chapter file -- call it chap1.tex. Same for
/chapter2 (file called chap2.tex), and /chapter3 (file called chap3.tex).

Then, in /docroot, I have the following which I use to compile 'the book'.

\documentclass[11pt,letterpaper,oneside,onecolumn]{book}

\usepackage{import}
\usepackage{getfiledate}
\usepackage{currfile}

\usepackage{fancyhdr}
\fancypagestyle{plain}{%
%\fancyhf{} % clear all header and footer fields
\fancyhead[R]{}
\fancyhead[L]{}
% following gives me compile date -- don't want that...
% \fancyfoot[R]{\today}
% what I want is time stamp for each included file -- following doesn't work
\fancyfoot[R]{\getfiledate[putprefix=false,notime=true,boxed=false]{\currfilepath}}

\fancyfoot[L]{}
\renewcommand{\footrulewidth}{0.25pt}
\renewcommand{\headrulewidth}{0pt}}


\begin{document}

% use following to set chapter number for individual chapters
% use n-1 for chapter n
\setcounter{chapter}{0}

\frontmatter
\mainmatter
\includefrom{chapter1/}{chap1}
\includefrom{chapter2/}{chap2}
\includefrom{chapter3/}{chap3}

\end{document}


It is this line that doesn't seem to work

\fancyfoot[R]{\getfiledate[putprefix=false,notime=true,boxed=false]{\currfilepath}}


\getfiledate is supposed to pull the file date (time stamp) from
whatever file is fed to it (in this case, the file specified in the
\includefrom statement in the skeleton master file). . If I try this
explicitly (say, \getfiledate{/chapter1/chap1.tex}), it more or less
works, but what I want is for the call to \getfiledate to pull the time
stamp for each included chapter. So, how to feed it the right file name?
In theory, using \currfilepath, which is suppose to give the file path
and full file name (based on what I can glean from the docs for currfile).

Basically all I (and I suspect a few of us) want to do is this. We have
a book, with multiple chapters. Some of the chapters have been changed
recently. Some haven't. When I compile the book, I/we would like the
time stamp for the chapter file to be printed in the footer for the
first page of each chapter. I/we can easily get the compilation date
(for the whole book) there, but that isn't what we want. The time stamp
for the chapter is what we want, and is what readers are looking for to
see if that particular chapter has changed since last printing.

Let me know if you need anything more.

coo...@nospamverizon.net

unread,
Sep 17, 2011, 7:49:48 PM9/17/11
to
On 9/17/2011 7:16 PM, Robin Fairbairns wrote:
> Timothy Madden<termin...@gmail.com> writes:
>
>> I would like to add the document creation date in my document, and I
>> would like to insert the last modified date of the current source file
>> in the LaTeX output, instead of \today which merely outputs the
>> compilation (processing) date.
>>
>> Is there a way to get the current source file timestamp ?
>
> http://www.tex.ac.uk/cgi-bin/texfaq2html?label=filename discusses ways
> to keep hold of the "current file"
>
> \pdffilemoddate{<filename>} gives you the information you want.
>
> i don't know how you get presentable information from the command.


the currfile package I refer to in my reply covers much of this. But, I
can't seem to get it to work with \included files.

coo...@nospamverizon.net

unread,
Sep 17, 2011, 8:05:23 PM9/17/11
to
Even if you don't use \fancyhdr, there is still a problem. Usae the
follow skeleton master file


\documentclass[11pt,letterpaper,oneside,onecolumn]{book}
\usepackage{import}

\usepackage{getfiledate}
\usepackage{currfile}


\begin{document}

% use following to set chapter number for individual chapters
% use n-1 for chapter n
\setcounter{chapter}{0}

%\maketitle

\frontmatter
\mainmatter
\includefrom{chapter1/}{chap1}
\includefrom{chapter2/}{chap2}
\includefrom{chapter3/}{chap3}

\end{document}


For each chapter, use the following

\chapter{}

\getfiledate[putprefix=true,notime=true,boxed=false]{\currfilepath}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ut velit
vulputate mi porta elementum. In sagittis ultrices urna, id aliquam
lacus facilisis eget. Aenean fermentum imperdiet quam ut faucibus. Fusce
mollis tempor cursus. Sed interdum, leo id interdum congue, massa augue
consectetur ante, a suscipit tortor felis ut leo. Fusce vestibulum
sollicitudin lectus vitae porttitor. Aliquam adipiscing sollicitudin
felis in egestas. Sed dapibus, leo ut molestie sagittis, urna magna
consectetur nunc, et commodo dui diam nec tellus. Pellentesque habitant
morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Aenean ultrices, libero non gravida hendrerit, elit velit varius nunc,
vitae sollicitudin diam arcu ut metus. Mauris non purus dapibus risus
suscipit fringilla eget ut arcu. Curabitur eu dui est. Nulla facilisi.
Aliquam vitae metus id lacus euismod pharetra. Lorem ipsum dolor sit
amet, consectetur adipiscing elit. Aenean sit amet libero felis.


Now, when the book is compiled, the first line of each chapter should read

The date of last modification of file <chapter name> is <time stamp>

Now, what has me puzzled is that this works insofar as the <chapter
name> is correctly pulled, but not the time stamp for the chapter. All
you get printed is (for example, for chapter 1)

The date of last modification of file chap1.tex is 0000-00-00

So, it is picking up the name of the chapter file, correctly, but not
the time stamp for the file.

coo...@nospamverizon.net

unread,
Sep 17, 2011, 8:33:25 PM9/17/11
to

>
> Now, when the book is compiled, the first line of each chapter should read
>
> The date of last modification of file <chapter name> is <time stamp>
>
> Now, what has me puzzled is that this works insofar as the <chapter
> name> is correctly pulled, but not the time stamp for the chapter. All
> you get printed is (for example, for chapter 1)
>
> The date of last modification of file chap1.tex is 0000-00-00
>
> So, it is picking up the name of the chapter file, correctly, but not
> the time stamp for the file.
>

Turns out the the currfile package only support \include and \input, and
not \includefrom. If you use

\documentclass[11pt,letterpaper,oneside,onecolumn]{book}

\usepackage{getfiledate}
\usepackage{currfile}

\begin{document}

% use following to set chapter number for individual chapters
% use n-1 for chapter n
\setcounter{chapter}{0}

%\maketitle

\frontmatter
\mainmatter
\include{chapter1/chap1}
\include{chapter2/chap2}
\include{chapter3/chap3}
%\includefrom{chapter2/}{chap2}
%\includefrom{chapter3/}{chap3}

\end{document}



Seems to work fine...then any call to

\getfiledate[putprefix=true,notime=false,boxed=false]{\currfilepath}


in an individual chapter gives the right file name and time stamp for
the file.

Now of course my problem is figuring out how to move back from
\includefrom to \include. Pain...

Ahmed Musa

unread,
Sep 17, 2011, 9:42:00 PM9/17/11
to
I need to relate \getfiledate to \includefrom. To do that I needed to see how \includefrom grabs its arguments and then modify the command \getfiledate. That will take me some time.

Donald Arseneau

unread,
Sep 17, 2011, 11:36:03 PM9/17/11
to
coo...@NOSPAMverizon.net writes:

> Turns out the the currfile package only support \include and \input, and not
> \includefrom.

That is not the problem, because \includefrom literally invokes \include.

The problem is that currfile does not support LaTeX "\input@path",
but instead does a superficial examination of the filename
parameter, rather than the resolved file name (based on a quick
look).



Donald Arseneau as...@triumf.ca

Donald Arseneau

unread,
Sep 17, 2011, 11:48:31 PM9/17/11
to
I suggest instead that the full file name is in the macro
\@filef@nd (or something like that) with a space appended
to the name. Look at (the original) \IfFileExists.

Donald Arseneau as...@triumf.ca

Ahmed Musa

unread,
Sep 17, 2011, 11:57:47 PM9/17/11
to
I have got the following to work on my system. The date it gave for file 'getfiledate-testfile1.tex' is 'September 18, 2011', which presumably is what you wanted. To get this format, I introduced the key 'docformat' in the getfiledate package. I also included a new key called 'inputpath' to conform with needs like yours. The new version of getfiledate isn't on CTAN yet. It requires the latest version of the ltxkeys package, which itself isn't available on CTAN. How do I get the packages to you?

The test file 'getfiledate-testfile1.tex' contains only 'xx' in red color. I don't think you'll need it.

\usepackage{getfiledate}
\usepackage{import}

\begin{document}

\setcounter{chapter}{3}
\chapter{First chapter}

%\frontmatter
%\mainmatter

%\includefrom{lect1&2/}{lect1_book}
%\includefrom{lect1&2/}{lect2_book}
%\includefrom{lect3&4/}{lect3_book}

\getfiledate[inputpath={D:/MyDoc/TeXThings/},docformat,
putprefix,width=.5\hsize]{getfiledate-testfile1.tex}
\includefrom{D:/MyDoc/TeXThings/}{getfiledate-testfile1}

Martin Scharrer

unread,
Sep 18, 2011, 3:27:29 AM9/18/11
to
The main file name is given by `\jobname` (without the extension) as already shown by Enrico Gregorio. The name (and path) of the current file can easily be accessed using the 'currfile' package:

\filemodprint{\currfilepath}

Best,
Martin



Heiko Oberdiek

unread,
Sep 18, 2011, 5:12:54 AM9/18/11
to
coo...@NOSPAMverizon.net wrote:

> Consider the following directory structure:
>
> docroot - chapter1
> - chapter2
> - chapter3
>
> In /chapter1 there is the chapter file -- call it chap1.tex. Same for
> /chapter2 (file called chap2.tex), and /chapter3 (file called chap3.tex).
>
> Then, in /docroot, I have the following which I use to compile 'the book'.
>
> \documentclass[11pt,letterpaper,oneside,onecolumn]{book}
>
> \usepackage{import}
> \usepackage{getfiledate}
> \usepackage{currfile}

Package import sets \input@path (usually undefined).
Perhaps package currfile does not support this feature.

> \includefrom{chapter1/}{chap1}
> \includefrom{chapter2/}{chap2}
> \includefrom{chapter3/}{chap3}

You could make a feature request for currfile that it supports
\input@path or package import.

As workaround you could redefine \includefrom to set the
wanted \currfilepath:

\let\OldIncludeFrom\includefrom
\renewcommand*{\includefrom}[2]{%
\clearpage
\let\OldCurrFilePath\currfilepath
\def\currfilepath{#1#2.tex}%
\OldIncludeFrom{#1}{#2}%
\let\currfilepath\OldCurrFilePath
}

--
Heiko Oberdiek

Martin Scharrer

unread,
Sep 18, 2011, 7:45:14 AM9/18/11
to
On Sunday, September 18, 2011 11:12:54 AM UTC+2, Heiko Oberdiek wrote:
> coo...@NOSPAMverizon.net wrote:
>
> > Consider the following directory structure:
> >
> > docroot - chapter1
> > - chapter2
> > - chapter3
> >
> > In /chapter1 there is the chapter file -- call it chap1.tex. Same for
> > /chapter2 (file called chap2.tex), and /chapter3 (file called chap3.tex).
> >
> > Then, in /docroot, I have the following which I use to compile 'the book'.
> >
> > \documentclass[11pt,letterpaper,oneside,onecolumn]{book}
> >
> > \usepackage{import}
> > \usepackage{getfiledate}
> > \usepackage{currfile}
>
> Package import sets \input@path (usually undefined).
> Perhaps package currfile does not support this feature.
>
> > \includefrom{chapter1/}{chap1}
> > \includefrom{chapter2/}{chap2}
> > \includefrom{chapter3/}{chap3}
>
> You could make a feature request for currfile that it supports
> \input@path or package import.

Thanks Heiko,
I'm the author of 'currfile' and opened now a ticket myself: https://bitbucket.org/martin_scharrer/currfile/issue/2/files-read-using-input-path-do-not-contain

I'm currently working on it right now.

Regards,
Martin

Martin Scharrer

unread,
Sep 18, 2011, 12:30:51 PM9/18/11
to

I just uploaded v0.5 of currfile to CTAN which now support \input@path so that it works with files read with \includefrom from the 'import' package.
It should be available on CTAN tomorrow or the day after and then one or two days later or so for TeXLive and MikTeX. In the meantime you can get it directly from the source code repository at https://bitbucket.org/martin_scharrer/currfile, i.e. https://bitbucket.org/martin_scharrer/currfile/src/default/currfile.sty. Just put this in your local TEXMF tree under 'tex/latex/currfile/' or your document directory.

For printing the file modification date/time I would recommend the code Enrico Gregorio posted earlier which uses the 'filemod' package. However, I'm biased here because that package is also written by me.

Regards,
Martin

Martin Scharrer

unread,
Sep 18, 2011, 12:43:15 PM9/18/11
to
On Saturday, September 17, 2011 12:43:12 AM UTC+2, Enrico Gregorio wrote:
> Timothy Madden <termin...@gmail.com> wrote:
>
Hi Enrico,
that's good code. You can also locally assign the \year, \month and \day registers and then use \today to get always the same format and take advantage of the localized format provided by the 'babel' package.

Including with the also suggested 'currfile' package (required only for multi-file documents of course), it would look like:

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{filemod}
\usepackage{currfile}% needs [2011/09/18] to work with 'import' package.

\renewcommand*{\thefilemoddate}[3]{{\year#1 \month#2 \day#3 \today}}
\renewcommand*{\thefilemodtime}[4]{\unskip}

\begin{document}

\today

\filemodprint{\currfilepath}

\end{document}


Martin Scharrer

unread,
Sep 18, 2011, 12:46:24 PM9/18/11
to
On Saturday, September 17, 2011 12:43:12 AM UTC+2, Enrico Gregorio wrote:
> Timothy Madden <termin...@gmail.com> wrote:
>
> > On 16.09.2011 23:31, Jos� Carlos Santos wrote:
> > > On 16-09-2011 17:59, Timothy Madden wrote:
> > >
> > >> I would like to add the document creation date in my document, and I
> > >> would like to insert the last modified date of the current source file
> > >> in the LaTeX output, instead of \today which merely outputs the
> > >> compilation (processing) date.
> > >>
> > >> Is there a way to get the current source file timestamp ?


> \renewcommand*{\thefilemoddate}[3]{\printmonth{#2} #3, #1}
> \renewcommand*{\thefilemodtime}[4]{\unskip}
BTW,
you can redefine \thefilemod directly to `\printmonth{#2} #3, #1`, then you don't need to change \thefilemodtime. Normally \thefilemod is equal to \thefilemoddate\filemodsep\thefilemodtime where \filemodsep holds a space.

Regards,
Martin

coo...@nospamverizon.net

unread,
Sep 18, 2011, 8:45:03 PM9/18/11
to


Thanks very much, to all involved, for working on this.

In the end, what would be wonderful is a simply construct like \today,
which we (less-clever user-types) could simply embed as needed. While
getfiledate is a nice package, I find it a bit cumbersome to work with
since I need to strip away a lot of the 'built-in' formatting features
that I don't need. Maybe I'm in the minority, but all I want is the file
date (time stamp), which I can then format as needed. So, instead of
\today. something like \filedate or \timestamp or some such.

Ahmed Musa

unread,
Sep 18, 2011, 9:20:22 PM9/18/11
to

> In the end, what would be wonderful is a simply construct like \today,
> which we (less-clever user-types) could simply embed as needed. While
> getfiledate is a nice package, I find it a bit cumbersome to work with
> since I need to strip away a lot of the 'built-in' formatting features
> that I don't need. Maybe I'm in the minority, but all I want is the file
> date (time stamp), which I can then format as needed. So, instead of
> \today. something like \filedate or \timestamp or some such.

If you have the year, month (in numerical and word forms), day, hour, minute, and second in separate macros, you should be able to format them the way you fancy. Does this come close to meeting your need? If yes, they will be easy to implement.

coo...@nospamverizon.net

unread,
Sep 18, 2011, 10:11:31 PM9/18/11
to


Yes, that should work very well. I'm a big fan of packages that provide
as close to primitive elements as possible.

Martin Scharrer

unread,
Sep 19, 2011, 4:07:39 AM9/19/11
to
On Monday, September 19, 2011 2:45:03 AM UTC+2, (unknown) wrote:
> On 9/18/2011 12:30 PM, Martin Scharrer wrote:
> > On Sunday, September 18, 2011 1:49:48 AM UTC+2, (unknown) wrote:
> >> On 9/17/2011 7:16 PM, Robin Fairbairns wrote:
Well, why not using the `filemod` package then? It leaves most of the formatting (i.e. all except of some sane default definitions) to the user.
I might add a \Filemodtoday{<filename>} in the next version based on the code I posted earlier.

Best,
Martin

Timothy Madden

unread,
Sep 19, 2011, 7:02:12 AM9/19/11
to
Oh, that is so good to hear !
Thanks !

Timothy Madden

Timothy Madden

unread,
Sep 19, 2011, 7:32:43 AM9/19/11
to
On 18.09.2011 02:48, coo...@NOSPAMverizon.net wrote:
> Basically all I (and I suspect a few of us) want to do is this. We have
> a book, with multiple chapters. Some of the chapters have been changed
> recently. Some haven't. When I compile the book, I/we would like the
> time stamp for the chapter file to be printed in the footer for the
> first page of each chapter. I/we can easily get the compilation date
> (for the whole book) there, but that isn't what we want. The time stamp
> for the chapter is what we want, and is what readers are looking for to
> see if that particular chapter has changed since last printing.
>
> Let me know if you need anything more.

I think what other people (like me) also need is a way to include the
date the *document* was created or last updated, and not the chapters in
the document.

After all, the readers do not always want 7 creation dates for one
document. From this point of view, the included files problem is more
difficult: what I want is the latest modification time among all of the
included files in the document, with the root file included too.

Is there a way to get a list of all files included in a document,
together with the root file, and than get the last modified one ?

Thank you,
Timothy Madden

Timothy Madden

unread,
Sep 19, 2011, 7:35:37 AM9/19/11
to
Will that leave the \today command back to the same value it was before
the \filemodedate call ?

Thank you,
Timothy Madden

Timothy Madden

unread,
Sep 19, 2011, 9:12:05 AM9/19/11
to
That is not enough in my case. I usually run latex (from my editor) like
this:
latex qa/partial_index_test_plan.tex
that is, I am processing a file from a subdirectory. In this case the
currfile package reports the main file as 'partial_index_test_plan.tex'
only, without the 'qa/' directory part.

After going through the package documentation I can vaguely understand
that I need to use the maindir package option in this case, if I want to
get the name of the main file correctly, like:

\usepackage [mainext=tex,maindir=qa/]{currfile}

However I find this difficult to infer from the paragraph in the
documentation (maybe an example there could help ?), I find it to be
non-portable and to defeat the purpose of the package in the first
place. It will really make my file compile only from a specific
directory. Also, if I use --job-name="Test Plan" on the command line,
than there goes my main file name, which now appears to be named
"Test*Plan" (note the odd replacement of the space character with '*',
too). So maybe a mainfile package option should be there, too.

Is there no way to get the actual name of the LaTeX root file ?

Since LaTeX has no spell checking of its own, I would like to run aspell
on my file with
\write18 {aspell -c \currfilepath}
just before \end {document}. However with my command line (latex
'qa/partial_index_test_plan.tex') the name is wrong and the spell check
command can not find the file.

I do not know much about TeX programming, but is the current input file
not an open stream descriptor in TeX ? If so, could a package author use
the POSIX/UNIX lstat() API to get the file date/time ? Or get even the
file name with some more-specific OS function ?

Thank you,
Timothy Madden

Martin Scharrer

unread,
Sep 19, 2011, 9:59:22 AM9/19/11
to
The `svn-multi` package does that, but only if you use Subversion to version control all source files. The same technique could be applied to the file modification date as well. I actually had that idea a while back, but didn't found the time to program it so far.

Regards,
Martin


coo...@nospamverizon.net

unread,
Sep 19, 2011, 4:26:38 PM9/19/11
to
I'm having to have competing packages vying for my dollar. ;-)

Basically, I have specific wants/needs which might be satisfied by
filemod. But others might not. \filemodtoday would be a slick feature --
here's my +1 vote.

coo...@nospamverizon.net

unread,
Sep 19, 2011, 7:49:06 PM9/19/11
to comp.t...@googlegroups.com, Martin Scharrer
On 9/19/2011 4:07 AM, Martin Scharrer wrote:
OK -- can't seem to get it to work. Added the following line to each of
the \include chapters (using standard \include, and not \includefrom
with the import package).

This file was modified on \Filemodtoday{\currfilepath}

But, it fails on compile. I'm obviously missing something. I still need
to be able to tell filemod the name of the file. And the only way I know
of to this this for included files is to use \currfilepath. And yet,
this causes a compile fail.

\getfiledate[putprefix=true,prefix,notime=true,boxed=false]{\currfilepath}

works...

This file was modified on \Filemodtoday{\currfilepath}

fails...

If filemod can't handle some facility to get the name of the file (I'm
obviously using getfiledate package for this), then it's not a viable
option. I notice that in Enrico's example he explicitly enters the name
of the file. Again, that won't work...


coo...@nospamverizon.net

unread,
Sep 19, 2011, 7:52:28 PM9/19/11
to
Whoops, I meant ..."I'm obviously using currfile for this..' (not
getfiledate).

But, no matter, compile still fails.

Martin Scharrer

unread,
Sep 20, 2011, 3:44:03 AM9/20/11
to Martin Scharrer
On Tuesday, September 20, 2011 1:49:06 AM UTC+2, (unknown) wrote:
>
> OK -- can't seem to get it to work. Added the following line to each of
> the \include chapters (using standard \include, and not \includefrom
> with the import package).
>
> This file was modified on \Filemodtoday{\currfilepath}
>
> But, it fails on compile. I'm obviously missing something.
And what compiler error message are you getting?
You updated to the new version of currfile and filemod I released in the last two days, did you? Otherwise it of course doesn't work.


> I still need
> to be able to tell filemod the name of the file. And the only way I know
> of to this this for included files is to use \currfilepath. And yet,
> this causes a compile fail.
>
> \getfiledate[putprefix=true,prefix,notime=true,boxed=false]{\currfilepath}
>
> works...
>
> This file was modified on \Filemodtoday{\currfilepath}
>
> fails...
>
> If filemod can't handle some facility to get the name of the file (I'm
> obviously using getfiledate package for this), then it's not a viable
> option. I notice that in Enrico's example he explicitly enters the name
> of the file. Again, that won't work...
It worked well in my tests with the new versions of the two packages with both \include and \includefrom.

Here a minimal example:

\documentclass{book}

\usepackage{currfile}[2011/09/18]
\usepackage{filemod}[2011/09/19]
\usepackage{import}

\begin{document}

\includefrom{chapter1/}{chap1}
\includefrom{chapter2/}{chap2}
\includefrom{chapter3/}{chap3}

\end{document}

Where the chap? file look like:

\chapter{...}

\Filemodtoday{\currfilepath}


The STY files are pretty new and can also be downloaded from the code repository:

https://bitbucket.org/martin_scharrer/filemod/src/beacb6c52528/filemod.sty
https://bitbucket.org/martin_scharrer/filemod/src/beacb6c52528/filemod-expmin.sty
https://bitbucket.org/martin_scharrer/currfile/src/aa8c084e1860/currfile.sty

(I just saw that currfile.sty has the wrong version/date header from the last version. I will fix this on CTAN now.)

Best,
Martin





Best,
Martin

Ahmed Musa

unread,
Sep 20, 2011, 2:42:58 PM9/20/11
to
> I'm having to have competing packages vying for my dollar.

They aren't vying for anything: they're just using your problems to improve their packages.

coo...@nospamverizon.net

unread,
Sep 20, 2011, 8:50:06 PM9/20/11
to
On 9/20/2011 2:42 PM, Ahmed Musa wrote:
>> I'm having to have competing packages vying for my dollar.
>
> They aren't vying for anything: they're just using your problems to improve their packages.

I was joking (hopefully this much was obvious).

coo...@nospamverizon.net

unread,
Sep 20, 2011, 9:12:14 PM9/20/11
to

> You updated to the new version of currfile and filemod I released in the last two days, did you? Otherwise it of course doesn't work.
>
>

Yes. I'm slow, but not entirely an idiot. ;-)


> It worked well in my tests with the new versions of the two packages with both \include and \includefrom.
>
> Here a minimal example:
>
> \documentclass{book}
>
> \usepackage{currfile}[2011/09/18]
> \usepackage{filemod}[2011/09/19]
> \usepackage{import}
>
> \begin{document}
>
> \includefrom{chapter1/}{chap1}
> \includefrom{chapter2/}{chap2}
> \includefrom{chapter3/}{chap3}
>
> \end{document}

I'm trying much the same thing, except for the test I've reverted back
to the more 'primitive' \include. My skeleton file is

\documentclass[11pt,letterpaper,oneside,onecolumn]{book}

\usepackage{currfile}
\usepackage{filemod}

\begin{document}

\setcounter{chapter}{0}

\mainmatter
\include{chapter1/chap1}
\include{chapter2/chap2}
\include{chapter3/chap3}

\end{document}

Each chapter has the same basic structure: for example, chap1.tex looks like

% chapter 1

\chapter{}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ut velit
vulputate mi porta elementum. In sagittis ultrices urna, id aliquam
lacus facilisis eget. Aenean fermentum imperdiet quam ut faucibus. Fusce
mollis tempor cursus. Sed interdum, leo id interdum congue, massa augue
consectetur ante, a suscipit tortor felis ut leo. Fusce vestibulum
sollicitudin lectus vitae porttitor. Aliquam adipiscing sollicitudin
felis in egestas. Sed dapibus, leo ut molestie sagittis, urna magna
consectetur nunc, et commodo dui diam nec tellus. Pellentesque habitant
morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Aenean ultrices, libero non gravida hendrerit, elit velit varius nunc,
vitae sollicitudin diam arcu ut metus. Mauris non purus dapibus risus
suscipit fringilla eget ut arcu. Curabitur eu dui est. Nulla facilisi.
Aliquam vitae metus id lacus euismod pharetra. Lorem ipsum dolor sit
amet, consectetur adipiscing elit. Aenean sit amet libero felis.


Compiles fine -- *until* I actually try to parse the date/time stamp for
the file. If I modify any/all of the chapxx.tex files by including the
following sentence

This file was modified on \Filemodtoday{\currfilepath}

the compilation fails. The error message I get (using latest and
greatest version of MikTeX, is

! Undefined control sequence
l.7 This file was modified on \Filemodtoday
{\currfilepath}

?




>
> Where the chap? file look like:
>
> \chapter{...}
>
> \Filemodtoday{\currfilepath}


Yes, as shown above, just like that.
I'll try that and report back. In the meantime, I'll zip up my 'test;
directory structure and files, and send it to you offline, so I/we can
confirm that we're working on the same thing.


Thanks!

coo...@nospamverizon.net

unread,
Sep 20, 2011, 9:51:11 PM9/20/11
to

>
> The STY files are pretty new and can also be downloaded from the code repository:
>
> https://bitbucket.org/martin_scharrer/filemod/src/beacb6c52528/filemod.sty
> https://bitbucket.org/martin_scharrer/filemod/src/beacb6c52528/filemod-expmin.sty
> https://bitbucket.org/martin_scharrer/currfile/src/aa8c084e1860/currfile.sty
>
> (I just saw that currfile.sty has the wrong version/date header from the last version. I will fix this on CTAN now.)
>

Perhaps a clue. I just uninstalled and reinstalled currfile and filemod,
using the CTAN repo.

currfile reports as having been built (packaged) on 9-19-2011 (i.e.,
yesterday, my time).

However, filemod reports as having been built (packaged) on 03-28-2011
-- which is quite some time ago. I tried 5 different package
repositories, and they show the same package date for filemod.

So, I went to the bitbucket links you kindly posted, and downloaded the
.sty file for currfile, replace the 'older' one, and now it works like a
charm. Haven't tried all the permutations yet, but at least now I can do
a basic compilation, and the code is pulling the correct time stamp.

Where can I lay my hands on the latest documentation for the updated
version of currfile?

Thanks!!!

coo...@nospamverizon.net

unread,
Sep 20, 2011, 9:53:47 PM9/20/11
to
On 9/20/2011 9:51 PM, coo...@NOSPAMverizon.net wrote:
>
>>
>> The STY files are pretty new and can also be downloaded from the code
>> repository:
>>

> So, I went to the bitbucket links you kindly posted, and downloaded the
> .sty file for currfile, replace the 'older' one, and now it works like a
> charm. Haven't tried all the permutations yet, but at least now I can do
> a basic compilation, and the code is pulling the correct time stamp.

Whoops -- I meant I downloaded latest filemod.sty.

>
> Where can I lay my hands on the latest documentation for the updated
> version of currfile?

And, request for docs for latest version of filemod. ;-)

Martin Scharrer

unread,
Sep 21, 2011, 1:35:14 AM9/21/11
to
You are simply using the old version of `filemod`. Update it as mentioned and it should work.

Best,
Martin


Robin Fairbairns

unread,
Sep 21, 2011, 9:25:46 AM9/21/11
to
coo...@NOSPAMverizon.net writes:

> Perhaps a clue. I just uninstalled and reinstalled currfile and
> filemod, using the CTAN repo.

i assume you mean you were using mirror.ctan.org?

> currfile reports as having been built (packaged) on 9-19-2011 (i.e.,
> yesterday, my time).
>
> However, filemod reports as having been built (packaged) on 03-28-2011
> -- which is quite some time ago. I tried 5 different package
> repositories, and they show the same package date for filemod.

the current filemod only appeared on ctan on 20th; the tex live bundle
for it arrived in the small hours of the morning (my time) today
(2011-09-21).

if you had gone to one of the core ctans (both of which are in europe)
you would have seen current filemod very soon after it was installed.
mirrors can take up to 24 hours to acquire new stuff ("can" in the sense
that we start to worry if they take more than that).
--
Robin Fairbairns, Cambridge
my address is @cl.cam.ac.uk, regardless of the header. sorry about that.

Martin Scharrer

unread,
Sep 25, 2011, 5:21:41 PM9/25/11
to
On Wednesday, September 21, 2011 3:53:47 AM UTC+2, (unknown) wrote:
> On 9/20/2011 9:51 PM, coo...@NOSPAMverizon.net wrote:
> >
> >>
> >> The STY files are pretty new and can also be downloaded from the code
> >> repository:
> >>
>
> > So, I went to the bitbucket links you kindly posted, and downloaded the
> > .sty file for currfile, replace the 'older' one, and now it works like a
> > charm. Haven't tried all the permutations yet, but at least now I can do
> > a basic compilation, and the code is pulling the correct time stamp.
>
> Whoops -- I meant I downloaded latest filemod.sty.
Ach, either from the repository (however, with the code documentation still included as comments) or on CTAN after the usual delay, as stated before.

> >
> > Where can I lay my hands on the latest documentation for the updated
> > version of currfile?
>
> And, request for docs for latest version of filemod. ;-)

Again, CTAN or build it yourself by running `pdflatex currfile.dtx` or `pdflatex filemod.dtx` from the repository.

Note that the 'currfile' manual didn't changed much but simply mentions now that it supports `\input@path` which is required for e.g. the 'import' package.
The 'filehook' manual now holds the documentation of the two new macros.

Please be a little more patient next time and simply wait one or two days longer.

Regards,
Martin

0 new messages