asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.13k stars 500 forks source link

PDF theme default values not respected #2491

Closed houserockr closed 5 months ago

houserockr commented 5 months ago

Problem description

We use doctoolchain for a documentation project. dtc uses asciidoctor-pdf under the hood and I can reproduce my problem isolated by simply calling asciidoctor-pdf on one of our *.adoc files. Which is why I'm posting the problem here instead of doctoolchain.

After a recent upgrade of dtc from v2.2.0 to 3.2.0, our document started to look extremely compressed, i.e. all the (default) margins were basically non existent or set to 0.

Our pdf theme looks as follows:

expand custom-theme.yml ```yaml page: layout: portrait margin: [0.75in, 1in, 0.75in, 1in] size: A4 font: catalog: Roboto: # snip DejaVu Sans: # snip Noto Serif: # snip conum: font-family: Noto Serif base: font-family: Roboto font-color: #000000 font-size: 10 line-height-length: 11 line-height: $base_line_height_length / $base_font_size vertical-spacing: $base_line_height_length heading: # this should avoid orphans and widows with asciidoctor 2.2.0+ #min-height-after: auto font_color: #223c81 font_size: 18 font-family: Noto Serif font_style: bold line_height: 1.2 margin_bottom: $vertical_spacing margin-top: 4 # h1 is used for part titles (book doctype) or the doctitle (article doctype) h1_font_size: floor($base_font_size * 2.6) # h2 is used for chapter titles (book doctype only) h2_font_size: 14 h2_margin_bottom: 17 h3_font_size: 14 h3_margin_bottom: 12 h4_font_size: 12 h5_font_size: $heading_h4_font_size h6_font_size: $heading_h4_font_size # If I leave this out, the default will not be 12 like the docs state #block: # margin-bottom: 12 code: font-family: M+ 1mn font-size: $base_font_size border-color: #ffffff background-color: #f7f7f7 line-height: $base_line_height padding: $base_line_height_length / 2 # Inline code/commands with `` codespan: font-family: $code_font_family # unset font size to use that of the context (e.g. base or heading) font-size: ~ background-color: $code_background_color link: font_color: #00007f text_decoration: underline list: indent: $base_font_size * 1.5 header: height: 0.75in line_height: 1 recto: center: content: '{document-title} {document-subtitle}' verso: center: content: '{document-title} {document-subtitle}' image: align: left caption: align: left font_color: #223c81 font_size: 11 margin-inside: 4 margin-outside: 8 title_page: align: left logo: image: image:foo.svg[pdfwidth=30%, align=left] top: 10% title: font_size: 24 font_style: bold font_color: #223c81 toc: h2-font-style: bold h3-font-style: bold running-content: start-at: toc ```

For example, the docs state a default of 12 for block-margin-bottom.

If I explicitly add the block-margin-bottom: 12 to my theme, the resulting document looks as expected, i.e. having a well visible vertical space after blocks (e.g. code blocks).

When commented out however, the default is not 12 and the resulting document displays blocks without any space. Which leads me to believe the default might be 0.

Unfortunately, this is not only the case for the block-* classes, but also for headings.

This is how I invoke asciidoctor-pdf:

$ asciidoctor-pdf -a pdf-theme=custom -a pdf-themesdir=pdfTheme -a pdf-fontsdir=fonts src/foo.adoc

Where the yaml-theme is described in custom-theme.yml.

Environment

mojavelinux commented 5 months ago

Your theme does not extend any theme. Therefore, it starts with an empty theme with no inherited properties. This is stated in the release notes for 2.0.0. See https://docs.asciidoctor.org/pdf-converter/2.0/whats-new/#themes It's also mentioned several times in the docs, such as https://docs.asciidoctor.org/pdf-converter/latest/theme/create-theme/#extend-default. Therefore, if you want to extend the default theme, it should start with the following line:

extends: default

In the future, if you have questions related to usage (which includes upgrading), please direct those questions to the project chat at https://chat.asciidoctor.org (users/asciidoctor-pdf stream). Thanks!