日期时间格式的大写

日期时间格式的大写

在荷兰语等语言中,除非星期几和月份名称的第一个字母是句子的第一个字符,否则它们不会大写。因此,我在 latex 文件的序言中添加了以下代码来应对一般规则:

\newcommand*{\dayofweeknameiddutch}[1]{%
\ifcase#1\relax
\or zondag%
\or maandag%
\or dinsdag%
\or woensdag%
\or donderdag%
\or vrijdag%
\or zaterdag%
\fi}

\newdateformat{dutchformat}{%
\dayofweekname{\THEDAY}{\THEMONTH}{\THEYEAR}~\THEDAY~\monthname[\THEMONTH]~\THEYEAR}

现在您可以使用:

\selectlanguage{dutch}
\dutchformat\formatdate{DAY}{MONTH}{YEAR}

在文档中,但您不能将此调用中出现的第一个字符大写,因为此调用是句子的开头。我尝试使用 mfirstuc 和 stringstrings 包,但似乎没有任何效果,因为这两个包都需要一个扩展字符串作为其参数。

请参阅以下最小工作示例:

\documentclass{minimal}
\usepackage{inputenc}

\usepackage[T1]{fontenc}

\usepackage[dutch]{babel}
\usepackage{datetime}

\newcommand*{\dayofweeknameiddutch}[1]{%
\ifcase#1\relax
\or zondag%
\or maandag%
\or dinsdag%
\or woensdag%
\or donderdag%
\or vrijdag%
\or zaterdag%
\fi}

\newdateformat{dutchformat}{%
\dayofweekname{\THEDAY}{\THEMONTH}{\THEYEAR}~\THEDAY~\monthname[\THEMONTH]~\THEYEAR}

\begin{document}
\noindent In this sentence the format of the date
``\dutchformat\formatdate{1}{1}{2013}'' is displayed correctly
since it occurs in the middle of the sentence. But when I start
a sentence with \verb+\dutchformat\formatdate{1}{1}{2013}+\verb
I want the first character of the expanded string i.e.\
``dinsdag'' to be capitalized like ``Dinsdag''. The commands
\verb+\newdateformat+\verb and \verb+\formatdate+\verb come
from the \texttt{datetime} package.

\end{document}

因此,这个问题归结为 formatdate 调用的扩展。有什么想法吗?

答案1

我创建了两个命令\dutchformat\Dutchformat用于大写版本。

\documentclass{minimal}
\usepackage{inputenc}

\usepackage[T1]{fontenc}

\usepackage[dutch]{babel}
\usepackage{datetime}

\newdateformat{dutchformat}{%
\dayofweekname{\THEDAY}{\THEMONTH}{\THEYEAR}~\THEDAY~\monthname[\THEMONTH]~\THEYEAR}

\let\SAVEdutchformat\dutchformat

\newcommand*{\dayofweeknameiddutch}[1]{}%

\renewcommand\dutchformat{%
\renewcommand*{\dayofweeknameiddutch}[1]{%
\ifcase##1\relax
\or zondag%
\or maandag%
\or dinsdag%
\or woensdag%
\or donderdag%
\or vrijdag%
\or zaterdag%
\fi}%
\SAVEdutchformat}

\newcommand\Dutchformat{%
\renewcommand*{\dayofweeknameiddutch}[1]{%
\ifcase##1\relax
\or Zondag%
\or Maandag%
\or Dinsdag%
\or Woensdag%
\or Donderdag%
\or Vrijdag%
\or Zaterdag%
\fi}%
\SAVEdutchformat}
\begin{document}
\dutchformat\formatdate{1}{1}{2013}

\Dutchformat\formatdate{1}{1}{2013}
\end{document}

在此处输入图片描述

相关内容