[ACCEPTED]-LaTeX command for last modified-latex
pdfTeX provides the primitive \pdffilemoddate
to query 8 this information for files. (LuaTeX uses 7 its own Lua functions for the same thing.) Since 6 pdfTeX is used by default in all LaTeX distributions 5 in the last few years (at least), there's 4 no harm in using the new functionality unless 3 you're dealing with very old production 2 systems. Here's an example:
\documentclass{article} \begin{document} \def\parsedate #1:20#2#3#4#5#6#7#8\empty{20#2#3/#4#5/#6#7} \def\moddate#1{\expandafter\parsedate\pdffilemoddate{#1}\empty} this is the moddate: \moddate{\jobname.tex} \end{document}
(Assuming the 1 file has been modified since year 2000.)
The package filemod seems to do exactly what you 6 need. To get the last modified date of the 5 file you just include the package in the 4 usual way:
\usepackage{filemod}
and the modification time of the 3 current document is printed by:
\filemodprintdate{\jobname}
you can also 2 print the modification time, and there are 1 many options to format the output.
Unfortunately, TeX does not provide commands 5 for such information; the only way to get 4 such information is
- by running a non-TeX script to create a TeX file before running LaTeX and including this file in your main LaTeX document somehow, or
- by running the external script from TeX (which only works if the so-called write18 or shellescape feature is enabled; you'd have to consult the manual of your TeX implementation for this, and not have a stubborn sysadmin).
It is possible that 3 extended TeXs do support file info commands 2 (luaTeX perhaps?), but it's not part of 1 TeX proper.
If you are using an automated build system, you 6 could ask it to generate a file (perhaps 5 named today.sty
) which depends on all the source 4 files.
In make that might look like:
today.sty: $LATEX_SRCS
echo "\date{" > $@
date +D >> $@
echo "}" >> $@
and \usepackage{today.sty}
.
The 3 will use the date of the first build after a 2 file changes, and won't update until either 1 you delete today.sty
or alter another source file.
thank dmckee
LATEX_SRCS = test.tex
define moddate
date +%Y%m%d%H%M%S
endef
today.sty: $(LATEX_SRCS)
@echo "\def\moddate{"$(shell $(moddate))"}"> $@
0
There is the getfiledate LaTeX package (it was part 11 of my LaTeX distribution by default). It 10 seems to be designed to automatically output 9 a paragraph like:
The date of last modification of file misc-test1.tex was 2009-10-11 21:45:50.
with a bit of ability to 8 tweak the output. You can definitely get 7 just the date. However, I couldn't figure 6 out how to get rid of newlines around the 5 date and how to change the date format. To 4 be honest I think the authors implemented 3 it exactly for the single purpose they needed 2 it, and it is rather cumbersome for general 1 use.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.