Developing software in the Real World

Background images and multiple styles in rst2pdf

Over the weekend I released rst2pdf 0.99. The list of changes is quite long as it’s been over a year since the last release.

There are some key things in this release that I’m particularly pleased about including Python 3.9 and 3.10 & Sphinx 4 support, multiple styles in the class directive and the ability to specify background images in the raw:: pdf directive. There’s also a number of bug fixes, particular to math rendering and errors.

I use rst2pdf to write the slides for talks that I give, so going to use background images and multiple styles in class a lot!

Background images

It’s not uncommon that I want a background image on a slide for a title page. Prior to 0.99, I would do this in presentation.rst:

with a page template defined in style.yaml:

For every different background image, I have do define a new page template in my style file isn’t great.

With rst2pdf 0.99, I can specify the image in the PageBreak directive:

Now, just one page template is required for all my title pages.

Multiple styles in the class directive

Another situation I sometimes have is when I want to apply more than one style modifier to some text.

For example, rendering multiple paragraphs that need to be aligned differently with different colours. Previously, I would generate a new style for each combination:

and so on, depending on which combinations are needed.

I can then use like this in my rst file:

With rst2pdf 0.99, we can now specify more than one style in the class directive, so we can separate the styles:

and then apply them appropriately:

Hopefully, this will make my style file that much clearer and easier to understand!

Try it out

With rst2pdf 0.99 we are getting very close now to 1.0 now and I’d love to see some people kick the tyres and see if it works for them. Restructured Text is a good markup format for documentation and is easy to publish to the web and PDF. Try it out and report any issues you find on GitHub.

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *