1
0

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 1 year has passed since last update.

Asciidoctorで図キャプションを図に合わせる

Posted at

1. はじめに

図を左寄せ、中央、右寄せにしたときに、図キャプションが左寄せになってしまうのを解消してみた。

処理系は、 asciidoctor.js。Rubyのasciidoctorでも同じだと思う。

https://discuss.asciidoctor.org/How-to-center-image-caption-when-the-image-is-centered-td901.html
https://github.com/asciidoctor/asciidoctor/issues/857
この辺をそのまま利用させてもらった。

2. デフォルト

main.adoc
= イメージの整列
:imagesdir: ./image

== right

.右寄せ
image::right.png[align="right"]

== center

.中央
image::center.png[align="center"]

== left

.左寄せ
image::left.png[align="left"]

キャプションは左寄せ

pic1.png

3. キャプションを図に合わせる

docinfoを設定する

main.adoc
= イメージの整列
:docinfo: shared
:imagesdir: ./image

== right

.右寄せ
image::right.png[align="right"]

== center

.中央
image::center.png[align="center"]

== left

.左寄せ
image::left.png[align="left"]

docinfo.html を次のように設定

docinfo.html
<style type="text/css"> .imageblock > .title { text-align: inherit; } </style>

docinfoはこのあたり
https://docs.asciidoctor.org/asciidoctor/latest/docinfo/
htmlのhead部分にそのまま出力されるみたい。

キャプションが図に合わせて移動

pic2.png

ん、右寄せは、ちょっとおかしいか。

1
0
1

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?