redefine date format in letter environment

Julius Müller Julius.Muller at gmx.net
Wed Dec 7 16:13:58 CET 2022


Am 07.12.22 um 14:30 schrieb Haines Brown:
> I want today's date to appear: 2022.21.07 rather than 2022.21.7
>
> \documentclass[letterpaper,12pt]{letter}
>
> \usepackage{fontspec}
> \usepackage{libertinus-otf}
>
> \def\mydate{\leavevmode\hbox{\the\year.\twodigits\month.\twodigits\day}}
> \def\twodigits#1{\ifnum#1<10 0\fi\the#1}
> \renewcommand*\today{\number\year.\number\month.\number\day}

As Lars Madsen already pointed out, you need to use the \twodigits macro
within \today if you want the two digits form, for example by making use
of the \mydate macro you just defined:

\renewcommand*\today{\mydate}

>
> \begin{document}
> \begin{letter}{}
>
>    \opening{}
>
> \end{letter}
> \end{document}
>
>



More information about the texhax mailing list.