Output code overflow
First of all, thanks a lot for this. I jumped right in and created my version based on your template.
However, how are you dealing with this?
---
title: "Pretty PDFs with Quarto - Output overflow?"
format: PrettyPDF-pdf
---
The geometry was adjusted to make room for the border on the right hand side via `\geometry{a4paper, total={170mm,257mm}, left=20mm, top=20mm, bottom=20mm, right=50mm}`.
However, the code output does not seem to be affected by this?
```{r}
letters
```
I spent some time trying to fix it and found e.g. this but so far no solution for me so that I may need to go back to default geometry and no border on the right side :(
To control output text the quick fix as per the R Markdown Cookbook https://bookdown.org/yihui/rmarkdown-cookbook/text-width.html is to specify options(width = 70) (or whatever number is relevant, maybe you need slightly less, I think the default is 85), i.e., you can do this in either the YAML header as
---
title: "Pretty PDFs with Quarto - Output overflow?"
format: PrettyPDF-pdf
engine: knitr
knitr:
opts_chunk:
R.options:
width: 70
---
or in a chunk near the start of your doc, e.g.
---
title: "Pretty PDFs with Quarto - Output overflow?"
format: PrettyPDF-pdf
---
```{r}
#| include: false
options(width = 70)
```
but you might need to get into trickery with the LaTeX listings package as well.
Thank you! This solves the issue. I was sceptical whether it would actually also decrease the box's width - which you can't see in PrettyPDF, so I used my modified version with a green bg color to check. But yeah, seems to work perfectly:
Thanks @remlapmot, the width options is what I'm currently using as well to deal with this problem. I'm going to leave this issue open for now since I'm working on a non-R specific fix using LaTeX.
That's great.
This is a great extension.
On a different point, for your super Quarto tutorials blog post Frank Dondelinger and I (coincidentally when Frank and I were both at Lancaster) had the equivalent older R Markdown trick of placing the answer text within an asis chunk, i.e.,
```{asis}
Solutions text goes here
```
(whose include status is similarly toggled by the global knitr chunk options).
I realised that your Quarto solution would probably work for other engines, and I managed to get it working for the jupyter: python3, jupyter:nbstata (for Stata), and engine: julia.
https://remlapmot.github.io/post/2025/quarto-conditional-content/
It will be great when Quarto allows the equivalent of ! expr in chunk options for other engines.
cheers Tom