3

I created a presentation in Quarto with code and outputted it to RevealJS and PPTX. The font size for code in RevealJS is sensible, but the font-size in PowerPoint is gigantic, so the same slide looks very different in RevealJS and PPTX.

Is there a configuration to reduce the font size for monospace fonts in PPTX?

Lucas A. Meyer
  • 428
  • 3
  • 8

1 Answers1

0

I couldn't find a configuration, but I wrote a quick Python script that uses the python-pptx package to change the fonts. I run it after rendering the presentation.

I first set the font in the YAML as Consolas (to make it easier to find):

format: 
    pptx:
       reference-doc: templates/template.pptx
       monofont: "Consolas"
from pptx.util import Pt
from pptx import Presentation

prs = Presentation(path)

# text_runs will be populated with a list of strings,
# one for each text run in presentation
text_runs = []

for slide in prs.slides:
    for shape in slide.shapes:
        if not shape.has_text_frame:
            continue
        for paragraph in shape.text_frame.paragraphs:
            for run in paragraph.runs:
                if run.font.name == "Consolas":
                    run.font.size = Pt(12)

prs.save(new_path)
Lucas A. Meyer
  • 428
  • 3
  • 8
  • 1
    Did you change the default font size in `templates/template.pptx` and that did not take effect ? I would expect this to work with Pandoc. If not, could be seen as an issue as reference document are used for styling – cderv Jul 07 '22 at 22:54
  • It works, but then it changes the font for all the other text in the PPTX, too. In RevealJS, the monospace font is noticeably smaller than the "normal" presentation font. In PowerPoint, both follow the template size, which is reasonable for the "normal slide font", but extremely large for code. – Lucas A. Meyer Jul 07 '22 at 23:26
  • Maybe this is a better way to explain it: RevealJS uses a different (and smaller) font for echoed code blocks. PowerPoint doesn't seem to have that feature, so the echoed code block uses the default font, which is usually big. – Lucas A. Meyer Jul 07 '22 at 23:31
  • 1
    With powerpoint, you need to identified the style used by the text you want to change, and just modify this style in the reference doc. But it is maybe really limited compare to docx where you can set Custom styling. With powerpoint you need to customize the template for the layout used https://pandoc.org/MANUAL.html#powerpoint-layout-choice and yes it does not seem you can tweak a specific font size for some part unfortunately – cderv Jul 08 '22 at 16:01
  • How did you change the font size with revealjs?! I've been trying to change it for hours ; ;. – ethan tenison Aug 10 '22 at 23:51