In LaTeX, you can change the quote type (inline/block) based on the quote length (e.g. as defined by APA):
\usepackage[thresholdtype=words]{csquotes}
\SetBlockThreshold{40}
Is there a way to do that in Typst?
In LaTeX, you can change the quote type (inline/block) based on the quote length (e.g. as defined by APA):
\usepackage[thresholdtype=words]{csquotes}
\SetBlockThreshold{40}
Is there a way to do that in Typst?
Hey @Waldo, welcome to the forum! I’ve changed your question post’s title to better fit our guidelines: How to post in the Questions category
Make sure your title is a question you’d ask to a friend about Typst.
(By the way, the title was also a bit unclear to me so you may want to change it further.)
Can you elaborate on this / give an example? You can always use #quote(block: true / false)[... stuff ...]
as needed, if you’re referring to block quotes.
APA demands that if a Quote is longer than 40 Words, it’s displayed as a block. If it’s shorter than 40 Words, it should be inline.
e.g.
He said “my cat is cute” [source].
vs.
He said
— Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. [source]
I don’t want to manually count the words but automatically do inline/block based on wordcount.
You can try this solution through the wordometer
package. It probably won’t be perfect, but should work for most common cases:
#import "@preview/wordometer:0.1.4": word-count, total-words
#let dyn-quote(body, block-threshold: 40, attribution: none, ..args) = word-count(total => {
quote(body, block: total.words > block-threshold, attribution: attribution, ..args)
// optional: remove this to remove inline attribution
if attribution != none and total.words <= block-threshold {
if type(attribution) == label {
[#[ #ref(attribution)] <inline-attrib>]
} else {
[#[ (#attribution)] <inline-attrib>]
}
}
}, exclude: <inline-attrib>)
// Usage
// Could also be 'apa-quote' with a threshold of 40
#let small-quote = dyn-quote.with(block-threshold: 3)
They said #small-quote(attribution: [John Johnson])[Hello world!]
They also said #small-quote(attribution: [John Johnson], lorem(10))
Nice solution. In fact, the document show rule
#show: word-count
is unnecessary. It’s only needed to enable global word counts with the total-words
state variable.
Ah, thank you! I’ve removed it from my answer.