4

Using asciidoc, I'd like to place a the table of contents on the third page. At best, I can only manage to place it on page 2; after the title page.

My expectation is that something like this should work:

= My book
A book to enjoy

== Preface
Enjoy my book

== Table of contents
:toc:

== Chapter One
It was the best of times ...

... but the table of contents still ends up on page 2.

Is it possible to choose where to place the Table of Contents?

EDIT:

The reason I want the TOC on a different page is because I am copying a template which has a section before the table of contents.

chriskelly
  • 7,526
  • 3
  • 32
  • 50

2 Answers2

5

It's possible, but not supported in all backends.

Setting :toc: macro lets you use the toc::[] macro anywhere in the document.

Since in your example you seem to want a custom TOC title, I used :toc-title: to get rid of the default TOC title.

:toc: macro
:toc-title:
= My book
A book to enjoy

== Preface
Enjoy my book

== Table of contents
toc::[]

== Chapter One
It was the best of times ...

For more information see:

You can test the code here: https://asciidoclive.com/

Mike Scotty
  • 10,530
  • 5
  • 38
  • 50
1

http://www.methods.co.nz/asciidoc/userguide.html#_page_breaks

A line of three or more less-than (<<<) characters will generate a hard page break in DocBook and printed HTML outputs

This should at least get you on the right page. No pun intended.

Stephen
  • 5,362
  • 1
  • 22
  • 33
  • 1
    Thanks. Especially for the unintended pun ;). I think I should have been more clear in explaining why I want this. I'm copying an existing document written in word where the 'preface' section comes before the table of contents. Therefore, I can't have a blank page before either. – chriskelly Apr 25 '18 at 20:54
  • Shoot. Unfortunately that's out of my know-how :\ – Stephen Apr 25 '18 at 21:47