2

Below is an 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}

... the above code compiles, but if the line that calls in the titling package is uncommented compilation fails with:

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

2 Answers 2

3

I have no idea what either package is doing, but if in doubt, add \protect. This runs without error:

\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

The datetime package has a peculiar choice of what commands should be robust or not. For instance, it declares \longdate, \shortdate and similar commands as robust (they shouldn't, probably), but it doesn't do the same to \displaydate which is likely to be used in moving arguments.

So the package should do

\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}}}

because this command uses \formatdate which performs assignments and is not declared as robust when (re)defined (also \PackageError is a culprit). Unfortunately, the package uses \newcommand instead.

You can fix the issue with 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}

and report this to the package author.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .