如何在asciidoc书籍封面页添加图片?

13

我想使用Asciidoc创建一本PDF书。标题页应包括标题,副标题和一张图片。到目前为止,我找不到任何关于如何实现这一点的文档。

直觉上,我会做类似于以下的事情

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

但这只是将image:images/titelimage.png[width=400]添加为副标题。我想要的是像这样的东西

My book title
<titleimage>
subtitle

有没有一种方法可以在ascciidoc中实现这个?如果没有,我需要做什么来完成它?

5个回答

16
如果您正在使用asciidoctor-pdf,可以定义一个标记来设置标志。它将把图像放置在文档标题上方。
:title-logo-image: images/titelimage.png

在此处查看示例pdf原始adoc


2
我认为现在它被称为“title-logo-image”,请参见https://github.com/asciidoctor/asciidoctor-pdf/tree/master/examples目录(新链接)。 - Gijs

7

如果有人仍在寻找答案,这是使用 asciidoctor-pdf 正确的方法:

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

这会给你一个仅包括图片的第一页,接下来是一个页面展示标题、作者、修订等信息。

如果你想要在同一页上展示图片和标题/作者,需要使用:title-logo-image:


2

如果你想要使用docbook 4.x输出生成PDF,你应该:

生成一个具有封面图片的docinfo文件。这是一个XML文件,类似以下示例。详情请参见http://www.methods.co.nz/asciidoc/userguide.html#X87

示例:

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

接下来,您需要自定义DocBook样式表以包含标题页的媒体元素(默认情况下,样式表不包括此元素)。http://www.sagehill.net/docbookxsl/TitlePagePrint.html

DocBook 5在其样式表中包含了封面元素。


1

这个:

= The Book's Title
:author: First Last
:email: first.last@company.com
:toc:
:toc-placement: preamble
:doctype: book

image:./images/title_page.jpg[]

产生:

My book title
first.last@company.com - first.last@company.com
Image
Table of Contents
...

我可能会在下周尝试一下,如果对我有效,我会让你知道的。 - Isaac

0

你只需要在目录和图片之间添加一个空行:指令。这就是 asciidoc 分隔块的方式。


1
实际上,我不再使用:toc:,只使用标题。我生成一本书,它会自动添加目录。在标题后面用一个空行放置图片并不能起到作用。 - Isaac

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接