Skip to content

Commit

Permalink
ieee-monolith:0.1.0 (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fricsion authored Jan 10, 2025
1 parent 381a966 commit 8582292
Show file tree
Hide file tree
Showing 7 changed files with 420 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/preview/ieee-monolith/0.1.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Taiki M.

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.
26 changes: 26 additions & 0 deletions packages/preview/ieee-monolith/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# IEEE Setup With Single Column

I like IEEE style of references/bibliography.

And I wanted it to be single column instead of two.

Credit: Typst GmbH (I used their template as the base for mine)

## The goal of this template:
- You can just copy-and-paste `main.typ` from your previously-written `ieee-charged` (by Typst Team) document. And it works!
- Additional features are all optional. e.g. global font setting
- Adjust spacings according to the single column setup.


## Usage
This template is suppose be compatible with `charged-ieee` template by Typst Team.

Just replace:
```
#import "@preview/charged-ieee:0.1.3": ieee
```
with:
```
#import "@preview/ieee-monolith:0.1.0": ieee
```
238 changes: 238 additions & 0 deletions packages/preview/ieee-monolith/0.1.0/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
// This function gets your whole document as its `body` and formats
// it as an article in the style of the IEEE.
#let ieee(
// The paper's title.
title: [Paper Title],

// An array of authors. For each author you can specify a name,
// department, organization, location, and email. Everything but
// but the name is optional.
authors: (),

// The paper's abstract. Can be omitted if you don't have one.
abstract: none,

// A list of index terms to display after the abstract.
index-terms: (),

// The article's paper size. Also affects the margins.
paper-size: "us-letter",

// The result of a call to the `bibliography` function or `none`.
bibliography: none,

// How figures are referred to from within the text.
// Use "Figure" instead of "Fig." for computer-related publications.
figure-supplement: [Fig.],

// グローバルのフォント
global-font: "Tex Gyre Termes",

// The paper's content.
body
) = {
// Set document metadata.
set document(title: title, author: authors.map(author => author.name))

// Set the body font.
// As of 2024-08, the IEEE LaTeX template uses wider interword spacing
// - See e.g. the definition \def\@IEEEinterspaceratioM{0.35} in IEEEtran.cls
set text(font: global-font, size: 12pt, spacing: .35em) // size: フォントサイズ指定

// Enums numbering
set enum(numbering: "1)a)i)")

// Tables & figures
show figure: set block(spacing: 25pt) // spacing: 図の表現の上下のスペース
show figure: set place(clearance: 15.5pt)
show figure.where(kind: table): set figure.caption(position: top)
show figure.where(kind: table): set text(size: 10pt)
show figure.where(kind: table): set figure(numbering: "I")
show figure.where(kind: image): set figure(supplement: figure-supplement, numbering: "1")
show figure.caption: set text(size: 10pt) // 画像・図キャプションのフォントサイズ
show figure.caption: set align(start)
show figure.caption.where(kind: table): set align(center)

// Adapt supplement in caption independently from supplement used for
// references.
show figure: fig => {
let prefix = (
if fig.kind == table [TABLE]
else if fig.kind == image [Fig.]
else [#fig.supplement]
)
let numbers = numbering(fig.numbering, ..fig.counter.at(fig.location()))
show figure.caption: it => [#prefix~#numbers: #it.body]
show figure.caption.where(kind: table): smallcaps
fig
}

// Code blocks
show raw: set text(
font: "TeX Gyre Cursor",
ligatures: false,
size: 1em / 0.8,
spacing: 100%,
)

// Configure the page and multi-column properties.
set columns(gutter: 12pt)
set page(
columns: 1,
paper: paper-size,
// The margins depend on the paper size.
margin: if paper-size == "a4" {
(x: 41.5pt, top: 80.51pt, bottom: 89.51pt)
} else {
(
// x: (ここの数字pt / 216mm) * 100% をいじると左右の余白が変わる
x: (75pt / 216mm) * 100%,
top: (55pt / 279mm) * 100%,
bottom: (64pt / 279mm) * 100%,
)
}
)

// Configure equation numbering and spacing.
set math.equation(numbering: "(1)")
show math.equation: set block(spacing: 1.5em) // spacing: 数式ブロックの上下のスペース

// Configure appearance of equation references
show ref: it => {
if it.element != none and it.element.func() == math.equation {
// Override equation references.
link(it.element.location(), numbering(
it.element.numbering,
..counter(math.equation).at(it.element.location())
))
} else {
// Other references as usual.
it
}
}

// Configure lists.
set enum(indent: 10pt, body-indent: 9pt)
set list(indent: 10pt, body-indent: 9pt)

// Configure headings.
set heading(numbering: "I.A.a)")
show heading: it => {
// Find out the final number of the heading counter.
let levels = counter(heading).get()
let deepest = if levels != () {
levels.last()
} else {
1
}

set text(12pt, weight: 400) // ヘディングのフォントサイズを指定
if it.level == 1 {
// First-level headings are centered smallcaps.
// We don't want to number the acknowledgment section.
let is-ack = it.body in ([Acknowledgment], [Acknowledgement], [Acknowledgments], [Acknowledgements])
set align(center)
set text(if is-ack { 13pt } else { 14pt }) // ヘディング1のフォントサイズ指定
show: block.with(above: 15pt, below: 13.75pt, sticky: true)
show: smallcaps
if it.numbering != none and not is-ack {
numbering("I.", deepest)
h(7pt, weak: true)
}
it.body
} else if it.level == 2 {
// Second-level headings are run-ins.
set par(first-line-indent: 0pt)
set text(style: "italic")
show: block.with(spacing: 20pt, sticky: true) // spacing: ヘディングのあとの行間スペース
if it.numbering != none {
numbering("A.", deepest)
h(7pt, weak: true)
}
it.body
} else [
// Third level headings are run-ins too, but different.
#if it.level == 3 {
numbering("a)", deepest)
[ ]
}
_#(it.body):_
]
}

// Style bibliography.
show std.bibliography: set text(9pt) // 参考文献のテキストサイズ
show std.bibliography: set block(spacing: 0.7em)
set std.bibliography(title: text(10pt)[References], style: "ieee")

// Display the paper's title and authors at the top of the page,
// spanning all columns (hence floating at the scope of the
// columns' parent, which is the page).
place(
top,
float: true,
scope: "parent",
clearance: 30pt,
{
v(3pt, weak: true)
align(center, par(leading: 0.5em, text(size: 24pt, title)))
v(8.35mm, weak: true)

// Display the authors list.
set par(leading: 0.6em)
for i in range(calc.ceil(authors.len() / 3)) {
let end = calc.min((i + 1) * 3, authors.len())
let is-last = authors.len() == end
let slice = authors.slice(i * 3, end)
grid(
columns: slice.len() * (1fr,),
gutter: 12pt,
..slice.map(author => align(center, {
text(size: 11pt, author.name)
if "department" in author [
\ #emph(author.department)
]
if "organization" in author [
\ #emph(author.organization)
]
if "location" in author [
\ #author.location
]
if "email" in author {
if type(author.email) == str [
\ #link("mailto:" + author.email)
] else [
\ #author.email
]
}
}))
)

if not is-last {
v(16pt, weak: true)
}
}
}
)

// Configure paragraph properties.
set par(spacing: 1.3em, justify: true, first-line-indent: 1em, leading: 0.6em) // パラグラフの間のスペースをspacing: で編集可能

// Display abstract and index terms.
if abstract != none [
#set text(11pt, weight: 700, spacing: 150%)
#h(1em) _Abstract_---#h(weak: true, 0pt)#abstract

#if index-terms != () [
#h(.3em)_Index Terms_---#h(weak: true, 0pt)#index-terms.join(", ")
]
#v(2pt)
]

// Display the paper's contents.
set par(leading: 1.0em) // leading: の値を変更して行間のスペースを指定
body

// Display bibliography.
bibliography
}
99 changes: 99 additions & 0 deletions packages/preview/ieee-monolith/0.1.0/template/main.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#import "@preview/ieee-monolith:0.1.0": ieee

#show: ieee.with(
title: [A typesetting system to untangle the scientific writing process],
abstract: [
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.
],
authors: (
(
name: "John Smith",
department: [Sample],
organization: [Placeholder],
location: [Somewhere],
email: "[email protected]"
),

),
index-terms: ("Scientific writing", "Typesetting", "Document creation", "Syntax"),
bibliography: bibliography("refs.bib"),

global-font: ("Charter", "Hiragino Kaku Gothic Interface"), // Choose Fonts used globally. For multiple languages, you may want to use more than 2.
)


#outline(indent: true) // Show Table of Contents
#set page(numbering: "1 / 1",) // Add page number at the bottom

// Your content goes below.
= Introduction
Scientific writing is a crucial part of the research process, allowing researchers to share their findings with the wider scientific community. However, the process of typesetting scientific documents can often be a frustrating and time-consuming affair, particularly when using outdated tools such as LaTeX. Despite being over 30 years old, it remains a popular choice for scientific writing due to its power and flexibility. However, it also comes with a steep learning curve, complex syntax, and long compile times, leading to frustration and despair for many researchers @netwok2020 @netwok2022.

== Paper overview
In this paper we introduce Typst, a new typesetting system designed to streamline the scientific writing process and provide researchers with a fast, efficient, and easy-to-use alternative to existing systems. Our goal is to shake up the status quo and offer researchers a better way to approach scientific writing.

By leveraging advanced algorithms and a user-friendly interface, Typst offers several advantages over existing typesetting systems, including faster document creation, simplified syntax, and increased ease-of-use.


= Methods <sec:methods>
#lorem(45)

$ a + b = gamma $ <eq:gamma>

#lorem(80)

#figure(
placement: none,
circle(radius: 15pt),
caption: [A circle representing the Sun.]
) <fig:sun>

In @fig:sun you can see a common representation of the Sun, which is a star that is located at the center of the solar system.

#lorem(120)

#figure(
caption: [The Planets of the Solar System and Their Average Distance from the Sun],
placement: top,
table(
// Table styling is not mandated by the IEEE. Feel free to adjust these
// settings and potentially move them into a set rule.
columns: (6em, auto),
align: (left, right),
inset: (x: 8pt, y: 4pt),
stroke: (x, y) => if y <= 1 { (top: 0.5pt) },
fill: (x, y) => if y > 0 and calc.rem(y, 2) == 0 { rgb("#efefef") },

table.header[Planet][Distance (million km)],
[Mercury], [57.9],
[Venus], [108.2],
[Earth], [149.6],
[Mars], [227.9],
[Jupiter], [778.6],
[Saturn], [1,433.5],
[Uranus], [2,872.5],
[Neptune], [4,495.1],
)
) <tab:planets>

In @tab:planets, you see the planets of the solar system and their average distance from the Sun.
The distances were calculated with @eq:gamma that we presented in @sec:methods.

= Test Block Quote
#lorem(50)

#set quote(block: true)
#quote(attribution: [Random Guy])[
hello, world. this statement makes zero sense. But I hope you like it!
]

= 日本語テスト
これは正常に表示されていますか?

英語と並んでいるときも、ズレずにcorrectly表示されていますか?

hello, world

英語に挟まれているときも、正常に表示されていますか?

goodbye, world
Loading

0 comments on commit 8582292

Please sign in to comment.