Skip to content

Commit de427a3

Browse files
authored
charged-ieee:0.1.4 and wonderous-book:0.1.2 (#2901)
1 parent eb3249d commit de427a3

File tree

13 files changed

+711
-0
lines changed

13 files changed

+711
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
MIT No Attribution
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
4+
software and associated documentation files (the "Software"), to deal in the Software
5+
without restriction, including without limitation the rights to use, copy, modify,
6+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7+
permit persons to whom the Software is furnished to do so.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
10+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
11+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
13+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
14+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# charged-ieee
2+
This is a Typst template for a two-column paper from the proceedings of the
3+
Institute of Electrical and Electronics Engineers. The paper is tightly spaced,
4+
fits a lot of content and comes preconfigured for numeric citations from
5+
BibLaTeX or Hayagriva files.
6+
7+
## Usage
8+
You can use this template in the Typst web app by clicking "Start from template"
9+
on the dashboard and searching for `charged-ieee`.
10+
11+
Alternatively, you can use the CLI to kick this project off using the command
12+
```
13+
typst init @preview/charged-ieee
14+
```
15+
16+
Typst will create a new directory with all the files needed to get you started.
17+
18+
## Configuration
19+
This template exports the `ieee` function with the following named arguments:
20+
21+
- `title`: The paper's title as content.
22+
- `authors`: An array of author dictionaries. Each of the author dictionaries
23+
must have a `name` key and can have the keys `department`, `organization`,
24+
`location`, and `email`. All keys accept content.
25+
- `abstract`: The content of a brief summary of the paper or `none`. Appears at
26+
the top of the first column in boldface.
27+
- `index-terms`: Array of index terms to display after the abstract. Shall be
28+
`content`.
29+
- `paper-size`: Defaults to `us-letter`. Specify a [paper size
30+
string](https://typst.app/docs/reference/layout/page/#parameters-paper) to
31+
change the page format.
32+
- `bibliography`: The result of a call to the `bibliography` function or `none`.
33+
Specifying this will configure numeric, IEEE-style citations.
34+
- `figure-supplement`: How figures are referred to from within the text. Use
35+
`"Figure"` instead of `"Fig."` for computer-related publications.
36+
37+
The function also accepts a single, positional argument for the body of the
38+
paper.
39+
40+
The template will initialize your package with a sample call to the `ieee`
41+
function in a show rule. If you want to change an existing project to use this
42+
template, you can add a show rule like this at the top of your file:
43+
44+
```typ
45+
#import "@preview/charged-ieee:0.1.4": ieee
46+
47+
#show: ieee.with(
48+
title: [A typesetting system to untangle the scientific writing process],
49+
abstract: [
50+
The process of scientific writing is often tangled up with the intricacies of typesetting, leading to frustration and wasted time for researchers. In this paper, we introduce Typst, a new typesetting system designed specifically for scientific writing. Typst untangles the typesetting process, allowing researchers to compose papers faster. In a series of experiments we demonstrate that Typst offers several advantages, including faster document creation, simplified syntax, and increased ease-of-use.
51+
],
52+
authors: (
53+
(
54+
name: "Martin Haug",
55+
department: [Co-Founder],
56+
organization: [Typst GmbH],
57+
location: [Berlin, Germany],
58+
email: "haug@typst.app"
59+
),
60+
(
61+
name: "Laurenz Mädje",
62+
department: [Co-Founder],
63+
organization: [Typst GmbH],
64+
location: [Berlin, Germany],
65+
email: "maedje@typst.app"
66+
),
67+
),
68+
index-terms: ("Scientific writing", "Typesetting", "Document creation", "Syntax"),
69+
bibliography: bibliography("refs.bib"),
70+
)
71+
72+
// Your content goes below.
73+
```
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
// This function gets your whole document as its `body` and formats
2+
// it as an article in the style of the IEEE.
3+
#let ieee(
4+
// The paper's title.
5+
title: [Paper Title],
6+
7+
// An array of authors. For each author you can specify a name,
8+
// department, organization, location, and email. Everything but
9+
// but the name is optional.
10+
authors: (),
11+
12+
// The paper's abstract. Can be omitted if you don't have one.
13+
abstract: none,
14+
15+
// A list of index terms to display after the abstract.
16+
index-terms: (),
17+
18+
// The article's paper size. Also affects the margins.
19+
paper-size: "us-letter",
20+
21+
// The result of a call to the `bibliography` function or `none`.
22+
bibliography: none,
23+
24+
// How figures are referred to from within the text.
25+
// Use "Figure" instead of "Fig." for computer-related publications.
26+
figure-supplement: [Fig.],
27+
28+
// The paper's content.
29+
body
30+
) = {
31+
// Set document metadata.
32+
set document(title: title, author: authors.map(author => author.name))
33+
34+
// Set the body font.
35+
// As of 2024-08, the IEEE LaTeX template uses wider interword spacing
36+
// - See e.g. the definition \def\@IEEEinterspaceratioM{0.35} in IEEEtran.cls
37+
set text(font: "TeX Gyre Termes", size: 10pt, spacing: .35em)
38+
39+
// Enums numbering
40+
set enum(numbering: "1)a)i)")
41+
42+
// Tables & figures
43+
show figure: set block(spacing: 15.5pt)
44+
show figure: set place(clearance: 15.5pt)
45+
show figure.where(kind: table): set figure.caption(position: top, separator: [\ ])
46+
show figure.where(kind: table): set text(size: 8pt)
47+
show figure.where(kind: table): set figure(numbering: "I")
48+
show figure.where(kind: image): set figure(supplement: figure-supplement, numbering: "1")
49+
show figure.caption: set text(size: 8pt)
50+
show figure.caption: set align(start)
51+
show figure.caption.where(kind: table): set align(center)
52+
53+
// Adapt supplement in caption independently from supplement used for
54+
// references.
55+
set figure.caption(separator: [. ])
56+
show figure: fig => {
57+
let prefix = (
58+
if fig.kind == table [TABLE]
59+
else if fig.kind == image [Fig.]
60+
else [#fig.supplement]
61+
)
62+
let numbers = numbering(fig.numbering, ..fig.counter.at(fig.location()))
63+
// Wrap figure captions in block to prevent the creation of paragraphs. In
64+
// particular, this means `par.first-line-indent` does not apply.
65+
// See https://github.com/typst/templates/pull/73#discussion_r2112947947.
66+
show figure.caption: it => block[#prefix~#numbers#it.separator#it.body]
67+
show figure.caption.where(kind: table): smallcaps
68+
fig
69+
}
70+
71+
// Code blocks
72+
show raw: set text(
73+
font: "TeX Gyre Cursor",
74+
ligatures: false,
75+
size: 1em / 0.8,
76+
spacing: 100%,
77+
)
78+
79+
// Configure the page and multi-column properties.
80+
set columns(gutter: 12pt)
81+
set page(
82+
columns: 2,
83+
paper: paper-size,
84+
// The margins depend on the paper size.
85+
margin: if paper-size == "a4" {
86+
(x: 41.5pt, top: 80.51pt, bottom: 89.51pt)
87+
} else {
88+
(
89+
x: (50pt / 216mm) * 100%,
90+
top: (55pt / 279mm) * 100%,
91+
bottom: (64pt / 279mm) * 100%,
92+
)
93+
}
94+
)
95+
96+
// Configure equation numbering and spacing.
97+
set math.equation(numbering: "(1)")
98+
show math.equation: set block(spacing: 0.65em)
99+
100+
// Configure appearance of equation references
101+
show ref: it => {
102+
if it.element != none and it.element.func() == math.equation {
103+
// Override equation references.
104+
link(it.element.location(), numbering(
105+
it.element.numbering,
106+
..counter(math.equation).at(it.element.location())
107+
))
108+
} else {
109+
// Other references as usual.
110+
it
111+
}
112+
}
113+
114+
// Configure lists.
115+
set enum(indent: 10pt, body-indent: 9pt)
116+
set list(indent: 10pt, body-indent: 9pt)
117+
118+
// Configure headings.
119+
set heading(numbering: "I.A.a)")
120+
show heading: it => {
121+
// Find out the final number of the heading counter.
122+
let levels = counter(heading).get()
123+
let deepest = if levels != () {
124+
levels.last()
125+
} else {
126+
1
127+
}
128+
129+
set text(10pt, weight: 400)
130+
if it.level == 1 {
131+
// First-level headings are centered smallcaps.
132+
// We don't want to number the acknowledgment section.
133+
let is-ack = it.body in ([Acknowledgment], [Acknowledgement], [Acknowledgments], [Acknowledgements])
134+
set align(center)
135+
set text(if is-ack { 10pt } else { 11pt })
136+
show: block.with(above: 15pt, below: 13.75pt, sticky: true)
137+
show: smallcaps
138+
if it.numbering != none and not is-ack {
139+
numbering("I.", deepest)
140+
h(7pt, weak: true)
141+
}
142+
it.body
143+
} else if it.level == 2 {
144+
// Second-level headings are run-ins.
145+
set text(style: "italic")
146+
show: block.with(spacing: 10pt, sticky: true)
147+
if it.numbering != none {
148+
numbering("A.", deepest)
149+
h(7pt, weak: true)
150+
}
151+
it.body
152+
} else [
153+
// Third level headings are run-ins too, but different.
154+
#if it.level == 3 {
155+
numbering("a)", deepest)
156+
[ ]
157+
}
158+
_#(it.body):_
159+
]
160+
}
161+
162+
// Style bibliography.
163+
show std.bibliography: set text(8pt)
164+
show std.bibliography: set block(spacing: 0.5em)
165+
set std.bibliography(title: text(10pt)[References], style: "ieee")
166+
167+
// Display the paper's title and authors at the top of the page,
168+
// spanning all columns (hence floating at the scope of the
169+
// columns' parent, which is the page).
170+
place(
171+
top,
172+
float: true,
173+
scope: "parent",
174+
clearance: 30pt,
175+
{
176+
{
177+
set align(center)
178+
set par(leading: 0.5em)
179+
set text(size: 24pt)
180+
block(below: 8.35mm, title)
181+
}
182+
183+
// Display the authors list.
184+
set par(leading: 0.6em)
185+
for i in range(calc.ceil(authors.len() / 3)) {
186+
let end = calc.min((i + 1) * 3, authors.len())
187+
let is-last = authors.len() == end
188+
let slice = authors.slice(i * 3, end)
189+
grid(
190+
columns: slice.len() * (1fr,),
191+
gutter: 12pt,
192+
..slice.map(author => align(center, {
193+
text(size: 11pt, author.name)
194+
if "department" in author [
195+
\ #emph(author.department)
196+
]
197+
if "organization" in author [
198+
\ #emph(author.organization)
199+
]
200+
if "location" in author [
201+
\ #author.location
202+
]
203+
if "email" in author {
204+
if type(author.email) == str [
205+
\ #link("mailto:" + author.email)
206+
] else [
207+
\ #author.email
208+
]
209+
}
210+
}))
211+
)
212+
213+
if not is-last {
214+
v(16pt, weak: true)
215+
}
216+
}
217+
}
218+
)
219+
220+
set par(justify: true, first-line-indent: (amount: 1em, all: true), spacing: 0.5em, leading: 0.5em)
221+
222+
// Display abstract and index terms.
223+
if abstract != none {
224+
set par(spacing: 0.45em, leading: 0.45em)
225+
set text(9pt, weight: 700, spacing: 150%)
226+
227+
[_Abstract_---#h(weak: true, 0pt)#abstract]
228+
229+
if index-terms != () {
230+
parbreak()
231+
[_Index Terms_---#h(weak: true, 0pt)#index-terms.join[, ]]
232+
}
233+
v(2pt)
234+
}
235+
236+
// Display the paper's contents.
237+
body
238+
239+
// Display bibliography.
240+
bibliography
241+
}

0 commit comments

Comments
 (0)