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.