4

I'm playing around with pandoc as a way to create epub books. It automatically creates a table of contents by detecting all H1 tags in the book. This works well except that every epub has a TOC link to the title page, something I don't need. How do I get rid of this TOC link? Thanks, John

bearaman
  • 991
  • 6
  • 22
  • 39

1 Answers1

3

Use title in the YAML metadata block instead of a H1 for the title. For EPUB there are more specific options in the YAML block:

---
title:
- type: main
  text: My Book
- type: subtitle
  text: An investigation of metadata
creator:
- role: author
  text: John Smith
- role: editor
  text: Sarah Jones
identifier:
- scheme: DOI
  text: doi:10.234234.234/33
publisher:  My Press
rights: © 2007 John Smith, CC BY-NC
---

my body text

Note that if you're not converting from markdown, you can use --variable and --epub-metadata to pass in those values instead.

In your case, you'll probably need to modify the incoming HTML before passing it to pandoc to remove the h1 of the title page, and pass that information on with --variable title='My Title'.

This is because pandoc really makes a distinction between metadata (like the document title, author etc) and the document itself. So if you have a header in your document, then it also belongs in the table of contents and pandoc will put it there no matter what. (Of course, you can always go and modify the output produces by pandoc again, if you disagree with it.)

mb21
  • 28,026
  • 6
  • 96
  • 118
  • Thanks mb21. I think I misunderstood the difference between the epub navigations points which include the title page and the .mobi TOC, which don't. If I do a basic conversion with no TOC selected, I still get the epub navigation points, which is correct. When I convert the epub to mobi, only the title pages are included in the Table of Contents. – bearaman Jul 14 '15 at 11:39
  • 1
    Much of how the title page and a few subsequent pages look depend upon the template being used (default or otherwise) to generate those pages. See: https://pandoc.org/MANUAL.html#templates – jeffmcneill Nov 26 '18 at 05:02