Asciidoctor-pdf: How to render document header at top of first main page (like a journal article)

Created on 25 Feb 2015  路  15Comments  路  Source: asciidoctor/asciidoctor-pdf

I've searched, but I can't find a way to get the document's title and author data to just be at the top of the first page. PDF backend always renders the title info as a cover page, even for the article doc type -- is there a way? Not finding one, I submit this as an enhancement.

I know I can just skip the document header and use the level one section as the title of the doc, but then numbering is strange because all my first level headings look like second level headings.

improvement

Most helpful comment

This is a limitation to how Asciidoctor PDF is currently implemented. It always creates a title page.

There is one hack, though. You can disable the title (which also disabled the title page), and then you can add a discrete h1 heading that only shows for the PDF backend. This gives you to open to create a mini title bar at the top of the first page.

= Document Title
Author Name
// other attributes
ifdef::backend-pdf[:notitle:]

ifdef::backend-pdf[]
[discrete]
= {doctitle}
endif::[]

content of document

Let me know if that works for you. We should probably still consider having a way to display the document title on the same page as the content. How do you think we should specify that behavior?

All 15 comments

This is a limitation to how Asciidoctor PDF is currently implemented. It always creates a title page.

There is one hack, though. You can disable the title (which also disabled the title page), and then you can add a discrete h1 heading that only shows for the PDF backend. This gives you to open to create a mini title bar at the top of the first page.

= Document Title
Author Name
// other attributes
ifdef::backend-pdf[:notitle:]

ifdef::backend-pdf[]
[discrete]
= {doctitle}
endif::[]

content of document

Let me know if that works for you. We should probably still consider having a way to display the document title on the same page as the content. How do you think we should specify that behavior?

I'll give your workaround a try when I return to work next week. I think it will be satisfactory for many cases. Having your notes here in the docs is probably good enough. Thanks.

I'll have to look into what you do in latex when you want this -- the back of my mind is saying that an article type does this by default, and it is only the book type that has a title page. but the back of my mind is unreliable.

A journal article is usually all of this in-line

  • title, author and abstract
  • one or two column content
  • bibliography (in the same column layout as the content)

Abstract and two-column support and in-line bibliography may be asking more than the system is intended to provide. And, it may not be worth the effort since journals all have specific requirements that would require you to tweak things.

the back of my mind is saying that an article type does this by default (in LaTeX), and it is only the book type that has a title page. but the back of my mind is unreliable.

Very likely.

This is probably what we should be doing in Asciidoctor PDF. It is the way it is right now because I developed Asciidoctor PDF with a magazine output in mind...so I may not have thought the article scenario through properly. I also need to check what the DocBook output does, because we're trying to be consistent with that for people migrating. Again, I'll need to refresh my memory.

two-column support

I think two-column support belongs in the AsciiDoc -> LaTeX -> PDF chain. I'd like to avoid going down that road in Asciidoctor PDF because it's already hard enough to manage the layouts with Prawn :)

in-line bibliography

This I want to see supported consistently throughout the Asciidoctor toolchain because it's critical behavior.

Sorry it took me so long to get back to you on this. The workaround you suggested in your original response to this issue doesn't seem to work for me (asciidoctorj-pdf 1.5.0-alpha.6). I'll look at the related issue #105.

Okay... poked at this a little more, and after correcting some erroneous blank lines it basically works.

I can't get the :toc: to render the way I want, but for a PDF, the outline view provided by most PDF viewers makes this a small issue.

Two problems

  • the title appears twice in the PDF's outline view.
  • the author info is not rendered.

Here's an example:

= Document Title
author name
:icons: font
ifdef::backend-pdf[:notitle:]
ifdef::backend-pdf[]
[discrete]
== {doctitle}
endif::[]

== Section

_Hello_ there.

== Another Section

Foo

Which turns out a pdf that looks like: http://kas.d.pr/iZsX

That perfectly describes the state of things at the moment. It's clear what we need to do now to remove the need for these workarounds.

Depending on how things go for 1.5.0, we can consider making this part of that release or perhaps a micro release following it.

The hack from mojavelinux works fine, if you do use this:

// :doctype: article
:authors: Name, Firstname
:doctitle: Document Title
ifdef::backend-pdf[:notitle:]
ifdef::backend-pdf[]
[discrete]
= {doctitle}
endif::[]

{authors}

== First Section
_Hello_ there.

== Second Section
Once upon a time...

Your two problems are solved.
If you use :authors: instead of :author: the author(s) also appear(s) in pdf-metadata (look at pdfmarks if you test both).

@MaWiMa That gets my immediate problem solved. Thanks!

For the record, this is the same issue as #105.

Hello, any news? :-)

This issue also affects me. I鈥檇 like to show the main title and the subtitle on two different lines. Therefore, I adapted the workaround proposed here as follows.

= PhD proposal: Elicitation and explanation for voting rules
//Disables the title page
ifdef::backend-pdf[:notitle:]

ifdef::backend-pdf[]
[discrete]
= PhD proposal:
[discrete]
= Elicitation and explanation for voting rules
endif::[]

I have copied the main title and subtitle because I ignore how to access those as variables.

It would be more elegant to be able to customize this using a theme or in-document variables.

A more sleek solution:

:doctitle: <YOUR TITLE>
// other header attributes
ifdef::backend-pdf[:notitle:]
ifdef::backend-pdf[[discrete]]
= {doctitle}

// document content

And some remarks:

  1. set title with doctitle instead of =, or the TOC of the pdf will duplicate the text of the first heading (instead of using the title) (an asciidoctor-pdf bug?)
  2. you cannot define header attributes after a [discrete] line (as it is already considered document content)

(Still the proper solution would be #105)

Please see the proposed solution attached to #105. (PR #975)

This has been solved by PR #975. There is still some follow-up work to do, but the basic functionality is now in place.

Was this page helpful?
0 / 5 - 0 ratings