Skip to content

Commit 435ff18

Browse files
authored
ytableausp:0.1.0 (#3177)
1 parent 574b9ea commit 435ff18

File tree

9 files changed

+176
-0
lines changed

9 files changed

+176
-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) 2025 Riley
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: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# ytableausp
2+
3+
## What is this package?
4+
This package enables you to make many variety of Young Tableaux like this.
5+
6+
![The result of the various Young Tableaux.](images/example1.png)
7+
8+
If you make a document of the representation theory in Typst, this package may be your friend.
9+
10+
## How to import.
11+
To import this package, you need only to write the following in your typst document.
12+
13+
```typst
14+
#import "@preview/ytableausp:0.1.0": *
15+
```
16+
17+
## How to use.
18+
There are 3 steps to make your basic tableau. \
19+
First, you have better to set your shape.
20+
21+
```typst
22+
#let my-tableau-1 = (
23+
(1,3,5,6),
24+
(2,4),
25+
(7,),
26+
(8,)
27+
)
28+
```
29+
30+
Note that, by the specification of typst, you need to type the list which has only one element as `(7,)`, not `(7)`.\
31+
Second, you need to use `ytableausp` funcion as follows.
32+
33+
```typst
34+
#ytableausp(
35+
shape: my-tableu-1,
36+
cellsize: 1em,
37+
fontsize: 0.8em
38+
)
39+
```
40+
41+
Finally, you can check your tableau displayed correctly.
42+
43+
![The example tableau.](images/example2.png)
44+
45+
Actually, it is not nessecary for you to set the command as first step. It can go well that you set nested list directly into `ytableausp` function correctly. However, the above step is easy to check what shape your tableau forms.
46+
47+
## More settings.
48+
You can set the cell or font size of your tableau freely. And you can insert your tableau into sentences.
49+
50+
![You can insert tableaux into passages.](images/example3.png)
51+
52+
And the element of the nested list which corresponding to each cell has three parameter, letter, border color, filled color. i.e. If you type this,
53+
54+
```typst
55+
#let my-colored-tableau = (
56+
((none, black, none), (none, black, none), (6, yellow, red)),
57+
((none, black, none), (4, black, red)),
58+
((5,yellow, red),)
59+
)
60+
61+
This is colored tableau... #ytableausp(shape: my-colored-tableau, cellsize: 2em, fontsize: 1.8em) So special!
62+
```
63+
64+
then your tableau is the following.
65+
66+
![You can color the tableau.](images/example4.png)
67+
68+
If you type `none` in the second, the border of its cell vanishes.
69+
70+
```typst
71+
#let mytableau = (
72+
((1,black, none), ($dots.c$, none, none), ($n$, black, none)),
73+
(($dots.v$, none, none),),
74+
(($m$, black, none),)
75+
)
76+
77+
#ytableausp(
78+
shape: mytableau,
79+
cellsize: 2em,
80+
fontsize: 1.8em,
81+
)
82+
```
83+
84+
![you can vanish some cells.](images/example5.png)
14.1 KB
Loading
3.8 KB
Loading
37.8 KB
Loading
11 KB
Loading
3.21 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "ytableausp"
3+
version = "0.1.0"
4+
entrypoint = "ytableausp.typ"
5+
exclude = ["images"]
6+
authors = ["Riley"]
7+
license = "MIT"
8+
repository = "https://github.com/Riley719/ytableausp"
9+
description = "You can make Young Tableaux."
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#import table: cell
2+
#let ytableausp(
3+
shape: ((1,2,3), (4,5), (6,)),
4+
cellsize: 1.1em,
5+
fontsize: 0.7em,
6+
) = {
7+
let tableaucells = calc.max(shape.len(), shape.at(0).len())
8+
let cells = ()
9+
let columnsize = ()
10+
let rowsize = ()
11+
let i = 0
12+
13+
while i < shape.at(0).len() {
14+
columnsize.push(cellsize)
15+
i += 1
16+
}
17+
i = 0
18+
while i < shape.len() {
19+
rowsize.push(cellsize)
20+
i += 1
21+
}
22+
23+
for (y, row-length) in shape.enumerate() {
24+
let x = 0
25+
while x < shape.at(0).len() {
26+
if x < shape.at(y).len() {
27+
if type(shape.at(y).at(x)) == int {
28+
cells.push(
29+
cell(x: x,
30+
y: y
31+
)[#text(size: fontsize)[#shape.at(y).at(x)]],
32+
)
33+
} else {
34+
cells.push(
35+
cell(x: x,
36+
y: y,
37+
stroke: shape.at(y).at(x).at(1),
38+
fill: shape.at(y).at(x).at(2)
39+
)[#shape.at(y).at(x).at(0)],
40+
)
41+
}
42+
} else {
43+
cells.push(
44+
cell(x: x,
45+
y: y,
46+
stroke: none
47+
)[],
48+
)
49+
}
50+
x += 1
51+
}
52+
}
53+
box(
54+
baseline: 50% - 0.5em,
55+
table(
56+
columns: columnsize,
57+
rows: rowsize,
58+
align: center + horizon,
59+
..cells
60+
)
61+
)
62+
}

0 commit comments

Comments
 (0)