![패키지 [날짜/시간]이 [제목]과 작동하지 않습니다.](https://rvso.com/image/305763/%ED%8C%A8%ED%82%A4%EC%A7%80%20%5B%EB%82%A0%EC%A7%9C%2F%EC%8B%9C%EA%B0%84%5D%EC%9D%B4%20%5B%EC%A0%9C%EB%AA%A9%5D%EA%B3%BC%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
다음은 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}
이를 패키지 작성자에게 보고합니다.