For printed drafts of my papers, I would like to add a timestamp on every page with the date/time when the document was last compiled. Is there any LaTeX command that produces the current date/time at compile time? Even better, is there any package that already solves my problem?
[Tex/LaTex] How to typeset the date/time at compile time
datetime
Related Solutions
The tdclock
package offers an easy way to insert the current date and time into a PDF document:
\documentclass{article}
\usepackage{tdclock}
\begin{document}
\initclock
Date: \tddate
\end{document}
Mind the \initclock
at the beginning of the document, then you'll be able to display the current time and date with the macros \tdclock
, \tddate
, \tdtime
, ... (see the documentation for more details).
You need to use the dateplot
library to read in dates, see page 331 of the v1.12 manual. You also need to save the file as a CSV. Then, the following MWE will plot the first dataset that you listed. Note that the key date coordinates in=x
tells pgfplots
to look for the date information in the column specified by the x
coordinate of the \addplot
command. In addition, pgfplots
reads the date and time as one column, not as separate columns. You can adjust how the xticklabel
is printed by adjusting that key as well; see the specified page in the manual.
Furthermore, you can control the options for a particular plot by setting the options on the \addplot
command. I put +[no markers]
which tells pgfplots only to overwrite the options I give to the command, but leave all the others (e.g., color, thickness, etc.). Without the +
, only the option specified would be set, all others would be default values (e.g., color would be black, etc.).
For your third question, it is better to post one question per... post, so you should probably take what is working for you here and ask a new question specifically about how to deal with gaps in your data. Also, be sure to define how long a "gap" should be.
Finally, pgfplots
automatically loads tikz
so there is no reason to load the latter, and I used the filecontents
package to make a self-contained example.
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot, statistics}
\pgfplotsset{compat=1.12}
\usepackage{filecontents}
\begin{filecontents*}{data.txt}
no, date, value
1, 2015-09-13 21:00:00, 922
2, 2015-09-13 22:00:00, 3993
3, 2015-09-13 23:00:00, 3003
4, 2015-09-14 00:00:00, 991
5, 2015-09-14 01:00:00, 2021
6, 2015-09-14 02:00:00, 841
7, 2015-09-14 03:00:00, 2812
8, 2015-09-14 14:00:00, 991
9, 2015-09-14 15:00:00, 231
10, 2015-09-14 16:00:00, 678
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=time, ylabel=Value, date coordinates in=x, table/col sep=comma, date ZERO=2015-09-13, xticklabel=\day. \hour:\minute, xticklabel style={rotate=90, anchor=near xticklabel}]
\addplot+[no markers] table[x=date,y=value] {data.txt};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
One can use
\today
to get the current date, the command\currenttime
fromdatetime
package to get the current time, andfancyhdr
package to add it to every page.