タイトルパッケージと日付の書式設定

タイトルパッケージと日付の書式設定

私はタイトルプレーン コマンドを使用して、定義された日付などを再利用するパッケージを作成します\thedate。ただし、ローカリゼーションの種類が異なるため、日付形式は必要なものではありません。

私の最初のショットは同位体適切なオプションを使用してパッケージをアップグレードしましたが、これは機能しないようですタイトルパッケージ。

とにかく、私が作成したものは次のとおりです。

\documentclass{article}

\usepackage[ngerman]{babel}
\usepackage[ngerman]{isodate}
\usepackage{titling}

\setlength{\parindent}{0pt}

\date{\today}

\begin{document}
typically this: \thedate \\
should be: \today \\
but it is: {\origdate\thedate} \\
not even: {\isodate\thedate} \\
\end{document}

説明:\date私の意図は、適​​切なツールを使って定義された日付を再利用することです。私は次のように考えました。タイトルこれはタイトルなどには最適ですが、日付には書式の問題(\todayおよび\thedate相違)があります。コメントに従って、日付時刻2パッケージですが、これまで使用していた日付参照ソリューションでは機能しないようです。

以下は、日付時刻2パッケージ:

\documentclass{article}

\usepackage[ngerman]{babel}
\usepackage[useregional]{datetime2}
\usepackage{titling}

\setlength{\parindent}{0pt}

\date{\today}
%\DTMsavedate{date0}{\thedate} % does not compile
\DTMsavedate{date1}{2017-04-25}

\begin{document}
\selectlanguage{ngerman}
%maybe this: \DTMdate{\thedate} \\ % neither does this
wait, what: \DTMusedate{date1} \\
\end{document}

答え1

独自のコンバーターを作成します。

\documentclass{article}

\usepackage[ngerman]{babel}
\usepackage[ngerman]{isodate}
\usepackage{titling}

\setlength{\parindent}{0pt}

\date{\today}

\newcommand\convertdate[1]{\expandafter\convertdateaux#1\relax}
\def\convertdateaux#1 #2, #3\relax{#2.\@ #1 #3}

\begin{document}
typically this: \thedate \\
should be: \today \\
but it is: {\origdate\thedate} \\
not even: {\isodate\thedate} \\

How about \convertdate{\thedate}?
\end{document}

ここに画像の説明を入力してください

関連情報