Asciidoctor-pdf: How to make the title of image be center?

Created on 28 Mar 2017  Â·  7Comments  Â·  Source: asciidoctor/asciidoctor-pdf

Hi, everybody.
I'm using asciidoctor-pdf to generate pdf.
But I want to know how to make the title of image be center?
Thanks

Most helpful comment

For anyone else who finds this and is wondering how to go about doing this quickly, it's actually fairly simple. Just create a file called theme.yml with the following contents:

extends: default
image:
  align: center
caption:
  align: center

Then create your PDF using the following command:

asciidoctor-pdf -a pdf-style=theme.yml your_document.adoc

All 7 comments

Currently it's only possible to align block captions globally using the theme file. See https://github.com/asciidoctor/asciidoctor-pdf/blob/master/docs/theming-guide.adoc#keys-caption

It's not currently possible to control the caption position per block. This is likely something we first need to resolve in Asciidoctor core. It looks like you already found it, though. See https://github.com/asciidoctor/asciidoctor/issues/857.

all right , thanks

For anyone else who finds this and is wondering how to go about doing this quickly, it's actually fairly simple. Just create a file called theme.yml with the following contents:

extends: default
image:
  align: center
caption:
  align: center

Then create your PDF using the following command:

asciidoctor-pdf -a pdf-style=theme.yml your_document.adoc

@dohliam you are absolutely correct, this can be controlled by the theme. What's more, in 1.5.0-rc.2, you can configure the caption alignment to inherit from the image alignment.

extends: default
image:
  caption:
    align: inherit

Then you'd define a block image as follows:

image::filename.png[align=center]

Now both the image and caption will be aligned to the center.

What's not possible is to control the alignment of the caption from the AsciiDoc. It can only be controlled by the theme.

I'm having this exact problem.

I've gotta say it makes no sense that the image-caption is not contained in the same html-block (the same div) as the image. How many use cases are there, where somebody goes: "I'd like my image to be right-aligned, but I want the caption to be much wider than the image, and I want it in the center"

Screenshot from 2020-11-17 15-21-15

I can see from my searches that a lot of people are annoyed by this, and rightfully so, I must say. Are anybody working on this issue?

@acebone I don't like the aggressive tone of your comment. It's not welcome here. If you ask again in a constructive way without the insults, I'd be happy to walk you through how to achieve the result you want.

I'm sorry - I was very annoyed at the time, I can totally understand you
resenting that way of addressing others. It's simply not ok. I don't
usually respond in that way, and I'll make an effort to see that it will
not happen again.

I am wrong btw. The markup is as it should be, so the fix lies in CSS.

Once again Dan, I do apologize

Den tir. 17. nov. 2020 kl. 20.33 skrev Dan Allen notifications@github.com:

I don't like the aggressive tone of your comment. It's not welcome here.
If you ask again in a constructive way without the insults, I'd be happy to
walk you through how to achieve the result you want.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/asciidoctor/asciidoctor-pdf/issues/790#issuecomment-729153549,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABFJZOY2DG6H65IVRVXGY3SQLFYRANCNFSM4DFM3M7A
.

Was this page helpful?
0 / 5 - 0 ratings