4

I am struggling with custom toc items added via:

\addcontentsline{toc}{section}{Some text here}

Actually my problem is that I need to add some items which contain chronological date periods like:

12/1/2005 - 3/3/2006 Some event.........................................1
10/10/2005 - 11/30/2005 Some other event................................2

This looks not so nice. What I would like to do is adjusting event description to some line position to look like:

12/1/2005 - 3/3/2006     Some event.....................................1
10/10/2005 - 11/30/2005  Some other event...............................2

I tried to use \makebox but as it seems it is not allowed to be used within \addcontentsline{toc}{section}{...} command.

Does anyone have other suggestions?

fbrereto
  • 35,429
  • 19
  • 126
  • 178
ovanes
  • 5,483
  • 2
  • 34
  • 60
  • Hm, a sane date format with a fixed width might help, such as ISO 8601 :-) – Joey Dec 02 '09 at 22:13
  • Thanks for the answer, but I don't have fixed width font in TOC, so there will be still some difference in text width. Another point is that I need some flexibility. I might want to state only the year followed by event description. – ovanes Dec 02 '09 at 22:29
  • not a fixed with font, but a fixed date format. see http://en.wikipedia.org/wiki/ISO_8601 something like yyyy/mm/dd would help with your spacing. also, use an en-dash between date ranges, in latex, it would be `--`. – Mica Dec 03 '09 at 00:34
  • 1
    I pretty well understand what fixed date format is. But when not using fixed width font, this format might result in different text length because in non-fixed-width font 9 might be wider as 1 for example. Therefore 2009/01/01 will be not so wide as 2009/09/09, resulting in different text lengths. – ovanes Dec 03 '09 at 09:32

1 Answers1

2

Got it...

\makebox is a fragile command, so I need to protect it :)

\addcontentsline{toc}{section}{\protect\makebox[2cm][l]{date here} Description here}

Sorry for noise!

Ovanes

ovanes
  • 5,483
  • 2
  • 34
  • 60
  • 1
    I didnt check your code, but won't be better to use `{\protect\makebox[1cm][l]{date1}-\protect\makebox{date2} Descrioption}` or maybe better in preamble: `\newcommand{\mysection}[3]{\addcontentsline{toc}{section}{\protect\makebox[1cm][l]{#2} - \protect\makebox[2cm][l]{#3} #1}}`? – Crowley Dec 02 '09 at 23:20
  • Yes, that would be better, but I wanted to have it simple for the example here, because \makebox was not accepted by LaTeX compiler and I did know how to fix that. – ovanes Dec 02 '09 at 23:50