YasAko
YasAko

Reputation: 1

How to add borders to headings in AsciiDoctor-pdf PDF output

How to add borders to headings in AsciiDoctor-pdf PDF output.

(I am not an English speaker. Ask me if any expressions are difficult to understand).

I am a high school student and I am using AsciiDoctor-PDF to create documents for other students to look at.

https://docs.asciidoctor.org/pdf-converter/latest/theme/heading/#level

documentation

I want to put a border around a heading using the border in the URL above.

The border around the heading would look like the image below.
The top text is on level 2 and the bottom text is on level 3 in the image.

output-pdf

What should I do?

heading:
  h1_font_size: floor($base_font_size * 2.4)
  h2:
    font_size: floor($base_font_size * 2.4)
    border-width: [0.75, 0, 2, 0]
    border-color: 000000

Upvotes: 0

Views: 481

Answers (1)

eskwayrd
eskwayrd

Reputation: 4521

You are close, but I suspect that your impression of the heading level is incorrect.

To demonstrate that adding borders to heading works, here's a simple document:

= Document
:pdf-theme: ./pdf-theme.yml

Lorem ipsum...

== Section 1

This is section 1.

=== Subsection A

Section 1 has a subsection.

== Section 2

This is section 2.

And here is the content of pdf-theme.yml:

extends: default-with-font-fallbacks
heading:
  h2:
    font-size: floor($base_font_size * 2.4)
    border-color: #ff0000
    border-width: 2pt
  h3:
    font-size: 22pt

That renders like this:

enter image description here

I suspect that in your document, the heading you are trying to style is a level 3 or level 4 heading, which is why you do not see the border. You have only added the border style for level 2 headings.

Upvotes: 0

Related Questions