[OS X TeX] print the latex source filename
Alessandro Languasco
languasc at gmail.com
Sat Mar 21 06:39:28 CET 2009
>> A bit nicer is this block of code from Heiko Oberdiek for
>> "branding" the pdfTeX output also with the date of the source (it
>> also uses \jobname):
>>
>> \makeatletter % following code needs hyperref
>> \@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}{}
>> \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}
>
> I haven't been able to make this code work. What does it do compared
> to:
>
> \documentclass[11pt]{book}
> \usepackage{calc}
> \newcounter{hours}\newcounter{minutes}
> \newcommand{\printtime}%
> {%begin definition
> \setcounter{hours}{\time/60}%
> \setcounter{minutes}{\time-\value{hours}*60}%
> \thehours:\theminutes%
> }%end definition
> \begin{document}
> This file was saved as \jobname \hspace{1mm} on \today \hspace{1mm}
> at \printtime.
> \end{document}
Dear Peter and Alain
thanks for the code. I wasn't able to use Peter's suggestion... but
this is not a problem for me because
I was looking for something easier (like Alain's solution).
thanks again.
Bests,
Alessandro
More information about the macostex-archives
mailing list