Skip to content

Commit

Permalink
rubber-article:0.3.1 (#1793)
Browse files Browse the repository at this point in the history
  • Loading branch information
npikall authored Feb 21, 2025
1 parent e31ecb6 commit a8ec931
Show file tree
Hide file tree
Showing 7 changed files with 445 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/preview/rubber-article/0.3.1/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# [v0.3.1](https://github.com/npikall/rubber-article/releases/tag/v0.3.1)
New Feature:
- new function to only format the appendix

# [v0.3.0](https://github.com/npikall/rubber-article/releases/tag/v0.3.0)
New Features:
- integrated bibliography
- better handling of the figure captions
- chapterwise numbering of equations
- headers have been updated
- an appendix can be added

# [v0.2.0](https://github.com/npikall/rubber-article/releases/tag/v0.2.0)
Added some more funcitonality to the package.
- Headers are now integrated, useing hydra.
- List indentation are now set to 1.5em.

# [v0.1.0](https://github.com/npikall/rubber-article/releases/tag/v0.1.0)
Initial Release
24 changes: 24 additions & 0 deletions packages/preview/rubber-article/0.3.1/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

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 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.

For more information, please refer to <http://unlicense.org/>
37 changes: 37 additions & 0 deletions packages/preview/rubber-article/0.3.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# The `rubber-article` Package
<div align="center">Version 0.3.1</div>

This template is a intended as a starting point for creating documents, which should have the classic LaTeX Article look.

## Getting Started

These instructions will get you a copy of the project up and running on the typst web app. Perhaps a short code example on importing the package and a very simple teaser usage.

```typ
#import "@preview/rubber-article:0.3.1": *
#show: article.with()
#maketitle(
title: "The Title of the Paper",
authors: ("Authors Name",),
date: "September 2024",
)
```

## Further Functionality
The template provides a few more functions to customize the document.
For an indepth look into the functionality checkout the [guide].

```typ
#show article.with(
lang:"de",
eq-numbering:none,
text-size:10pt,
page-numbering: "1",
page-numbering-align: center,
heading-numbering: "1.1 ",
)
```

[guide]: https://github.com/npikall/rubber-article/tree/main/docs/docs.pdf
283 changes: 283 additions & 0 deletions packages/preview/rubber-article/0.3.1/src/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
#import "@preview/hydra:0.6.0": hydra

// Workaround for the lack of `std` scope
#let std-bibliography = bibliography


/// A Template recreating the look of the classic Article Class.
/// -> content
#let article(
/// Set the language of the document.
/// -> str
lang: "de",
/// Set the equation numbering style.
/// -> str | none
eq-numbering: none,
/// Chapterwise numbering of equations.
/// -> bool
eq-chapterwise: false,
/// Set the text size.
/// Headings are adjusted automatically.
/// -> length
text-size: 10pt,
/// Set the page numbering style.
/// -> none | str | function
page-numbering: "1",
/// Set the page numbering alignment.
/// -> alignment
page-numbering-align: center,
/// Set the heading numbering style.
/// -> none | str | function
heading-numbering: "1.1",
/// Set the margins of the document.
/// -> auto | relative | dictionary
margins: (left: 25mm, right: 25mm, top: 30mm, bottom: 30mm),
/// Set the Enum indentation.
/// -> length
enum-indent: 1.5em,
/// Set the List indentation.
/// -> length
list-indent: 1.5em,
/// Set if the default header should be used.
/// -> bool
show-header: false,
/// Set if the default header should be alternating.
/// -> bool
alternating-header: true,
/// Set the first page of the header.
/// -> int | float
first-page-header: 1,
/// Set the Header Titel
/// -> str | content
header-titel: none,
/// Set if document should be justified.
/// -> bool
justify: true,
/// Add an appendix to the document.
/// -> content
appendix: none,
/// Set the appendix numbering style.
/// -> none | str | function
appendix-numbering: "A.1",
/// Add a bibliography to the document.
/// -> content
bibliography: none,
/// Set the title of the bibliography.
/// -> str | content
bib-titel: "Bibliography",
/// Set the width of the figure captions.
/// -> relative
fig-caption-width: 75%,
///-> content
content,
) = {
// Set the document's basic properties.
set page(
margin: margins,
numbering: page-numbering,
number-align: page-numbering-align,
)
set text(font: "New Computer Modern", lang: lang, size: text-size)

// Set the equation numbering style.

let chapterwise-numbering = (..num) => numbering(eq-numbering, counter(heading).get().first(), num.pos().first())

let reset-eq-counter = it => {
counter(math.equation).update(0)
it
}
show heading.where(level: 1): if eq-chapterwise {reset-eq-counter} else {it => it}

set math.equation(numbering: eq-numbering) if not eq-chapterwise
set math.equation(numbering: chapterwise-numbering) if eq-chapterwise

set heading(numbering: heading-numbering)
set enum(indent: enum-indent)
set list(indent: list-indent)
show outline.entry.where(level:1): {
it => link(
it.element.location(),
it.indented(strong(it.prefix()), strong((it.body()) + h(1fr) + it.page()),
gap:0.5em),
)
}

set std-bibliography(style: "ieee", title: bib-titel)

// Referencing Figures

show figure.where(kind: table): set figure(supplement: [Tab.], numbering: "1") if lang == "de"
show figure.where(kind: image): set figure(supplement: [Abb.], numbering: "1", ) if lang == "de"

show figure.where(kind: table): set figure.caption(position: top)

// Set Table style

set table(
stroke: none,
gutter: auto,
fill: none,
inset: (right: 1.5em),
)


show figure.caption: it => {
set par(justify: true)
let prefix = {
it.supplement + " " + context it.counter.display(it.numbering)+ ": "
}
let cap = {
strong(prefix)
it.body
}
block(width: fig-caption-width, cap)
}

// Configure the header.

let header-oddPage = context {
set text(10pt)
set grid.hline(stroke: 0.9pt)
grid(
columns: (1fr, 1fr),
align: (left, right),
inset:4pt,
smallcaps(header-titel),
smallcaps(hydra(1)),
grid.hline(),
)
}

let header-evenPage = context {
set text(10pt)
set grid.hline(stroke: 0.9pt)
grid(
columns: (1fr, 1fr),
align: (left, right),
inset:4pt,
smallcaps(hydra(1)),
smallcaps(header-titel),
grid.hline(),
)
}

let header-content = context {
let current = counter(page).get().first()

if current > first-page-header and calc.rem(current,2) == 0{
return header-evenPage
} else if current > first-page-header {
if alternating-header {
return header-oddPage
} else {
return header-evenPage
}
}
}

set page(header: header-content) if show-header

// Main body.

set par(justify: justify)

content

if bibliography != none {
pagebreak(weak: true)
bibliography
}

if appendix != none {
context counter(heading).update(0)
set heading(numbering: appendix-numbering)
appendix
}
}

/// Make the title of the document.
/// -> content
#let maketitle(
/// The title of the document.
/// -> string | content
title: "",
/// The authors of the document.
/// -> array
authors: (),
/// The date of the document.
/// -> string | content | datetime
date: none,
/// Use titel and author information for
/// the document metadata.
/// -> bool
metadata: true,
) = {
if metadata {
set document(author: authors, title: title)
}
// Author information.

let authors-text = {
set text(size: 1.1em)
pad(
top: 0.5em,
bottom: 0.5em,
x: 2em,
grid(
columns: (1fr,) * calc.min(3, authors.len()),
gutter: 1em,
..authors.map(author => align(center, author)),
),
)}
// Frontmatter

align(center)[
#v(60pt)
#block(text(weight: 400, 18pt, title))
#v(1em, weak: true)
#authors-text
#v(1em, weak: true)
#block(text(weight: 400, 1.1em, date))
#v(20pt)
]
}

/// Function to format the Appendix
/// -> content
#let appendix(
/// The numbering of the Appendix
/// -> none | str | function
numbering:"A.1",
/// The title of the Appendix
/// -> none | str | content
title: none,
/// The alignment of the title
/// -> alignment
title-align: center,
/// The size of the title
/// -> length
title-size: none,
/// Startting the appendex after this number
/// -> int
numbering-start:0,
content
) = {
context counter(heading).update(numbering-start)
set heading(numbering: numbering)

// Optional Title
if title != none {
show heading.where(level:1, numbering:none): it => {
if title-size != none {
set text(size: title-size)
it
} else {
it
}
}
let title-text = heading(numbering: none, level: 1, title)
align(title-align, title-text)
}
content
}
Loading

0 comments on commit a8ec931

Please sign in to comment.