How to print the current year in a LaTeX document?

4194 views
Skip to first unread message

Jason White

unread,
May 30, 2012, 11:10:35 PM5/30/12
to
What is the right way to print the current year in a LaTeX document? The
following sample document, when run through pdflatex, gives the error:
! Missing number, treated as zero.

This also happens if I write \arabic{year} instead of \year.

I'm using the latest TeX Live 2011/2012 packages from Debian.

I don't strictly need this functionality, but I'm curious as it isn't working
as I expected, and my Web searches haven't identified a solution.

\documentclass{article}

\begin{document}
This document was printed in \year\ and typeset with \LaTeX.
\end{document}

KF Leong

unread,
May 31, 2012, 12:20:06 AM5/31/12
to
On Thursday, 31 May 2012 11:10:35 UTC+8, Jason White wrote:
>
> \documentclass{article}
>
> \begin{document}
> This document was printed in \year\ and typeset with \LaTeX.
> \end{document}
-----
\documentclass{article}

\begin{document}
This document was printed in \the\year\ and typeset with \LaTeX.
\end{document}
-----

Reference:
http://tex.stackexchange.com/questions/19725/how-to-insert-4-digit-year-that-shows-up-in-today

Jason White

unread,
May 31, 2012, 2:23:06 AM5/31/12
to
>-----
>\documentclass{article}
>
>\begin{document}
>This document was printed in \the\year\ and typeset with \LaTeX.
>\end{document}
>-----
>
>Reference:
>http://tex.stackexchange.com/questions/19725/how-to-insert-4-digit-year-that-shows-up-in-today

Thanks. That should solve the problem perfectly.

Celso Alberto Rojas Pukall

unread,
Dec 3, 2022, 6:52:34 AM12/3/22
to
For the record, it has solved this very problem for me, thanks!

Dr Eberhard W Lisse

unread,
Dec 3, 2022, 9:21:44 AM12/3/22
to
Use the scrdate package from Komascript, which allows a large variety.

el

Peter Flynn

unread,
Dec 6, 2022, 6:00:12 AM12/6/22
to
On 03/12/2022 14:21, Dr Eberhard W Lisse wrote:
> Use the scrdate package from Komascript, which allows a large variety.

Or the datetime2 package, which has similar features.

Peter
Reply all
Reply to author
Forward
0 new messages