[OS X TeX] Re: Save date-time, not Print date

Peter Dyballa Peter_Dyballa at Web.DE
Tue Feb 5 19:43:24 CET 2008


Am 05.02.2008 um 18:36 schrieb Alain Schremmer:

> How much are you asking for your Heiko Oberdiek code?

A MacBook Pro with four cores? I can wait to become your heir ...

     \def\fileinfo{Only maths!}						% an example
     \usepackage{cmap}							% allow copying from PDF
%    \DeclareGraphicsExtensions{.pdf,.png,.jpeg}			% allowed graphics  
formats
     \usepackage[activate={true,nocompatibility}]{microtype}
%    \usepackage[protrusion=true,expansion=true]{microtype}
%    \usepackage{lucida}
     \usepackage{hyperref}						% necessary
     \makeatletter
     \@ifundefined{pdffilemoddate}{%
        \PackageError{sourcetime}{%
          pdfTeX >= 1.30.0 required%
        }%
        \let\pdffilemoddate\@gobble
     }{}%
     \newcommand*{\SourceFile}[1]{%
       \edef\@SourceFileDate{\pdffilemoddate{#1}}%
       % empty in case of errors, but don't harm in next comparison
       \ifnum\pdfstrcmp{\@SourceFileDate}{\@CurrentSourceFileDate}>0 %
         \let\@CurrentSourceFileDate\@SourceFileDate
         \expandafter\@ParseDate\@SourceFileDate\@nil
         \hypersetup{%
           pdfcreationdate={\@SourceFileDate},%
           pdfmoddate={\@SourceFileDate}%
         }%
         \PackageInfo{sourcetime}{%
           Using file `#1'%
         }%
       \fi
     }
     \newcommand*{\@CurrentSourceFileDate}{}			% produces date form  
for PDF info
     \expandafter\def\expandafter\@ParseDate\detokenize{D:} 
#1#2#3#4#5#6#7#8{%
       \year=#1#2#3#4\relax
       \month=#5#6\relax
       \day=#7#8\relax
       \@ParseTime
     }
     \def\@ParseTime #1#2#3#4#5\@nil{%
       \time=\numexpr #1#2 * 60 + #3#4\relax
     }
     \makeatother
     \SourceFile{\jobname.tex}						% execution
     \pdfinfo
       { /Title		(Some Maths)
	/Author		(someone else)
	/Subject	(\fileinfo)					% example use
	/Keywords	(Maths, maths, maths.)
     }

It will fail with included files. If \jobname.tex is substituted  
with, say "latest.tex" and some external routine finds the youngest  
of all your TeX files and hard-links it to latest.tex, then  
\SourceFile{latest.tex} would reveal the date of the file modified  
latest.

--
Greetings

   Pete

The mathematician who pursues his studies without clear views of this  
matter, must often have the uncomfortable feeling that his paper and  
pencil surpass him in intelligence.
				– Ernst Mach






More information about the macostex-archives mailing list