If I add a relative bottom padding to paragraphs via show rule, it breaks an absolute left padding to quotes, which gets then wrong size. A minimal working example:
#set page("a7") // just for presentation here
#show quote: set pad(left: 1cm)
A text.
#quote(block: true)[This quote gets correct padding.]
#show par: it => {
pad(bottom: 1em, it)
}
#quote(block: true)[This quote gets wrong padding.]
Ideally, in fact, I would use a weak vertical space after every paragraph, not padding. I tried to do so with code below, but it doesn’t work. That’s why I resorted to the pad function. If anyone knows a better way to accomplish this, please let me know.
Hello,
The way you are writing things results in the following code:
#set page("a7") // just for presentation here
#quote(block: false)[
#set pad(left: 1cm)
Not padded.
#pad(bottom: 1em)[Padded.]
]
To explain further:
The first show rule sets the left property of pad for the entire document.
The second show rule wraps the content of any par in pad(bottom: 1em).
The two rules do not interfere with each other. You can read the documentation at Styling – Typst Documentation to get a better idea of how show rules work!
It seems you didn’t try the minimal working example I wrote. I’ve put in it very small paragraphs and quotes, and a little padding (1cm) but the problem happens independently of that. Also, you’ve cited the docs: please note that I’ve styled the quotes according to the quotes documentation.
So, anyone has any idea why a paragraph’s bottom padding interferes (doubles) a quote’s left padding?
The problem, as I understand it, is that show quote: set pad(...) doesn’t just affect the specific pad that quote itself adds, but all pads inside the quote. Your second show rule adds another pad inside, so it also gets left: 1cm.
Unfortunately I’m not sure how to best fix this cleanly. As a workaround, you can manually specify left: 0em for that pad, I wouldn’t consider that clean really clean…
I would have suggested that, but it doesn’t seem to do anything; I’m not sure why. Vertical spacing between blocks is something I have not understood fully yet…
Here it does succeed in apply the paragraph’s padding without interfere in the quote’s padding…
But in fact I changed the way of accomplish this to setting the spacing in block element:
#set page("a7") // just for presentation here
#show quote: set pad(left: 1cm) // left padding
#show quote: set block(spacing: 2.2em) // vertical space around block quote
#show par: set block(spacing: 1.5em) // vertical space around paragraphs
#lorem(13)
#lorem(13)
#quote(block: true)[#lorem(13)]
#lorem(13)
I did in in fact try your MWE before writing my answer, but it seems my reply was too confusing. Sorry about that! As you found your answer and @Andrew explained, when I wrote
The two rules do not interfere with each other
I meant to emphasise that your show quote: set pad and show par: it => {} were adding up to each other.
About the documentation, there is nothing wrong with the way you wrote quote styling. As you say, it’s very much the same way the documentation does things.
Just so you’re aware,
#show par: set block(spacing: 1.5em) // vertical space around paragraphs
Removing this does not seem to affect your desired output, and I believe these exist only in the form of boxed display mathematics? See below
#set page("a7") // just for presentation here
#show par: set block(fill: yellow, spacing: 1.5em) // vertical space around paragraphs
#box[test, $"test"$, $ "test" a x + b $]
#block[test, $"test"$, $ "test" a x + b $]
#quote[test, $"test"$, $ "test" a x + b $]
Oops, I didn’t test this. After some debugging, I think par should be replaced with quote. The problem is that (I’m pretty sure) par doesn’t have pad inside of it, so changing pad for par doesn’t have any effect. If pad affected the `par, then instead this could be used:
#show quote: it => { show par: set pad(bottom: 1em); it }
This means that you didn’t in fact apply “paragraph’s padding”. Almost all elements are block-level, which means that modifying block’s settings will affect such elements. And you used show par|quote: set block in this case, so this would make sense (to work).
Some things are easily remembered. And with time, some issues are easier to remember, but others — harder. It also depends on whether the problem has surfaced/was mentioned several times or not. And on how big/impactful the change is. This will probably have a big impact.