I would like to make the example I have written in this question to work in Pandoc. When run using pandoc input-tex-file -o output-epub-file
, pandoc produces a nice ebook using this tex file. However, the ebook lacks the indexes. How can I get the indexes in the output ebook?
-
2Pandoc has no native support for indices. Maybe you could write a filter...– DG'May 7, 2018 at 7:16
-
Filter example: stackoverflow.com/a/65656823/156060– Adam MonsenFeb 15 at 18:29
2 Answers
You can add index to you Pandoc generated ebook using the two steps:
- Adding identifier to your heading, for example the following
{#foo}
syntax added the identifierfor
to the headingMy heading
,
# My heading {#foo}
we assume the file name was chap01.md
.
- Creating a index type of file as your book index. In this file, you can write book index using markdown link format. eg:
# Index {epub:type=index}
#. [Index to My heading ](#foo)
we assume the file name was index.md
.
Finally, your can generate the ebook with index using:
pandoc index.md chap01.md -s -o indexed_ebook.epub
-
2This looks like a table of contents, rather than an index. Are you sure this is, what the OP meant?– DG'Aug 15, 2019 at 7:41
Actually, often the first thing an editor does when transforming to an eBook e.g. ePUB is to remove the table of content page. This is because the eReader will generate a table of content based on the hierarchy of the document, and it will make it available through some special interactions, in the eBooks the page where a content is present will change depending on the setting the user uses (e.g. font-size) so there is no need for a page containing the table of content!
Pandoc actually can generate a table of content using --toc
flag but this won't work with ePUB for the aforementioned reasons.