How to add an image to asciidoc book cover page?
Asked Answered
R

5

13

I would like to create a pdf book using asciidoc. The title page should include the title, subtitle and an image. So far I could not find any documentation on how to achive this.

Intuivly I would do something like

My book title
=============
:author: myself
:toc:
image:images/titelimage.png[width=400]

but this just adds image:images/titelimage.png[width=400] as a subtitle. What I would like to have is something like

My book title
<titleimage>
subtitle

Is there a way to do this in ascciidoc? If not, what do I need to do to get this?

Rourke answered 14/10, 2013 at 5:39 Comment(0)
N
16

If you're using asciidoctor-pdf you can define an attribute for the logo. It will place the image above the document title.

:title-logo-image: images/titelimage.png

See an example pdf here and the raw adoc.

Nitin answered 5/11, 2014 at 17:59 Comment(1)
I think it's now called 'title-logo-image', see the [github.com/asciidoctor/asciidoctor-pdf/tree/master/… directory (new link)Tarnopol
H
7

If anyone is still looking for this answer, this is the correct way to do it (using asciidoctor-pdf):

= Book title
Authors
:front-cover-image: image::./images/title_page.png[]

This gives you the image by itself as the first page followed by a page that shows the title, authors, revision etc.

If you want the image on the same page as the title and author, you need to use :title-logo-image: instead.

Hydrograph answered 22/11, 2018 at 16:11 Comment(0)
T
2

If you want a PDF using the docbook 4.x output you should:

Generate a docinfo file with an image for the front page. This is an XML file looking like the following example. It is discussed at http://www.methods.co.nz/asciidoc/userguide.html#X87

Example:

<mediaobject>
  <imageobject>
    <imagedata align="center" depth="400" fileref="../images/tiger.png" />
  </imageobject>
</mediaobject>
<subtitle>Subtitle of this book</subtitle>

Then, customize your DocBook stylesheets to include the media element for the title page (by default the stylesheets do not include this). http://www.sagehill.net/docbookxsl/TitlePagePrint.html

DocBook 5 includes a cover element in its stylesheets.

Torpor answered 28/7, 2014 at 20:40 Comment(0)
G
1

This:

= The Book's Title
:author: First Last
:email: [email protected]
:toc:
:toc-placement: preamble
:doctype: book

image:./images/title_page.jpg[]

Produces:

My book title
[email protected] - [email protected]
Image
Table of Contents
...
Gael answered 25/2, 2014 at 12:46 Comment(1)
I will try that out probably next week and will let you know if it worked for me.Rourke
I
0

you just need to add a empty line between the toc and the images: instruction. That's how asciidoc kinda separates blocs.

Idiotism answered 23/10, 2013 at 22:26 Comment(1)
Actually, I don't use :toc: anymore, just title. I generate a book, which automatically adds a toc. Putting the image just after the title with a free line inbetween does not do the job.Rourke

© 2022 - 2024 — McMap. All rights reserved.