패키지 [날짜/시간]이 [제목]과 작동하지 않습니다.

패키지 [날짜/시간]이 [제목]과 작동하지 않습니다.

다음은 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범인입니다). 불행하게도 패키지가 \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}

이를 패키지 작성자에게 보고합니다.

여기에 이미지 설명을 입력하세요

관련 정보