Search code examples
datetimelatex

How to customize date format?


I want to customize the date format (in the article document class) in such a way, that when I write \today (or similar), then the result is: '10. december 2023'. The months should be spelled in Danish and in lower case. Is there a way to do this?


Solution

  • Yes, you can do this, easily, without touching the article class file. Using the package babel with option danish also changes the format of the date: the following code

    \documentclass{article}
    \usepackage[danish]{babel}
    
    \title{Title}
    \author{Me}
    \date{\today}
    
    \begin{document}
    \maketitle
    
    Text.
    \end{document}
    

    gives this output:

    screenshot of output

    Also, you can read section 9.2 of the article class manual, saying something more about months in the date macro.


    Addendum

    The command \today{}, better followed by braces for the sake of better spacing, also works within a .tex file recalled by the command \input in the main .tex file.

    Main tex file:

    \documentclass{article}
    \usepackage[danish]{babel}
    
    \title{Title}
    \author{Me}
    \date{\today}
    
    \begin{document}
    \maketitle
    
    \input{content.tex}
    
    \end{document}
    

    content.tex file:

    Text, \today{} text.
    

    The output is the following:

    output modified