3

If I export the following document as a PDF through C-c C-e l p I get a PDF with a table of contents as expected:

* Hello                                                                                                                                      

  This is a test.                                                                                                                            

* World                                                                                                                                      

  Of org mode section numbering.

but if I add num:nil to the options (to disable section numbering) like so:

#+OPTIONS: num:nil                                                                                                                           
* Hello                                                                                                                                      

  This is a test.                                                                                                                            

* World                                                                                                                                      

  Of org mode section numbering.

my table of contents becomes empty.

I'd like to have a table of contents but without all the section numbers. Is there any way to do that? I've tried adding toc:2 as well but that didn't help.


The first one (without the num:nil) looks like this:

enter image description here

and the second one (with the num:nil) looks like this:

enter image description here

(a rather useless table of contents...)

1

Of course, that happen also in LaTeX. You could use the option toc:nil to disable the table of contents. Otherwise you can trick it using the LaTeX code which forces the sections to appear in the table of contents

* Hello @@latex: \addcontentsline{toc}{section}{Hello}@@
  This is a test 
* World @@latex: \addcontentsline{toc}{section}{World}@@
  Of =org-mode= section numbering

enter image description here

0

The num:nil option tells org to export your headings as unnumbered sections, which look like \section* in LaTeX. The normal handling of these sections in LaTeX is to exclude them from the table of contents. To over-ride this, you have to explicitly add them with \addcontentsline, as @Dox has indicated in his answer.

As an alternative, instead of setting the num:nil option, you can use a LaTeX macro to turn of section numbering entirely:

\setcounter{secnumdepth}{0}

If you do this, you only need this one line at the top of your org document, you don't need to add it for every section.

The resulting LaTeX produced by the org-exporter will use normal sections, i.e., \section (without an asterix). These sections show up in your TOC, but will not have numbers.

Using the setcounter macro will only work for LaTeX output, so it's no help if you export to html or other formats.

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.