This is what I'm trying to do:

{\Huge Table of Contents}\vspace{-3mm}
\rule{\linewidth}{0.5mm} \\[-4mm]

Using babel, I can get this code to work:


    {Table of Contents}


but the second I try to add in that \vspace as a test, it fails. Any ideas how to fix this? Because I really want to add those options to the table of contents and I need the babel package as well.

  • \contentsname should contain only a string. Formatting changes to the table of contents should be made by modifying \tableofcontents. – egreg Nov 19 '12 at 17:24
  • hmm, but the first snippet of code I posted works as long as babel is not being used – justin.dong Nov 19 '12 at 17:29
  • 2
    It only "works" by accident. it would fail if \contentsname was used anywhere other than the main section title, for example page heading pdf bookmarks, ... – David Carlisle Nov 19 '12 at 17:31
  • I see. What is the proper way to modify the spacing only around the ToC title then? And add the horizontal line just below the title? – justin.dong Nov 19 '12 at 17:42

Here's a way; modify the spacings to suit you.

  \vspace*{-4mm}% reduce space before
  \vspace{2mm}% space between title and rule
  \vspace{2mm}% space below rule

Don't add formatting instructions to \contentsname, which should only contain the string to print.

| improve this answer | |
  • Fantastic, thanks. This is exactly what I needed – justin.dong Nov 19 '12 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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