Skip to content
Draft
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/pmetrika/0.1.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Samuel Huang

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.
62 changes: 62 additions & 0 deletions packages/preview/pmetrika/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# A Typst Template for _Psychometrika_

Elegant, ergonomic, satisfying, reproducible manuscript preparation for
[_Psychometrika_](https://www.psychometricsociety.org/psychometrika), powered by
[Typst](https://typst.app/home).

## Usage

This template is designed to be as transparent as possible. Just import the
`conf` element, fill in the necessary metadata, and start writing as you
normally do!

```typst
#show: conf.with(
abstract: ...,

Check failure on line 15 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L15

Syntax error in README. expected expression If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.

Check failure on line 15 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L15

Syntax error in README. expected comma If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.

Check failure on line 15 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L15

Syntax error in README. expected expression If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.

Check failure on line 15 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L15

Syntax error in README. expected identifier If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.
title: ...,

Check failure on line 16 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L16

Syntax error in README. expected expression If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.

Check failure on line 16 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L16

Syntax error in README. expected comma If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.

Check failure on line 16 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L16

Syntax error in README. expected expression If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.

Check failure on line 16 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L16

Syntax error in README. expected identifier If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.
authors: (...),

Check failure on line 17 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L17

Syntax error in README. expected expression If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.

Check failure on line 17 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L17

Syntax error in README. expected identifier If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.
keywords: (...)

Check failure on line 18 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L18

Syntax error in README. expected expression If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.

Check failure on line 18 in packages/preview/pmetrika/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/README.md#L18

Syntax error in README. expected identifier If this code block is not supposed to be parsed as a Typst source, please explicitely specify another language.
)

= Your First Section
```

## Advanced Usage

You may also import and reuse some of the definitions, such as:

- `color-heading`
- `color-abstract`
- `font-mono`
- `stroke-table`
- `state-after-bib`
- ...

```typst
text(fill: color-heading)[A sentence with the color of a heading!]
```

When in doubt, read `lib.typ`, it's very straightforward! (Much more so than
most LaTeX packages.)

## Known Issues

- The table header color currently only applies to the first row instead of all
cells wrapped in `table.header`. You will need to import `color-header`
manually for some advanced coloring.
- Caption note via `/ Note: ...` doesn't stick with the figure when
`placement: auto` is set. A workaround for this is described in the
accompanied template file.

## Support

Should you have any questions, feel free to start a discussion. You're also
encouraged to consult the [Typst documentation](https://typst.app/docs).
Questions regarding Typst itself can be asked in Typst
[forum](https://forum.typst.app/) or
[Discord](https://discord.com/invite/2uDybryKPe).

## Contribution

Feel free to create an issue about how this template could be improved. Code
contributions via PRs are always welcomed!
7 changes: 7 additions & 0 deletions packages/preview/pmetrika/0.1.0/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
thumbnail:
cp template/{main.typ,refs.bib} .
sed -i '' '/^#import/s/"[^"]*"/"lib.typ"/' main.typ
curl https://imgs.xkcd.com/comics/data_point.png > data-point.png
typst compile -f png --pages 1 --ppi 250 main.typ thumbnail.png
oxipng -o 4 --strip safe --alpha thumbnail.png
rm main.typ refs.bib data-point.png
150 changes: 150 additions & 0 deletions packages/preview/pmetrika/0.1.0/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// TODO: obtain actual colors programmtically
#let color-heading = rgb("#4086B1")
#let color-abstract = rgb("#E8EEF3") // abstract bg
#let color-header = rgb("#B4C5DA") // table header bg
#let color-body = rgb("#EEF0F4") // table body bg
#let color-link = rgb("#455CA5") // cross references and links
#let color-doi = rgb("#337BCA") // doi in bottom left of pages
#let font-sans = "Source Sans Pro"
#let font-serif = "Minion Pro"
#let font-mono = "Source Code Pro"
#let stroke-table = stroke(0.5pt)
#let state-after-bib = state("after-bib", false)

#let conf(
title: none,
section: none,
abstract: none,
keywords: none,
doc,
) = {
set text(font: font-serif, size: 9.75pt)
show raw: set text(font: font-mono)
show strong: it => text(weight: "light", it) // FIXME: why it has to be light?

set page(
width: 176mm,
height: 250mm,
margin: (x: 0.6in, y: 0.5in),
header: context [
#if counter(page).get().first() > 1 [
_Psychometrika_ Submission
#h(1fr) #counter(page).display()
]
],
)

set bibliography(title: "References", style: "apa")
show bibliography: it => {
set text(size: 8pt)
it
// headings after bib are treated as appendices
state-after-bib.update(true)
counter(heading).update(0)
}

show heading: set text(
font: font-sans,
size: 9.5pt,
fill: color-heading,
weight: "semibold",
)
show heading: set block(below: 4pt)
show heading.where(level: 2): set text(style: "italic")
show heading.where(level: 3): set text(style: "italic", weight: "regular")
set heading(numbering: (..nums) => {
if state-after-bib.get() {
[Appendix #numbering("A.1.", ..nums)]
} else {
numbering("1.", ..nums)
}
})

set table(
// TODO: cell spanning a whole row should have no strokes
// TODO: rows sharing a spanned first cell should have no strokes
// TODO: spanned cells in header should have "padding" for strokes
stroke: (_, y) => (y: 0.5pt),
// FIXME: header spanning multiple rows should be colored correctly
fill: (_, y) => { if y == 0 { color-header } else { color-body } },
)
show table.cell: it => {
set text(font: font-sans, size: 7.75pt)
it
}
// HACK: work around for header fill, only works in v0.14.0
// FIXME: this somehow doesn't always work
show table.header: it => {
set table.cell(fill: color-header)
it
}
show table: it => {
set table.cell(fill: color-body)
it
}
set table.hline(stroke: stroke-table)

show figure: set text(font: font-sans, size: 7.75pt)
show figure.where(kind: table): set figure.caption(position: top)
show figure.caption: it => {
set align(left)
[
*#it.supplement #context it.counter.display(it.numbering).*
#sym.space
#it.body
]
}

// if a term list has only one term and it's called Note, it will be treated
// as a figure note
// TODO: only if the term list is after a figure
// TODO: pass note to #figure, see https://github.com/typst/typst/issues/7220
show terms: it => {
let terms = it.children
if terms.len() == 1 {
let it = terms.first()
if it.term.at("text", default: none) == "Note" {
set align(left)
set text(font: font-sans, size: 7.75pt)
set block(above: 7.75pt)
block[#emph(it.term): #it.description]
return
}
}
it
}

show link: set text(fill: color-link)


// content

if section != none {
set text(size: 8.5pt, font: font-sans, tracking: 1.1pt, fill: color-heading)
upper(section)
parbreak()
}

if title != none {
set text(size: 16pt, font: font-sans, fill: color-heading)
[*#title*]
}

if abstract != none {
set text(size: 9pt)
block(fill: color-abstract, inset: 9pt)[
#text(font: font-sans, tracking: -0.02pt)[*Abstract*]
#parbreak()
#abstract
]
}

if keywords != none {
set text(size: 8pt)
text(tracking: -0.17pt)[*Keywords:*]
sym.space
keywords.join("; ")
}

doc
}
86 changes: 86 additions & 0 deletions packages/preview/pmetrika/0.1.0/template/main.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#import "@preview/pmetrika:0.1.0": conf

#show: conf.with(
// These arguments are optional, but you likely need all of them in a paper.
title: [A Typst Template for _Psychometrika_],
abstract: lorem(20),
section: "application and case studies - original",
keywords: ("Typst", [_Psychometrika_], "typesetting"),
)

// NOTE: Some of the files referenced in this template are not included in distribution,
// this file won't compile before you replace/remove them!

= Start Writing as You Normally Would!

And they will be styled by the template automatically.

== Headings Are in Psychometrika Style

#grid(
columns: (1fr, 1fr),
[
#figure(
image("data-point.png", width: 80%),

Check failure on line 24 in packages/preview/pmetrika/0.1.0/template/main.typ

View check run for this annotation

Typst package check / @preview/pmetrika:0.1.0

packages/preview/pmetrika/0.1.0/template/main.typ#L24

The following error was reported by the Typst compiler: file not found (searched at packages/preview/pmetrika/0.1.0/template/data-point.png)
caption: [XKCD Comic: When one of your data points is really cool, devote a
whole figure to it. @data-point],
)
],
[
// A workaround to make sure the Note sticks together with the figure with
// auto placement
#place(
auto,
float: true,
block(breakable: false)[
#figure(
table(
columns: 5,
table.header(
[Oct 2025],
[Oct 2024],
[Programming Language],
[Ratings],
[Change],
),
[1], [1], [Python], [24.45%], [+2.55%],
[2], [4], [C], [9.29%], [+0.91%],
[3], [2], [C++], [8.84%], [-2.77%],
[4], [3], [Java], [8.35%], [-2.15%],
[5], [5], [C\#], [6.94%], [+1.32%],
),
caption: [Most popular languages in October 2025: the fierce battle for
second place in TIOBE Index],
)

/ Note: Term lists with a single term named `Note` will be treated as a figure
note.

$ H(X) = -sum_(i=1)^n p(x_i) log_2 p(x_i) $
],
)
],
)

= Advanced Styling

You may want to import some of the predefined style elements:

#import "@preview/pmetrika:0.1.0": color-heading

```typst
#import "@preview/pmetrika:0.1.0": color-heading
#text(fill: color-heading)[word]
```

So that you can have a #text(fill: color-heading)[word] colored like a heading!

When in doublt, consult the
#link("https://github.com/sghng/pmetrika/blob/main/lib.typ")[source code] to
see how things work.

#bibliography("refs.bib") // pass actual path to your bib!

= Sections After Bib Are Treated as Appendices

#lorem(64)
6 changes: 6 additions & 0 deletions packages/preview/pmetrika/0.1.0/template/refs.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@online{data-point,
title = {Data Point},
author = {Randall Munroe},
url = {https://xkcd.com/2713/},
organization = {xkcd},
}
Binary file added packages/preview/pmetrika/0.1.0/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions packages/preview/pmetrika/0.1.0/typst.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "pmetrika"
version = "0.1.0"
entrypoint = "lib.typ"
authors = ["Samuel Huang"]
license = "MIT"
description = "A template for the Psychometrika journal."
repository = "https://github.com/sghng/pmetrika"
keywords = [
"journal",
"psychology",
"psychometrika",
"psychometrics",
"quantitative",
"statistics",
]
disciplines = ["psychology", "mathematics"]
categories = ["paper"]

[template]
path = "template"
entrypoint = "main.typ"
thumbnail = "thumbnail.png"