TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.