3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Asciidoctor + pandoc で asciidoc を PDF に変換する

Last updated at Posted at 2021-11-12

asciidoc を最近始めたのですが、asciidoctor-pdf の PDF 出力がかっこ悪いので、 pandoc で対応している lualatex で PDF にすることにしました。
pandoc は asciidoc 入力に対応していないので、

  1. asciidoctor で asciidoc から docbook に変換する
  2. pandoc (lualatex) で docbook から pdf に変換する

という流れです。

インストール

当方 Windows 10 です。

asciidoctor

Ruby はインストールされているとします。

$ ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x64-mingw32]
$ gem -v
3.1.6

gem でインストールします。

$ gem install asciidoctor
Successfully installed asciidoctor-2.0.16
Parsing documentation for asciidoctor-2.0.16
Done installing documentation for asciidoctor after 2 seconds
1 gem installed

pandoc

chocolatey でインストールします。

> cinst /y pandoc

TeX Live

chocolatey でインストールしたあと、パッケージをインストールします。

> cinst /y texlive

TeX Live Manager を起動し、scheme-mediumcollection-langjapanese をインストールします。

image.png

image.png

コンパイル

Makefile を作ります。

Makefile
all: test.pdf
.SUFFIXES: .adoc .pdf

.adoc.pdf:
	asciidoctor -b docbook5 -o - $^ | pandoc -s -f docbook --pdf-engine=lualatex -V documentclass=ltjsarticle -o $@

Asciidoc ファイルの例です。

test.adoc
= Asciidoc のテスト
:author: みたゆうき

== はじめに
これはテスト文書です。
$ make
asciidoctor -b docbook5 -o - test.adoc | pandoc -s -f docbook --pdf-engine=lualatex -V documentclass=ltjsarticle -o test.pdf

出力結果です。如何にも TeX っぽい PDF になりました。

image.png

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?