Skip to content

Commit d5714ab

Browse files
committed
cellpress-unofficial-0.1.1
1 parent 5e2f541 commit d5714ab

File tree

9 files changed

+396
-0
lines changed

9 files changed

+396
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pdf
2+
*.png
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Permission to use, copy, modify, and/or distribute this software for
2+
any purpose with or without fee is hereby granted.
3+
4+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
5+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
6+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
7+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
8+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
9+
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
10+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Unofficial Cell Press template
2+
3+
An unofficial template for Cell Press research articles.
4+
5+
## Example
6+
7+
See [template/report.typ](template/report.typ).
8+
9+
![Example research article](inc/thumbnail.png)
10+
11+
## Requires Typst v0.14
12+
13+
Since this package relies on table subheaders ([typst/typst#6168](https://github.com/typst/typst/pull/6168)), it requires Typst v0.14+ (or a development version).
14+
15+
## Logo
16+
17+
The copyright of the [logo](inc/cell_press_logo.pdf) is held by Elsevier Inc.
Binary file not shown.
399 KB
Loading
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
// Cell Press template.
2+
3+
// Fonts.
4+
#let font-sans-serif = "Nimbus Sans" // "Helvetica Neue"
5+
6+
// Colours.
7+
#let zebra-gray = rgb(luma(95.25%)) // rgb("#f3f3f3")
8+
#let cellpress-red = rgb("#a93b45") // summary title red, table red
9+
#let cellpress-blue = rgb("#0296d3") // journal blue, summary blue, link blue
10+
#let cellpress-grey = rgb("#b3b3b3") // supertitle grey
11+
12+
// --- [ tables ] --------------------------------------------------------------
13+
14+
#let toprule(color: cellpress-red) = {
15+
table.hline(stroke: 0.7pt + color)
16+
}
17+
18+
#let bottomrule(color: cellpress-red) = {
19+
table.hline(stroke: 0.7pt + color)
20+
}
21+
22+
#let midrule(color: cellpress-red) = {
23+
table.hline(stroke: 0.5pt + color)
24+
}
25+
26+
#let tabsubhdr(content, colspan: 3, color: cellpress-red) = table.header(
27+
level: 2, // sub header
28+
table.cell(
29+
colspan: colspan,
30+
inset: (y: 5pt),
31+
fill: none,
32+
{
33+
// TODO: move styling to `show table.header.where(level: 2)` show-set rule when https://github.com/typst/typst/issues/3640 is resolved.
34+
set text(fill: color)
35+
show text: emph
36+
content
37+
}
38+
)
39+
)
40+
41+
#let style-table(body) = {
42+
// tables
43+
show figure.where(kind: table): set figure.caption(position: top, separator: [. ])
44+
show figure.where(kind: table): set block(breakable: true, above: 14pt, below: 14pt)
45+
show figure.where(kind: table): outer => {
46+
show figure.caption: it => align(
47+
center,
48+
[
49+
#strong[#it.supplement #context it.counter.display(it.numbering)#it.separator]
50+
#it.body
51+
]
52+
)
53+
outer
54+
}
55+
show table: set table(
56+
stroke: none,
57+
align: left,
58+
fill: (_, y) => {
59+
// TODO: remove `y != 0 and` when https://github.com/typst/typst/issues/4159#issuecomment-3124855835 is resolved
60+
if y != 0 and not calc.odd(y) {
61+
zebra-gray
62+
}
63+
},
64+
// TODO: uncomment when https://github.com/typst/typst/issues/4159#issuecomment-3124855835 is resolved is resolved
65+
//inset: (x: 2.5pt, y: 3pt),
66+
// TODO: remove when https://github.com/typst/typst/issues/4159#issuecomment-3124855835 is resolved is resolved
67+
inset: (x, y) => {
68+
let y_pad = 3pt
69+
if y == 0 {
70+
y_pad = 4pt
71+
}
72+
(x: 2.5pt, y: y_pad)
73+
}
74+
)
75+
// table header style.
76+
// TODO: use `show table.header.where(level: 1)` when https://github.com/typst/typst/issues/3640 is resolved.
77+
show table.cell.where(y: 0): it => {
78+
show text: strong
79+
set text(fill: cellpress-red)
80+
// TODO: uncomment when https://github.com/typst/typst/issues/4159#issuecomment-3124855835 is resolved is resolved
81+
//set table.cell(
82+
// inset: (x: 2.5pt, y: 4pt),
83+
// fill: none,
84+
//)
85+
it
86+
}
87+
88+
body
89+
}
90+
91+
// --- [ template ] ------------------------------------------------------------
92+
93+
// summary displays the given summary.
94+
#let summary(body) = {
95+
place(
96+
top,
97+
float: true,
98+
scope: "parent",
99+
)[
100+
#v(2mm)
101+
#heading(level: 1, outlined: false)[Summary]
102+
#set text(font: font-sans-serif, size: 9.9pt, weight: "semibold", fill: cellpress-blue)
103+
#set par(
104+
leading: 0.33em, // adjust line height
105+
)
106+
#block(below: 3mm, body)
107+
]
108+
}
109+
110+
// print-supertitle displays the "super" title (i.e. "Article") on the front
111+
// page.
112+
#let print-supertitle(supertitle) = {
113+
set text(font: font-sans-serif, size: 13.9pt, weight: "extrabold", tracking: -0.1pt, fill: cellpress-grey)
114+
// TODO: skip scale when extrabold exists (using variable fonts: https://github.com/typst/typst/issues/185)
115+
block(scale(origin: left+horizon, x: 110%)[#supertitle])
116+
}
117+
118+
// print-title displays the title of the paper.
119+
#let print-title(title) = {
120+
set text(font: font-sans-serif, size: 20pt, weight: "bold", tracking: -0.5pt)
121+
set par(
122+
justify: false,
123+
leading: 0.33em, // adjust line height
124+
)
125+
block(width: 75%, title)
126+
}
127+
128+
// print-authors displays the list of authors.
129+
#let print-authors(authors) = {
130+
let authors-str = authors
131+
if type(authors) == array {
132+
authors-str = authors.join(", ", last: " and ")
133+
}
134+
set text(font: font-sans-serif, size: 9pt, weight: "semibold")
135+
// TODO: skip scale when semibold exists (using variable fonts: https://github.com/typst/typst/issues/185)
136+
block(scale(origin: left+horizon, x: 97%)[#authors-str])
137+
}
138+
139+
// print-doi displays the doi link.
140+
#let print-doi(doi) = {
141+
set text(font: font-sans-serif, size: 7.9pt)
142+
block(link("https://doi.org/" + doi))
143+
}
144+
145+
// template applies the Cell Press article format to the document.
146+
#let template(
147+
journal: "Neuron", // "Cell Reports"
148+
supertitle: "Article", // "Resource"
149+
title: "Paper Title",
150+
authors: ("John Doe", "Jane Rue"),
151+
doi: none, // 10.1016/j.cell.2006.07.024
152+
date: datetime.today(),
153+
body
154+
) = {
155+
set page(
156+
width: 8.37in,
157+
height: 10.87in,
158+
margin: (
159+
inside: 1.88cm,
160+
outside: 2.1cm,
161+
top: 3.555cm,
162+
),
163+
columns: 2,
164+
header: context {
165+
if calc.odd(here().page()) [
166+
// odd page
167+
#if here().page() == 1 [
168+
// first page
169+
#grid(
170+
columns: (1fr, 1fr),
171+
//rows: 100%,
172+
align: (left, right),
173+
[
174+
#block(text(font: font-sans-serif, size: 24pt, weight: "bold", tracking: -1pt, fill: cellpress-blue)[#journal])
175+
#v(0.57cm)
176+
],
177+
[
178+
#place(top+right, dx: 0.3mm, dy: 1mm)[#image("/inc/cell_press_logo.pdf")]
179+
],
180+
)
181+
#place(
182+
top+right,
183+
dy: 1.475cm,
184+
dx: 2.485cm,
185+
rect(width: 2cm, height: 1.2cm, fill: cellpress-blue),
186+
)
187+
] else [
188+
#grid(
189+
columns: (1fr, 1fr),
190+
align: (left, right),
191+
[
192+
#block(text(font: font-sans-serif, size: 19pt, weight: "bold", tracking: -1pt, fill: cellpress-blue)[#journal])
193+
#v(-2mm)
194+
#block(text(font: font-sans-serif, size: 13.9pt, weight: "bold", fill: cellpress-grey)[#supertitle])
195+
],
196+
[
197+
#place(top+right, dx: 0.3mm, dy: -0.9mm)[#image("/inc/cell_press_logo.pdf")]
198+
],
199+
)
200+
#place(
201+
top+right,
202+
dy: 1.475cm,
203+
dx: 2.485cm,
204+
rect(width: 2cm, height: 1.2cm, fill: cellpress-blue),
205+
)
206+
]
207+
] else [
208+
// even page
209+
#grid(
210+
columns: (1fr, 1fr),
211+
align: (left, right),
212+
[
213+
#place(top+left, dx: -0.3mm, dy: -0.9mm)[#image("/inc/cell_press_logo.pdf")]
214+
],
215+
[
216+
#block(text(font: font-sans-serif, size: 19pt, weight: "bold", tracking: -1pt, fill: cellpress-blue)[#journal])
217+
#v(-2mm)
218+
#block(text(font: font-sans-serif, size: 13.9pt, weight: "bold", fill: cellpress-grey)[#supertitle])
219+
],
220+
)
221+
#place(
222+
top+left,
223+
dy: 1.475cm,
224+
dx: -2.485cm,
225+
rect(width: 2cm, height: 1.2cm, fill: cellpress-blue),
226+
)
227+
]
228+
},
229+
header-ascent: 20%,
230+
)
231+
set par(justify: true)
232+
set text(font: font-sans-serif, size: 8.4pt)
233+
234+
// Set link colour.
235+
show ref: set text(fill: cellpress-blue)
236+
show link: set text(fill: cellpress-blue)
237+
show cite: set text(fill: cellpress-blue)
238+
show footnote: set text(fill: cellpress-blue)
239+
240+
// Style tables.
241+
show: style-table
242+
243+
// Style headings.
244+
show heading.where(level: 1): it => {
245+
set text(font: font-sans-serif, size: 8.4pt, weight: "extrabold", tracking: -0.2pt, fill: cellpress-red)
246+
// TODO: skip scale when extrabold exists (using variable fonts: https://github.com/typst/typst/issues/185)
247+
set block(below: 0.55cm)
248+
scale(origin: left+horizon, x: 110%)[#upper(it)]
249+
}
250+
show heading.where(level: 2): it => {
251+
set text(font: font-sans-serif, size: 8.4pt, weight: "extrabold", tracking: -0.2pt, fill: cellpress-red)
252+
// TODO: skip scale when extrabold exists (using variable fonts: https://github.com/typst/typst/issues/185)
253+
set block(below: 0.55cm)
254+
scale(origin: left+horizon, x: 110%)[#it]
255+
}
256+
257+
// Use Cell citation style.
258+
set bibliography(style: "cell")
259+
260+
// Display title and authors.
261+
place(
262+
top+left,
263+
scope: "parent",
264+
float: true,
265+
)[
266+
#print-supertitle(supertitle)
267+
#v(-6.5mm)
268+
#print-title(title)
269+
#v(-2mm)
270+
#print-authors(authors)
271+
#if doi != none {
272+
print-doi(doi)
273+
}
274+
]
275+
276+
// Display body.
277+
body
278+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@article{takahashi2006induction,
2+
title={Induction of pluripotent stem cells from mouse embryonic and adult fibroblast cultures by defined factors},
3+
author={Takahashi, Kazutoshi and Yamanaka, Shinya},
4+
journal={cell},
5+
volume={126},
6+
number={4},
7+
pages={663--676},
8+
year={2006},
9+
publisher={Elsevier},
10+
doi={10.1016/j.cell.2006.07.024}
11+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#import "@preview/cellpress-unofficial:0.1.1" as cellpress
2+
3+
#show: cellpress.template.with(
4+
journal: "Neuron", // "Cell Reports"
5+
supertitle: "Article", // "Resource"
6+
title: "Paper Title",
7+
authors: ("John Doe", "Jane Rue"),
8+
//doi: "10.1016/j.cell.2006.07.024",
9+
)
10+
11+
// === [ Summary ] =============================================================
12+
13+
#cellpress.summary[
14+
#lorem(30)
15+
]
16+
17+
// === [ Introduction ] ========================================================
18+
19+
= Introduction
20+
21+
#lorem(30) @takahashi2006induction
22+
23+
// === [ Results ] =============================================================
24+
25+
= Results
26+
27+
#lorem(45)
28+
29+
As seen in @tbl-foo ...
30+
31+
#figure(
32+
caption: lorem(5),
33+
table(
34+
columns: 3,
35+
cellpress.toprule(),
36+
table.header[*foo*][*bar*][*baz*],
37+
cellpress.midrule(),
38+
[a], [b], [c],
39+
[a], [b], [c],
40+
[a], [b], [c],
41+
cellpress.bottomrule(),
42+
),
43+
) <tbl-foo>
44+
45+
// === [ Discussion ] ==========================================================
46+
47+
= Discussion
48+
49+
#lorem(25)
50+
51+
// === [ Bibliography ] ========================================================
52+
53+
#bibliography("references.bib")
54+
55+
// === [ Methods ] =============================================================
56+
57+
#set page(columns: 1)
58+
59+
= Methods
60+
61+
#lorem(15)

0 commit comments

Comments
 (0)