Login  Register

Positioning TOC for both HTML and PDF?

Posted by wolandscat on Jun 22, 2015; 11:45am
URL: https://discuss.asciidoctor.org/Positioning-TOC-for-both-HTML-and-PDF-tp3422.html

I have the TOC coming out on the left, with desired number of levels in HTML, using the following in the header section.

:doctype: book
:toc: left
:toclevels: 4

But for PDF, and any other linear output, I need it in the expected location, i.e. quite a few pages in, after the Amendment history table (this is a large tech spec book style document).

If I use :toc: macro, and toc::[] in the required location, I get a linear style HTML with the TOC where I expect it, but the PDF generated by asciidoctor-pdf seems to ignore the placement, and just puts a TOC (which does have the right levels, so the PDF-generator appears to have read the toclevels attribute value) as the first thing in the output - above everything else...

Part of this problem is that asciidoctor-pdf is doing the wrong thing in terms of placement, but my main requirement is to have one .adoc source that can generate both linear and interactive output.

Is there a current solution to this problem?

Clearly to get the right behaviour for generating a linear source and also an interactive source (i.e. anything like two-pane HTML) with a single set of directives is a bit tricky.

I think dealing with this properly means a command-line 'linear-output' or similar option is needed to tell the back-end processor to generate linear output or not, and if so, pay attention to the toc::[] location; if not, interpret the toc:location attribute in a meaningful way.

I can imagine the same argument applying to an index.