Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am having trouble formatting a date inside a caption using the datetime package. I'm told "Incomplete \iffalse; all text was ignored after line 6.

\documentclass{article}
\usepackage{datetime}
\begin{document}

\begin{figure}[h]
  \caption{Something that happened on \formatdate{30}{9}{2010}}
\end{figure}

\end{document}

If \formatdate is removed from \caption, the document compiles as expected. Also, I have tested \formatdate and it works when placed elsewhere. It seems to not like captions though...

So, any ideas how to format a date inside a caption?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

You can use protect

documentclass{article}
\usepackage{datetime}
\begin{document}

\begin{figure}[h]
  \caption{Something that happened on \protect\formatdate{30}{9}{2010}}
\end{figure}

\end{document}
share|improve this answer
    
Awesome! Thanks. –  user2470 Dec 13 '10 at 7:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.