Is it possible to make LaTeX believe that the current year is 2012, so that \the\year prints 2012?

  % What to do so that the following prints 2012?

I haven't found advice in The \the command; trying to set \year using \setcounter{year}{2012} didn't work either.

  • 2
    It's an internal variable, not a LaTeX counter: \year=2012
    – egreg
    Jun 16 '14 at 21:54
  • @egreg: Thanks for enlightening me, works like a charm but has to come after \begin{document} (not a problem for me). Care to write this as an answer? How does this fit the accepted answer of the linked question?
    – krlmlr
    Jun 16 '14 at 22:02
  • I have supplemented my answer there with these parameters.
    – egreg
    Jun 16 '14 at 22:09

TeX initializes \day, \month, \year and \time at the beginning of a job; they are internal integer registers that can be assigned new values. However, there is no LaTeX interface for modifying their values, so the primitive TeX assignment style has to be used: thus


will do, and similarly for the other registers mentioned above. Leave a space (or end of line) after the value, or append \relax to be sure.

Note that \time is initialized with the number of minutes past midnight when the job started. The initial values of \day, \month and \year are the expected ones.

You can print their values by prefixing the register's name with \the, as described in The \the command.


Just for fun, without a TeX primitive:

\ThisYear{1492}      Christopher Columbus discovers America in \the\year. \par
\AdvYear{509}        {\em\the\year: A Space Odyssey} was a film made in% 
\AdvYear{-33}        \the\year. \par 
\SetDate[20/07/1969] Man takes first steps on the Moon in \today. \par
\AdvanceDate[16403]  But today is \today.
  • Interesting. So, the advdate package interacts with the TeX variables?
    – krlmlr
    Jun 17 '14 at 7:04
  • @krlmlr Yes. Commands as \ThisYear are fairly simple (only do \year#1 \relax) but the package is justified because add x days to \today and obtain the right date is not so easy.
    – Fran
    Jun 17 '14 at 15:23

Just for fun, a quick LaTeX interface to the year:






Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.