I want to use isodate's \printdate as part of a command to create a new section. Simplified example:



\newcommand{\datesec}[1]{\section{Date \printdate{#1}}}




This gets numerous errors when run through pdflatex, starting with:

! Undefined control sequence.
\@nnil ->\@nil 

l.10 \datesec{2010-11-01}

I've tried every expansion trick I know (which is not saying much). In my experiments it also seems to me that I've managed to make a section heading successfully include the date, but then the PDF bookmark generated (I think) by hyperref just shows "Date " without including the output from \printdate.

How can I use \printdate in a section title and also have it generate a correct, complete PDF bookmark? Thanks!

P.S.: I've had a little more luck with datetime's \formatdate but not much, and it also has a less pleasing syntax.

  • What you are trying to do looks really hard to achieve because the isodate macros really aren't oriented towards being fully expandable. What exactly are your requirements? What features of the isodate package do you need? Commented Nov 4, 2010 at 19:28
  • I'm looking for the ability to type a short ISO date, like 2010-11-01, and then be able to choose (and maybe later change) how that date will be formatted. I need to include this date in some kind of command (like \datesec) that will create a section, but maybe later will create a subsection or a subsubsection instead, etc. Make sense?
    – dsedivec
    Commented Nov 4, 2010 at 20:40

2 Answers 2


This compiles, but I had to turn it around


\newcommand{\datesec}[1]{\texorpdfstring{Date \printdate{#1}}{}}


  • Thanks for the answer. As I commented above (after you left this answer) I'd vastly prefer to put the \section in the command so that I can change its nesting within other sections later.
    – dsedivec
    Commented Nov 4, 2010 at 21:20

Here's one of those annoying "I'm changing the problem" kind of answers to my own question: If you can use LuaTeX (I can), then it might be feasible to punt the date handling out to Lua rather than isodate. Example (just a toy, advice is not to put any significant amount of Lua code inline, but instead put it in a separate file):





function format_date(date_str)
  year, month, day = date_str:match("(%d+)-(%d+)-(%d+)")
  return string.format("%s %s, %s", MONTHS[month], day, year)





Test 1


Test 2


To my great, surprise, this works:

output of above source code

You must log in to answer this question.

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