2

The datetime2 docs are hard to read. I just want to typeset \today's date, both numerically and textually, in the correct way, depending on the babel language setting.

Here is my MWE:

\documentclass{article}

%\usepackage[UKenglish]{babel}
\usepackage[ngerman]{babel}

\usepackage{datetime2}

\begin{document}
  Numeric: \DTMsetup{???}\today % wanted: 27. 10. 2020 (ngerman), 27/10/2020 (UKenglish)

  Text: \DTMsetup{???}\today    % wanted: 27. Oktober 2020 (ngerman), 27th October 2020 (UKenglish)
\end{document}
1
  • +1: I feel better because you also have reading the datetime2 manual :). Mar 28, 2021 at 5:27

1 Answer 1

3

After some struggles

\documentclass{article}

\usepackage[UKenglish,ngerman]{babel}

\usepackage{datetime2}
\DTMsetup{useregional}
\begin{document}
Numeric: {\DTMsetregional[numeric]\today}   % wanted: 27. 10. 2020 (ngerman), 27/10/2020 (UKenglish)

Text:    {\today}   
  
\selectlanguage{UKenglish}
Numeric: {\DTMsetregional[numeric]\today}   % wanted: 27. 10. 2020 (ngerman), 27/10/2020 (UKenglish)

Text:    {\today}
  
  
\end{document}

You can also start with \DTMsetup{useregional=numeric}.

enter image description here

6
  • Exactly what I needed. Thank you so much!!!
    – AlexG
    Oct 27, 2020 at 14:05
  • Just one additional question, @Ulrike: German typesetting rules require a small space \, after the separator in numeric dates. How to get this?
    – AlexG
    Oct 27, 2020 at 14:08
  • \renewcommand*{\DTMgermandatesep}{.\,} Oct 27, 2020 at 14:29
  • Oh my, how many user commands does this package define! And this one isn't even documented! Thanks a lot! Would you please embed this in your answer?
    – AlexG
    Oct 27, 2020 at 14:33
  • this one was in the german configuration files, and \DTMlangsetup[german]{datesep=.\,} is probably the better method to change it. Oct 27, 2020 at 14:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .