Skip to content

Commit 7392bf5

Browse files
committed
Add typst-mla-template
1 parent 7b7732f commit 7392bf5

File tree

6 files changed

+223
-0
lines changed

6 files changed

+223
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 wych(witch)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# typst-mla-template
2+
A typst template for use in MLA formats.
3+
4+
## Usage
5+
6+
### Method 1: Using typst init (Recommended)
7+
8+
Initialize a new project using this template:
9+
10+
```bash
11+
typst init @preview/mla-template
12+
```
13+
14+
Or specify a custom directory name:
15+
16+
```bash
17+
typst init @preview/mla-template my-paper
18+
```
19+
20+
### Method 2: Manual import
21+
22+
Import the template in your Typst document:
23+
24+
```typst
25+
#import "@preview/typst-mla-template:0.1.0": *
26+
27+
#show: mla.with(
28+
title: "Your Paper Title",
29+
author: "Your Name",
30+
professor: "Professor Name",
31+
course: "Course Name",
32+
date: datetime.today(),
33+
)
34+
35+
// Your content here
36+
```
37+
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#let mla(
2+
title: "Paper Title",
3+
author: none,
4+
professor: none,
5+
date: none,
6+
course: none,
7+
bibliography-file: none,
8+
body
9+
) = {
10+
// Set document metdata.
11+
set document(
12+
title: title,
13+
author: author.firstname + " " + author.lastname
14+
)
15+
16+
// Configure the page.
17+
set page(
18+
paper: "us-letter",
19+
header: align(
20+
right + horizon,
21+
[
22+
#v(0.5in)
23+
#author.lastname
24+
#context(counter(page).display("1"))
25+
]
26+
),
27+
margin: 1in
28+
)
29+
30+
// Set paragraph properties.
31+
set par(
32+
first-line-indent: 0.5in,
33+
justify: false,
34+
leading: 2em
35+
)
36+
set par(
37+
spacing: 2em
38+
)
39+
40+
// Set the body font.
41+
set text(
42+
font: "Liberation Serif",
43+
size: 12pt,
44+
)
45+
46+
// Configure headings.
47+
set heading(numbering: "1.1.a.")
48+
show heading: set block(spacing: 2em)
49+
show heading: it => {
50+
set text(size: 12pt)
51+
set par(first-line-indent: 0in)
52+
53+
// Create the heading numbering.
54+
let number = if it.numbering != none {
55+
counter(heading).display(it.numbering)
56+
h(6pt, weak: true)
57+
}
58+
59+
// Don't number the conclusion
60+
let is-conclusion = it.body in ([conclusion], [Conclusion], [CONCLUSION])
61+
v(2em)
62+
if it.level == 1 and is-conclusion == true {
63+
block[#text(weight: "bold")[#it.body]]
64+
} else if it.level == 1 and is-conclusion == false {
65+
block[#text(weight: "bold")[#number #it.body]]
66+
} else if it.level == 2 {
67+
block[#text(weight: "semibold")[#number #it.body]]
68+
} else if it.level == 3 {
69+
block[#text(weight: "medium")[#number #it.body]]
70+
}
71+
v(2em)
72+
}
73+
74+
// configure block quotes
75+
set quote(block: true)
76+
show quote: set pad(left: 0.5in)
77+
show quote: set block(spacing: 2em)
78+
79+
// configure tables
80+
show figure.where(kind: table): it => {
81+
set block(spacing: 1em)
82+
set par(
83+
first-line-indent: 0in,
84+
leading: 1em
85+
)
86+
set table(stroke: none, align: center, row-gutter: 1em)
87+
strong([Table #it.counter.display(it.numbering) #linebreak()])
88+
it.caption.body
89+
it.body
90+
it.supplement
91+
}
92+
93+
// configure illustrations
94+
show figure.where(kind: image): it => {
95+
set block(spacing: 1em)
96+
set par(
97+
first-line-indent: 0in,
98+
leading: 1em
99+
)
100+
it.body
101+
align(
102+
center,
103+
[Fig. #it.counter.display(it.numbering)\. #it.caption.body]
104+
)
105+
106+
}
107+
108+
// MLA boilerplate
109+
align(left,
110+
stack(
111+
dir:ttb,
112+
spacing: 2em,
113+
[#author.firstname #author.lastname],
114+
..if professor != none { (professor,) } else { () },
115+
course,
116+
date
117+
)
118+
)
119+
120+
// Display the paper's title.
121+
align(center, title)
122+
123+
// Display the paper's contents.
124+
body
125+
126+
// Display the bibliography, if any is given.
127+
if bibliography-file != none {
128+
pagebreak()
129+
align(center, "Works Cited")
130+
show bibliography: set par(
131+
first-line-indent: 0in,
132+
hanging-indent: 0.5in
133+
)
134+
bibliography(
135+
bibliography-file, title:none, style: "mla"
136+
)
137+
}
138+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#import "@preview/mla-template:0.1.0":*
2+
#show: mla.with(
3+
title: "",
4+
author: (
5+
firstname: "",
6+
lastname: ""
7+
),
8+
professor:none,
9+
course:[],
10+
date: [],
11+
bibliography-file: none,
12+
)
552 KB
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "mla-template"
3+
version = "0.1.0"
4+
entrypoint = "template.typ"
5+
authors = ["Dzming Li <i@dzmingli>"]
6+
license = "MIT"
7+
categories = ["paper", "report"]
8+
repository = "https://nest.pijul.com/DzmingLi/typst-mla-template"
9+
description = "Template for MLA formats"
10+
keywords = ["MLA"]
11+
12+
[template]
13+
path = "template"
14+
entrypoint = "main.typ"
15+
thumbnail = "thumbnail.png"

0 commit comments

Comments
 (0)