Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the toc macro to be used to position the toc #1030

Closed
mojavelinux opened this issue Apr 21, 2019 · 10 comments
Closed

Allow the toc macro to be used to position the toc #1030

mojavelinux opened this issue Apr 21, 2019 · 10 comments
Assignees
Milestone

Comments

@mojavelinux
Copy link
Member

When the doctype is book, the toc starts on a dedicated page following the title page. When the doctype is not book (e.g., article), the toc is placed in between the doctitle and the body (no new page).

There are cases, however, when the author wants to place the toc in a different location, such as after colophon sections. Asciidoctor PDF should honor the toc macro for this purpose.

As a general rule, the toc still starts on a new page when the doctype is book. But otherwise, it should start at the location of the toc macro when the toc attribute is set to macro.

@damgot
Copy link

damgot commented Aug 26, 2019

Hello,
Do you have any news about this feature ?
I'm really interested in it.

@mojavelinux
Copy link
Member Author

You can find my latest comment here: #278 (comment)

@mojavelinux
Copy link
Member Author

I believe I've figured this one out with PR #1317. I'm sure there will still be some edge cases we're not thinking about, but I should satisfy the typical usage.

@mojavelinux mojavelinux self-assigned this Oct 10, 2019
@mojavelinux mojavelinux added this to the 1.5.0.beta.6 milestone Oct 10, 2019
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Oct 10, 2019
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Oct 11, 2019
@rben01
Copy link

rben01 commented Feb 27, 2021

Is there support for a "floating" TOC using :toc: left or right, which will be present on every page of the PDF? I'm thinking of something like the Hannover Beamer theme:

3565ED14-9D17-45F7-B553-6EF94FF99DA2

@mojavelinux
Copy link
Member Author

This converter will never support a sidebar TOC. If that's a feature you require, you should be starting to evaluate Asciidoctor Web PDF, which supports arbitrary layouts. See /~https://github.com/Mogztter/asciidoctor-web-pdf

@rben01
Copy link

rben01 commented Feb 28, 2021

@mojavelinux Thanks! That looks like exactly what I need.

@rben01
Copy link

rben01 commented Mar 1, 2021

@mojavelinux Actually it looks like Asciidoctor web pdf isn't quite what I'm looking for either -- it isn't quite as feature rich as Asciidoctor (non-web) pdf. If possible, I'd be interested in implementing a sidebar TOC for Asciidoctor pdf myself.

@mojavelinux
Copy link
Member Author

What would be best is to extend the converter and add that customization in your own codebase. I'm not looking to add a lot of layout enhancements to Asciidoctor PDF since it's incredibly complex to implement, support, and maintain in a general way. In other words, it's out of scope. (Asciidoctor PDF is designed for exactly the kind of document it creates now, which is a top-to-bottom print layout).

Here's how you can make your own converter:

class MyPDFConverter < (Asciidoctor::Converter.for 'pdf')
  register_for :pdf

  # override methods you want to replace or modify. for example:
  # def convert_document doc
  #   puts 'called'
  #   super
  # end
end

If Asciidoctor Web PDF is lacking in functionality that Asciidoctor PDF provides, please provide your feedback to that project. We are aiming for it to be a replacement.

@jimjyang
Copy link

Is it possible to use the same book-styled main.adoc to generate:

  1. an html: with a left TOC, and
  2. a pdf: with the TOC after a "preface", i.e., not automatically as page 2?

Or do I have to use two different main.adoc-files to achieve both 1 and 2?

So far I only manage to get either 1 (with :toc: left) or 2 (with :toc: macro), not both.

@mojavelinux
Copy link
Member Author

mojavelinux commented Jun 26, 2021

Please direct usage questions to the community chat at https://asciidoctor.zulipchat.com (where I'd be happy to answer your question). It's generally considered a poor practice to comment on closed issues unless there's a specific problem with the fix itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants