Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
675 changes: 675 additions & 0 deletions packages/preview/rcv-ballot-templates/0.1.0/LICENSE.md

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions packages/preview/rcv-ballot-templates/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# rcv-ballot-templates

RCV ballot papers for Typst.

## Usage

```typst

#import "@preview/rcv-ballot-templates:0.1.0": ballot-template, choices
#set document(title: [ RCV Ballot ])
#show: ballot-template

= Contest 1

#choices([ Choice 1 ], [ Choice 2 ])
```

*FYI: `choices()` can be used by itself without the template.*

## License

```text
Copyright (C) 2026 Reese Armstrong

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
```
53 changes: 53 additions & 0 deletions packages/preview/rcv-ballot-templates/0.1.0/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#let choices(names, box-size: 0.5in, gap: 0.125in, text-size: 20pt, margin-top: 0.25cm) = {
v(margin-top)

for c in names {
stack(
dir: ltr,
box(
stroke: luma(0),
width: box-size,
height: box-size,
),
h(gap),
text( size: text-size, baseline: gap )[ #c ]
)
}
}

#let ballot-template(doc) = {
set text(16pt)
set par(
spacing: 20pt,
)
title(context {
if document.title != none {
document.title
} else [
RCV Ballot
]
})

[
Rank choices in ascending order from most preferred (1) to least preferred.

Rank all choices where you would be satisfied with the outcome.


=== Example

#set text(13pt)


Johnny and his friends are voting on lunch options. Johnny would be satisfied with either hot dogs or burgers, but prefers hot dogs.

Johnny ranks hot dogs number 1 and burgers number 2, but leaves pancakes blank because he would not be happy with them.

#image("media/example.png", width: 2in, height: 2in)

Check failure on line 46 in packages/preview/rcv-ballot-templates/0.1.0/lib.typ

View check run for this annotation

Typst package check / @preview/rcv-ballot-templates:0.1.0

packages/preview/rcv-ballot-templates/0.1.0/lib.typ#L46

The following error was reported by the Typst compiler: failed to load file (This file exists but is excluded from your package.)


#v(0.5cm)
]

doc
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/preview/rcv-ballot-templates/0.1.0/template/main.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import "@preview/rcv-ballot-templates:0.1.0": ballot-template, choices

#set document(title: [RCV Ballot])
#show: ballot-template

== Contest 1

#choices(([ Choice 1 ], [ Choice 2 ], [ Choice 3 ]))
15 changes: 15 additions & 0 deletions packages/preview/rcv-ballot-templates/0.1.0/typst.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "rcv-ballot-templates"
version = "0.1.0"
entrypoint = "lib.typ"
authors = ["reesericci"]
license = "GPL-3.0-or-later"
description = "Simple RCV ballots"
repository = "https://codeberg.org/reesericci/typst-rcv"
categories = ["office", "fun"]
exclude = ["media/example.png"]

[template]
path = "template"
entrypoint = "main.typ"
thumbnail = "media/thumbnail.png"
Loading