我怎样才能显示某些日期而2000/12
不是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
您可能需要定义一种新样式,然后在文档中更改样式。要么在组或环境中更改它以保持样式更改在本地,要么事后再改回default
。
\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}