2

I expect it cannot be done since there's no way for LaTeX to know when the source was changed, but I thought I'd ask anyway.

Is it possible to automate the addition of timestamps to LaTeX documents that mark the time the document was written (not compiled)?

An example use case is when using todonotes to add comments to documents in the margins. I currently use something like this:

\usepackage[colorinlistoftodos,prependcaption,textsize=scriptsize]{todonotes}

% My notes
\newcommandx{\unsure}[2][1=]{\todo[linecolor=Orange,backgroundcolor=Orange!25,bordercolor=Orange,#1]{AS:\@ #2}}
\newcommandx{\change}[2][1=]{\todo[linecolor=Aquamarine,backgroundcolor=Aquamarine!25,bordercolor=Aquamarine,#1]{AS:\@ #2}}
\newcommandx{\info}[2][1=]{\todo[linecolor=OliveGreen,backgroundcolor=OliveGreen!25,bordercolor=OliveGreen,#1]{AS:\@ #2}}
\newcommandx{\tocite}[2][1=]{\todo[linecolor=green,backgroundcolor=green!25,bordercolor=green,#1]{AS:\@ To cite: #2}}

However, when collaborating over the document, it'll be useful to know the chronological order in which these comments were added also---to make them more conversation like.

We use git, so we do have some idea of the order, but having it included in the document itself would be very useful.

Edit: would there be a pre or post-compile-hook type thing that would replace a placeholder text with the current time stamp, for example?

  • 3
    I do something similar using subversion, it can insert data stamps into the file at the time of subversion commit, these can then be access via for example the svn-multi package (see PracTeX Journal 2007, issue 3 for information about this approach). I assume something similar exists for git – daleif Dec 11 '18 at 11:49
  • Yes, I expect it should be doable using git pre-commit hooks, but I was wondering if there was a "native" LaTeX way of doing it that wouldn't require all collaborators to install the hooks and so on. I don't think we can modify Overleaf's hooks, for example. – FranciscoD Dec 11 '18 at 12:06
  • Well, LaTeX packages like gitinfo2 are using the hooks. – TeXnician Dec 11 '18 at 15:10
  • It uses a post-commit hook, so the addition of the git info will not be in the committed version. Hence the question about a pre or post compile hook instead of a git hook. – FranciscoD Dec 18 '18 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.