So, recently I am working with some legal norms and need to write or publish some myself. These include ‘(Vereins)satzungen’ und ‘Verordnungen’ in German law system (i think the english terms are: 'statute, ‘charter’ and ‘constitution’ and ‘act’, ‘ordinance’ and ‘regulation’).
However, i would like to use typst to typeset some of these and i wonder how i can reliably typeset paragraph numbers, and sentence numbering. Here is an example:
PS: as you can see the current formatting is less than ideal. e.g. why are there bullet points???)
I have a somewhat working example here:
https://typst.app/project/RgpXazQvZNkkDyOMvUd8jM
(I would still need to implement some kind of check if there is only one paragraph or one sentence. In these cases the number is usually left out in law texts.)
However, its somewhat cumbersome to use. For every article one needs to call the article(name, ..paragraphs) function. and every paragraph is a list of content blocks. That is not what I imagined i nterms of usability - especially if i want to work with other, less technical people together on this.
Is there a better way to conceptualize articles? is there a better way to count/number paragraphs? Is there a better way to count/number sentences?
Actually i thought some people would have developed packages for this already, but i couldn’t find any on the universe.
I appreciate you taking the time to explain what you have tried.
Indeed, there’s an existing package for this when searching with the keyword law:
Unfortunately this package doesn’t automate the numbering.
Let us know whether that is enough to satisfy your needs. Additionally:
- The best solution to this in the future will probably be
par.line(numbering: ...). At this point, I don’t think it’s that feasible really.
- Instead of thinking of these paragraphs as
par, why not enum or terms? As seen in delegis screenshots, there can obviously be multiple levels which is something to be wary of:
2 Likes
What do you think of this solution, which uses Typst sections for legal sections, level-1 enums for numbered paragraphs, and level-2 enums for numbered sentences?
https://typst.app/project/rGC9SCKI8GJsiSDXhFPZnw
1 Like
Thank you for your replies.
@hpcfzl that looks nice, thanks for mentioning.
For my taste it is a little to less modular. I think it would be nice to be able to choose which features are applied. currently it’s more or less like all or nothing.
In general i really like the approach and the regex auto separation of paragraphs makes it very ergonomic. Overall there are a lot of nice tricks in your package.
I do have one or two special use cases that are not possible with the package, but it’s probably better to discuss these in issues on github.
One thing right here: The fourth edition was released and the ‘Randnummern’ are now numbered differently. Thus, would be nice if you’d update the comments in the source code 
@akoller thanks for your idea. I thought about something like this as well. Although it’s very handy abusing the enum syntax, i think it’s a footgun in the long run when it comes to more complex documents.
anyways, i don’t want to mark a solution right now. currently i need to finish my thesis and i will definitely get back to this in a week or at least a month.
I will either come up with a template/package of my own or see if we can work out somthing together @hpcfzl
I think show rules for standard elements are pretty normal in Typst. If you’re worried about polluting the rest of your document, you can always move the rules to a function and pass your text as a content argument. But of course you get to pick which solution you like. :)
I would first like to clarify that delegis is not my package, so you should probably consult with the actual author. Especially about the layout you would like to follow. Because despite your sample being very similar to theirs, there still are subtle differences, such as paragraph justification and the headings not being single-line. Would be a shame to have a separate package for the same purpose only to find the author was willing to approve your changes all along. Even for an updated edition, a package version update would be more welcoming to users, at least long-term.
I and likely others here as well otherwise have no problem in helping further, just ensure that you provide all we need to know about your desired layout. You already mentioned excluding single-paragraph and single-sentence numbering, but there’s definitely more to consider. The screenshots delegis has are useful for example.
Anyway, this code is something like your attempt, still without properly numbered paragraphs and missing first sentences’ numbering:
Code
/*
In case `+ ...` are going to be individual paragraphs,
uncomment this to have `enum` use `hanging-indent`
*/
// #import "@preview/itemize:0.2.0" as el
// #show: el.paragraph-enum-list
#show title: set align(center)
#show heading: set align(center)
#set page(numbering: "1", number-align: right)
#set text(font: "Liberation Sans", lang: "de")
#set par(justify: true, leading: 1em)
// Paragraph counter
// (depends on whether or not `+ ...` are used for them)
// Sentence counter
#let sen-num = counter("sen")
// Each heading resets the sentence counter
#show heading.where(numbering: "§ 1"): it => {
sen-num.update(1)
it
}
// These are considered to be sentences
#show regex("\. \p{Lu}"): it => context {
let (x, y) = it.text.split(" ")
// Ignores sentences present before the first numbered heading
if sen-num.get().first() == 0 { return it }
x + sym.space + super(sen-num.display()) + y
sen-num.step()
}
#lorem(50)
= #lorem(5)
#lorem(50)
#title(lorem(6))
#set heading(numbering: "§ 1")
= #lorem(6)
+ #lorem(50)
+ #lorem(50)
+ #lorem(50)
= #lorem(5)
+ #lorem(50)
+ #lorem(10)
+ #lorem(10)
= #lorem(5)
+ #lorem(5)
Output