變更 datetime2 中的日期格式

變更 datetime2 中的日期格式

使用該datetime2包,如何\today以「2019 年 3 月 1 日星期五」的格式顯示日期?

\documentclass{article}
\usepackage{datetime2}
\begin{document}
\today
\end{document}

答案1

下面我定義了一個名為 的新日期樣式mydateformat,然後將其與 一起使用\DTMsetdatestyle{mydateformat}

結果日期格式

\documentclass{article}

\usepackage[calc,showdow,english]{datetime2}

\DTMnewdatestyle{mydateformat}{%
  \renewcommand{\DTMdisplaydate}[4]{%
    \DTMshortweekdayname{##4},\space% short weekday,
    \DTMmonthname{##2}\nobreakspace%  (full) Month
    \number##3,\space%                day,
    \number##1%                       year
  }%
  \renewcommand{\DTMDisplaydate}{\DTMdisplaydate}%
}

\begin{document}

\today

\DTMsetdatestyle{mydateformat}

\today

\end{document}

相關內容