1

How can I display certain dates as 2000/12 instead of 30. Dezember 2000

\documentclass{article}

\usepackage{datetime2}

\begin{document}

\DTMdate{2000-12-30} %Prints as expected: 30. Dezember 2000

\DTMdate{2000-12-30} %Should be printed as: 2000/12

\end{document}
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Stefan Pinnow Mar 22 '18 at 8:59
  • 2
    As far as I can see, \date does not have an optional argument, neither by standard LaTeX nor by the datetime additions. – user31729 Mar 22 '18 at 10:24
  • 1
    Note also that \date on its own doesn't actually typeset anything. It only sets what should be displayed by \maketitle. – Torbjørn T. Mar 22 '18 at 13:30
  • Related (if not duplicate): Query regarding usage of \date – Nicola Talbot Mar 22 '18 at 14:11
1

You may need to define a new style, and then change style in the document. Either change it within a group or environment to keep the style change local, or change back to default afterwards.

enter image description here

\documentclass{article}

\usepackage{datetime2}

\DTMnewdatestyle{yyyymm}{%
\renewcommand\DTMdisplaydate[4]{##1/\DTMtwodigits{##2}}%
\renewcommand\DTMDisplaydate[4]{##1/\DTMtwodigits{##2}}%
}

\begin{document}

\DTMdate{2000-12-30} %Should be printed as: 2000/12

{% pair of braces makes the new style local
\DTMsetdatestyle{yyyymm}
\DTMdate{2000-12-30}
}

\DTMdate{2000-12-30}

\DTMsetdatestyle{yyyymm}
\DTMdate{2000-12-30}

% or you can set the style back to default
\DTMsetdatestyle{default}
\DTMdate{2000-12-30}


\end{document}

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.