パッケージ [datetime] は [titleling] では動作しません

パッケージ [datetime] は [titleling] では動作しません

以下は SSCCE です。

\documentclass{report}

\usepackage{datetime}
%\usepackage{titling} %if this line is uncommented compilation fails

\begin{document}
\newdate{date2}{08}{02}{2015}
\date{\displaydate{date2}}
foo
\end{document}

... 上記のコードはコンパイルされますが、titlingパッケージ内の呼び出し行がコメント解除されている場合、コンパイルは失敗します。

pdflatex esa-sre-gedais-sdp.tex
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
(./esa-sre-gedais-sdp.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, loaded.
(/usr/share/texmf-texlive/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo))
(/usr/share/texmf-texlive/tex/latex/datetime/datetime.sty
(/usr/share/texmf-texlive/tex/latex/fmtcount/fmtcount.sty
(/usr/share/texmf-texlive/tex/latex/base/ifthen.sty)
(/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-texlive/tex/latex/amsmath/amsgen.sty)
(/usr/share/texmf-texlive/tex/latex/fmtcount/fc-english.def)
(/usr/share/texmf-texlive/tex/latex/fmtcount/fc-USenglish.def)
No configuration file fmtcount.cfg found.
)) (/usr/share/texmf-texlive/tex/latex/titling/titling.sty)
(./esa-sre-gedais-sdp.aux))
! Incomplete \iffalse; all text was ignored after line 8.
<inserted text> 
                \fi 
<*> esa-sre-gedais-sdp.tex

? X
No pages of output.
Transcript written on esa-sre-gedais-sdp.log.
make: *** [all] Error 1

答え1

どちらのパッケージも何をしているのか分かりませんが、疑わしい場合は を追加してください\protect。これはエラーなしで実行されます:

\documentclass{report}

\usepackage{datetime}
\usepackage{titling} %if this line is uncommented compilation fails

\begin{document}
\newdate{date2}{08}{02}{2015}
\date{\protect\displaydate{date2}}
foo
\end{document}

答え2

このdatetimeパッケージには、どのコマンドが堅牢であるべきか、そうでないかという独特の選択があります。たとえば、、および類似のコマンドは堅牢であると宣言されていますが(おそらくそうすべきで\longdateはありません)、引数を移動する際に使用される可能性のある\shortdateに対しては、同じことが行われません。\displaydate

パッケージはすべきする

\DeclareRobustCommand*{\displaydate}[1]{%
\@ifundefined{date@#1@y}{%
\PackageError{datetime}{Date `#1' not defined}{}}{%
\formatdate{\csname date@#1@d\endcsname}{%
\csname date@#1@m\endcsname}{%
\csname date@#1@y\endcsname}}}

このコマンドは\formatdate割り当てを実行する を使用しており、(再)定義時に堅牢であると宣言されていないためです (これも\PackageError原因の 1 つです)。残念ながら、パッケージ\newcommandでは代わりに を使用します。

この問題は次のように修正できますetoolbox:

\documentclass{report}

\usepackage{etoolbox}
\usepackage{datetime}
\usepackage{titling} %if this line is uncommented compilation fails

\robustify{\displaydate} % make \displaydate robust

\begin{document}
\newdate{date2}{08}{02}{2015}

\title{Title}
\author{Author}
\date{\displaydate{date2}}

\maketitle

foo

\end{document}

パッケージの作成者に報告してください。

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

関連情報