I tried just surrounding the quote with another block with width: 50% and removing the padding with #show quote: set pad(x: 0pt). The result was closer to what I wanted, but it still has a small padding to the left, despite me removing the show rule.
Is there a way to select only the outer block to have width: 50%? Also, what am I getting wrong about the padding on the quote element? Finally, is there a way to reproduce (most of) the standard behaviour of the original element without resorting to rewriting it from scratch with a show rule?
Indeed a block quote is wrapped in a pad element, which is itself a kind of block element.
You did well: there is a default rule that does show quote: set pad(left: 1em, right: 1em). Your own set pad(x: 0pt) is a good way to cancel that. The remaining “padding” that you see is not really padding: it’s just that when you give a fixed size for the block, if the text is not justified it generally won’t fill the block width completely.
If you want to have the gray background flush with the edges of the text, I think you must either justify the text, or accept that the block will be a bit smaller or larger than 50%. The easiest would be to do something like block(width: 50%, block(fill: gray, your-content)): the outer block sets a maximum width of 50%, and the inner block will size itself with this constraint.
What you can do is set the width to 50% for quote elements, then add an “inner” rule to undo that:
#show quote: set block(width: 50%, fill: gray)
#show quote: set pad(0pt)
#show quote: it => {
show block: x => {
// Here the outer block is already materialized. Adding a set rule will
// only affect more inner blocks.
set block(width: auto)
x
}
it
}
What I meant by reproducing the default behaviour from scratch is kinda what you did by returning x and it from the closures in the show rules. Nice to see how I can subtly change the default behaviour like this.