Skip to content
Merged
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
21 changes: 21 additions & 0 deletions packages/preview/elsearticle/1.1.1/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Mathieu Aucejo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
72 changes: 72 additions & 0 deletions packages/preview/elsearticle/1.1.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# elsearticle template

[![Generic badge](https://img.shields.io/badge/Version-1.1.1-cornflowerblue.svg)]()
[![MIT License](https://img.shields.io/badge/License-MIT-forestgreen)](https://github.com/maucejo/elsearticle/blob/main/LICENSE)
[![User Manual](https://img.shields.io/badge/doc-.pdf-mediumpurple)](https://github.com/maucejo/elsearticle/blob/main/docs/manual.pdf)

`elsearticle` is a Typst template that aims to mimic the Elsevier article LaTeX class, a.k.a. `elsarticle.cls`, provided by Elsevier to format manuscript properly for submission to their journals.

## Basic usage

This section provides the minimal amount of information to get started with the template. For more detailed information, see the [manual](https://github.com/maucejo/elsearticle/blob/main/docs/manual.pdf).

To use the `elsearticle` template, you need to include the following line at the beginning of your `typ` file:

```typ
#import "@preview/elsearticle:1.1.1": *
```

### Initializing the template

After importing `elsearticle`, you have to initialize the template by a show rule with the `#elsearticle()` command. This function takes an optional argument to specify the title of the document.

* `title`: Title of the paper
* `author`: List of the authors of the paper
* `abstract`: Abstract of the paper
* `journal`: Name of the journal
* `keywords`: List of keywords of the paper
* `format`: Format of the paper. Possible values are `preprint`, `review`, `1p`, `3p`, `5p`
* `numcol`: Number of columns of the paper. Possible values are 1 and 2
* `line-numbering`: Enable line numbering. Possible values are `true` and `false`

## Additional features

The `elsearticle` template provides additional features to help you format your document properly.

### Appendix

To activate the appendix environment, all you have to do is to place the following command in your document:
```typ
#show: appendix

// Appendix content here
```

### Subfigures

Subfigures are not built-in features of Typst, but the `elsearticle` template provides a way to handle them. It is based on the `subpar` package that allows you to create subfigures and properly reference them.

```typ
#subfigure(
figure(image("image1.png"), caption: []), <figa>,
figure(image("image2.png"), caption: []), <figb>,
columns: (1fr, 1fr),
caption: [(a) Left image and (b) Right image],
label: <fig>
)
```

### Equations

The `elsearticle` template provides the `#nonumeq()` function to create unnmbered equations. The latter function can be used as follows:
```typ
#nonumeq[$
y = f(x)
$
]
```

# License
MIT licensed

Copyright (C) 2025 Mathieu AUCEJO (maucejo)
27 changes: 27 additions & 0 deletions packages/preview/elsearticle/1.1.1/src/els-environment.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#import "els-globals.typ": *

// Appendix
#let appendix(body) = {
set heading(numbering: "A.1.", supplement: [Appendix])
// Reset heading counter
counter(heading).update(0)

// Equation numbering
let numbering-eq = (..n) => {
let h1 = counter(heading).get().first()
numbering("(A.1a)", h1, ..n)
}
set math.equation(numbering: numbering-eq)

// Figure and Table numbering
let numbering-fig = n => {
let h1 = counter(heading).get().first()
numbering("A.1", h1, n)
}
show figure.where(kind: image): set figure(numbering: numbering-fig)
show figure.where(kind: table): set figure(numbering: numbering-fig)

isappendix.update(true)

body
}
73 changes: 73 additions & 0 deletions packages/preview/elsearticle/1.1.1/src/els-globals.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#let textfont = ("XITS", "STIX Two Text", "New Computer Modern")
#let mathfont = ("XITS Math", "STIX Two Math", "New Computer Modern Math")

#let font-size = (
script: 7pt,
footnote: 8pt,
small: 10pt,
normal: 12pt,
author: 12pt,
title: 17.2pt,
)

#let review = (
indent: 1.5em,
paper: "us-letter",
type: "review",
margins: (left: 39.7mm, right: 39.7mm, top: 39.7mm, bottom: 39.7mm),
leading: 1.1em,
above: 1.6em,
below: 1.3em,
spacing: 2em,
footer-descent: 20%
)

#let preprint = (
indent: 1.5em,
paper: "us-letter",
type: "preprint",
margins: (left: 39.7mm, right: 39.7mm, top: 43.7mm, bottom: 61.5mm),
leading: 0.5em,
above: 1.4em,
below: 0.85em,
spacing: 1.75em,
footer-descent: 20%
)

#let one-p = (
indent: 1.5em,
paper: "a4",
type: "1p",
margins: (left: 37.5mm, right: 37.5mm, top: 45.2mm, bottom: 47.9mm),
leading: 0.5em,
above: 1.4em,
below: 0.85em,
spacing: 1.75em,
footer-descent: 5%
)

#let three-p = (
indent: 1.5em,
paper: "a4",
type: "3p",
margins: (left: 22.8mm, right: 22.8mm, top: 38.8mm, bottom: 38.3mm),
leading: 0.5em,
above: 1.4em,
below: 0.85em,
spacing: 1.75em,
footer-descent: 8%
)

#let five-p = (
indent: 1.24em,
paper: "a4",
type: "5p",
margins: (left: 12.9mm, right: 12.9mm, top: 80pt, bottom: 80pt),
leading: 0.5em,
above: 1.25em,
below: 0.85em,
spacing: 1.5em,
footer-descent: 10%
)

#let isappendix = state("isappendix", false)
97 changes: 97 additions & 0 deletions packages/preview/elsearticle/1.1.1/src/els-template-info.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#import "els-globals.typ": *
#import "els-utils.typ": *

#let default-author = (
name: none,
affiliation: none,
corr: none,
id: "a"
)

#let template-info(title, abstract, authors, keywords, els-columns, els-format) = {
// Set authors and affiliation
let names = ()
let names-meta = ()
let affiliations = ()
let coord = none
for author in authors {
let new-author = default-author + author
let auth = (box(new-author.name), super(new-author.id))
if new-author.corr != none {
if els-columns == 1 {
coord = ("Corresponding author. E-mail address: ", new-author.corr).join()
} else {
coord = ([Corresponding author. #linebreak() #h(1.4em) E-mail address: ], new-author.corr).join()
}

if new-author.id != none {
auth.push(super((",", text(baseline: -1.5pt, "*")).join()))
} else {
auth.push(super(text(baseline: -1.5pt, "*")))
}
}
names.push(box(auth.join()))
names-meta.push(new-author.name)

if new-author.affiliation == none {
continue
}
else {
affiliations.push((super(new-author.id), new-author.affiliation, linebreak()).join())
}
}

let author-string = if authors.len() == 2 {
names.join(" and ")
} else {
names.join(", ", last: " and ")
}

// Format title and affiliation
let els-authors = align(center, {
par(leading: 0.95em, text(size: font-size.title, title))
v(0.9em)
text(size: font-size.author, author-string)
v(0.2em)
par(leading: 0.65em, text(size: font-size.small, emph(affiliations.join()), top-edge: 0.5em))
v(1.75em)
})

// Format the abstract
let els-abstract = if abstract != none {
set par(justify: true)
line(length: 100%, stroke: 0.5pt)
v(-0.25em)
text(weight: "bold")[Abstract]
if els-format.type.contains("review") {v(0.5em)} else {v(-0.2em)}
abstract
if els-format.type.contains("review") {linebreak()} else {v(0em)}
if keywords != () {
let kw = ()
for keyword in keywords{
kw.push(keyword)
}

let kw-string = if kw.len() > 1 {
kw.join(", ")
} else {
kw.first()
}
text((emph("Keywords: "), kw-string).join())
}
v(-0.2em)
line(length: 100%, stroke: 0.5pt)
if els-format.type.contains("review") {v(-0.75em)}
else if els-format.type.contains("5p") {v(-0.25em)}
else {none}
}

let els-info = (
els-authors: els-authors,
els-abstract: els-abstract,
coord: coord,
els-meta: names-meta
)

return els-info
}
22 changes: 22 additions & 0 deletions packages/preview/elsearticle/1.1.1/src/els-utils.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#import "els-globals.typ": *
#import "@preview/subpar:0.2.2"

// Subfigures
#let subfigure = {
subpar.grid.with(
numbering: n => if isappendix.get() {numbering("A.1", counter(heading).get().first(), n)
} else {
numbering("1", n)
},
numbering-sub-ref: (m, n) => if isappendix.get() {numbering("A.1a", counter(heading).get().first(), m, n)
} else {
numbering("1a", m, n)
}
)
}

// Equations
#let nonumeq(body) = {
set math.equation(numbering: none)
body
}
Loading