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?
- 411
-
2Pandoc has no native support for indices. Maybe you could write a filter... – DG' May 07 '18 at 07:16
-
Filter example: https://stackoverflow.com/a/65656823/156060 – Adam Monsen Feb 15 '23 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 identifierforto 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
- 111
-
2This looks like a table of contents, rather than an index. Are you sure this is, what the OP meant? – DG' Aug 15 '19 at 07: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.
- 2,225