Trying to migrate a number of my reports to using templates and this is getting me 95% there. I'm only missing the ability to add styling to the headers and footers. Would like to add Bolds and Italics, but if I can enter in AsciiDoc content instead, I would be able to migrate all of my documents.
Any of these options would be helpful:
footer:
recto_content_center: '*Page* {page-number} of {page-count}'
footer:
recto_content_center: '\textbf{Page} {page-number} of {page-count}'
footer:
recto_content_center: '<b>Page</b> {page-number} of {page-count}'
Bonus points if AsciiDoc markup is available as I would be able to implement tables and blocks.
You can use the first form, which is preferred. See https://github.com/asciidoctor/asciidoctor-pdf/blob/master/docs/theming-guide.adoc#attribute-references for details.
Technically, you can also embed a limited set of HTML that the parser understands (see https://github.com/asciidoctor/asciidoctor-pdf/blob/master/lib/asciidoctor-pdf/formatted_text/parser.treetop#L50-L59), but you need to use a pass macro (just like you would in an AsciiDoc document).
footer:
recto_content_center: 'pass:a[<b>Page</b> {page-number} of {page-count}]'
Always use the pass macro carefully because it could prevent things from being escaped that should be.
If there is something not clear in the guide, I'd be happy to clarify it.
So it does work, guess I should test a bit more before I post.
In that case, how do I provide more advanced formatting such as tables? I have a footer that contains a series of version numbers and template name references as part of a corporate reference. Some of it is left-aligned and some is right aligned. Since I can't use multiple alignments at once, I would like to implement a table instead. When I try this in the YML file, I get the content of the table markup instead:
footer_recto_content_center: |
|===
|*Template Name*|AB123|*Document Name*|Test Doc +
| |*Page*|{page-number} of {page-count}| +
|===
All I can tell you is that it's out of scope for right now. You can sort of fake it using hard line breaks and perhaps some non-breaking spaces, but tables just aren't possible right now.
I'm not going to say never, because as we build better abstractions, harder things become possible. But right now that would be too difficult to implement and lower priority than some really pressing issues we've got still floating.
While I'd like to +1 on the need for having a table in header/footer, for now I also have a question regarding inline styling: I want to have just one part of the footer having a red font, e.g.:
recto_content:
right: '{page-number}/{page-count}'
center: '[red]*Restricted*'
and while the _Restricted_ word is bolded, it has the default font color. Am I doing it wrong or is it not possible to have inline font coloring in header/footer?
Colors are not yet supported for inline text. See #350 and #376.
1.5.0.alpha.13 will introduce the option to layout the running content into 3 columns and align the content within each columns (left, center or right). That should give you much more control over the layout. See #449. It also includes some hints about how to have multi-line content.
Since the requests in this issue are covered by other issues, I'm going to close this issue. Please add any follow-up you might have in those other issues.
...I want to have just one part of the footer having a red font, e.g.:
recto_content: right: '{page-number}/{page-count}' center: '[red]*Restricted*'and while the _Restricted_ word is bolded, it has the default font color. Am I doing it wrong or is it not possible to have inline font coloring in header/footer?
In case anyone is still looking for a solution, I've created a footer with black center text and an orange page number like this in my yaml theme template (only showing the attributes that needed to be changed):
footer:
font_color: 000000
recto:
left:
content: " pass:a[<font><color rgb=\"#E6731D\">{page-number}</color></font>] "
center:
content: 'black center text here'
verso:
right:
content: $footer_recto_left_content
center:
content: $footer_recto_center_content
Credits to this guide on quoted strings for the idea. Actually the guide is unclear, this thread helped me realize I needed the passthrough macro.
Thanks for sharing.
Actually the guide is unclear
Feel free to submit a revision if you think the guide could be made more clear.
Most helpful comment
So it does work, guess I should test a bit more before I post.
In that case, how do I provide more advanced formatting such as tables? I have a footer that contains a series of version numbers and template name references as part of a corporate reference. Some of it is left-aligned and some is right aligned. Since I can't use multiple alignments at once, I would like to implement a table instead. When I try this in the YML file, I get the content of the table markup instead: