Compare commits

...

8 Commits

9 changed files with 707 additions and 285 deletions

View File

@@ -0,0 +1,39 @@
---
name: commit-messages
description: >-
Write short git commit messages, preferably under 20 words. Use when drafting
commits, writing commit messages, amending commits, or creating pull request
titles and summaries.
---
# Commit Messages
Keep commit messages **short**. Prefer **under 20 words** total.
## Rules
1. **One line** — subject only; no body unless the user asks for one.
2. **Imperative mood** — "Add table", not "Added table" or "Adds table".
3. **Say what changed** — lead with the action; drop filler ("this commit", "in order to").
4. **No lists** — one change per commit when possible; if many changes, summarize the main one.
5. **Count words** before committing; trim if over 20.
## Format
```
<verb> <what> [<optional context>]
```
Optional conventional prefix when it helps: `feat:`, `fix:`, `refactor:`, `docs:`.
## Examples
| Bad (too long) | Good |
|---|---|
| Add structured tables for test conditions and ink formula in product test template. | Add horizontal ink formula table |
| Refactor templates for consistency and clarity across travel and product test reports. | Align product test header with travel template |
| Update README to reflect new templates and usage examples for both report types. | Update README with template examples |
## PR titles
Apply the same limit to PR titles. PR body can be slightly longer but keep the summary to 1–3 short bullets.

View File

@@ -0,0 +1,49 @@
---
name: tinymist
description: >-
Compile and check Typst documents in this project with tinymist, not typst-cli.
Use when compiling .typ files, checking Typst errors, or validating report output.
---
# Use Tinymist for Typst
Always use **tinymist**, never `typst` CLI. Do not download or install typst.
## Binary
```bash
/home/diaco/.local/bin/tinymist
```
Fallback: `tinymist` if on PATH.
## Compile
From project root:
```bash
tinymist compile --font-path template_files main.typ main.pdf
```
Other entry points:
```bash
tinymist compile --font-path template_files main.travel-report-example.typ
tinymist compile --font-path template_files main.product-test-example.typ
```
Always pass `--font-path template_files` (fonts: `IRNazanin`, `IRZar`).
## Check errors
Use `tinymist compile` — errors print to stderr. For a quick pass/fail:
```bash
tinymist test main.typ
```
## Do not
- Run `typst compile`
- Download typst from GitHub releases
- Install typst via cargo unless the user explicitly asks

10
.zed/settings.json Normal file
View File

@@ -0,0 +1,10 @@
{
"lsp": {
"tinymist": {
"settings": {
"exportPdf": "onSave",
"outputPath": "$root/$dir/$name"
}
}
}
}

103
README.md
View File

@@ -1,42 +1,92 @@
# Typst Templates # Typst Templates
A collection of Typst templates for creating professional documents. A collection of Typst templates for creating professional Persian (RTL) reports for Kimia Razi.
## Templates ## Templates
### Paper Template (`paper_template.typ`) This repository contains three templates:
A professional document template with:
- Custom header and footer ### Paper Template (`paper_template.typ`)
- Persian and English font support
- Configurable page margins A general working-paper / report template (based on the SSRN paper layout). It exposes a `paper` function with:
- Title, author, and date formatting
- Support for sections and structured content - Persian (RTL) layout with custom fonts (`IRNazanin`, `IRZar`, `IRLotus`)
- A rotated sidebar background showing company, title, destinations, and page number
- A logo header that appears from the second page onward
- Configurable `title`, `subtitle`, `company`, `authors`, `destinations`, `purpose`, and `date`
- Numbered headings, equations, and footnotes
### Product Test Template (`product_test_template.typ`)
A template for raw-material / product test reports. It builds on the `paper` function and adds helper functions for tabular results:
- `general_info_table(...)` – general report information (dates, sample type, count, supplier)
- `received_samples_table(rows)` – structured table of received samples
- `sample_section(...)` / `sample_entry(...)` – per-sample heading and info blocks
- `test_result_table(cols)` / `pigment_result_block(name, rows)` – non-breakable result tables grouped per sample
### Travel Report Template (`travel-report-template.typ`)
A template for mission / travel reports. It exposes a `report` function and a `report-table` helper with:
- Persian (RTL) layout with fonts loaded from `template_files/`
- A title block with company, subtitle, and logo
- A general-info section (destination, purpose, team, date)
- A rotated sidebar background with destinations, authors, and page number
## Examples
- `main.product-test-example.typ` – a completed product test report (Esmaltes pigments) using `product_test_template.typ`
- `main.travel-report-example.typ` – a completed mission report using `travel-report-template.typ`
### Main Template (`main.typ`)
Extended template for comprehensive reports including:
- Multi-language support (Persian/English)
- Professional styling
- Tables and figures support
- Bibliography and citations
- Custom layout options
## Usage ## Usage
### Basic Usage
### Product test report
```typst ```typst
#import "paper_template.typ": * #import "product_test_template.typ": *
#show: project.with( #show: paper.with(
title: "Your Document Title", title: "گزارش تست مواد اولیه",
author: "Your Name", subtitle: "دپارتمان جوهر",
date: datetime.today().display() authors: ((name: "نام نویسنده"),),
date: "۱۴۰۵/۰۱/۲۴",
) )
= Section Title = اطلاعات کلی
Your content here... #general_info_table("۱۴۰۵/۰۱/۱۷", "۱۴۰۵/۰۱/۲۴", "پیگمنت", "۹", "Esmaltes")
``` ```
### Travel report
```typst
#import "travel-report-template.typ": report, report-table
#show: report.with(
title: "گزارش مأموریت",
destinations: ((name: "کاشی آسیا"),),
purpose: "تست آزمایشی جوهرها",
date: "۰۵/۰۲/۲۷",
)
= گزارش مأموریت
متن گزارش ...
```
### Installation ### Installation
Clone this repository to use the templates: Clone this repository to use the templates:
@@ -45,9 +95,14 @@ Clone this repository to use the templates:
git clone ssh://git@git.faryad.top:2222/rhino/typst-templates.git git clone ssh://git@git.faryad.top:2222/rhino/typst-templates.git
``` ```
### Requirements ### Requirements
- [Typst](https://typst.app/) - Install from https://github.com/typst/typst - [Typst](https://typst.app/) - Install from [https://github.com/typst/typst](https://github.com/typst/typst)
- Persian fonts (`IRNazanin`, `IRZar`, `IRLotus`). The travel report template loads fonts from `template_files/`; compile with `--font-path template_files`.
## Contributing ## Contributing

View File

@@ -0,0 +1,124 @@
#import "product_test_template.typ": *
#set text(lang: "fa")
#show: paper.with(
authors: (
(
name: "دیاکو سلطانپور",
affiliation: "کیمیا رازی - واحد جوهر",
email: "diaco@kimiarazi.com",
note: "ink dept",
),
),
date: "۲۲ تا ۴/۶/۲۶",
destinations: (
(name: " نتايج تست پيگمنت‌های شرکت اسمالتس"),
),
purpose: "بازدید و بررسی وضعیت",
)
// Your main content goes here
\
= اطلاعات کلی
#general_info_table(
"۱۴۰۵/۰۱/۱۷",
"۱۴۰۵/۰۱/۲۴",
"پیگمنت",
"۹",
"Esmaltes",
)
\
== نمونه‌های دریافت شده
#received_samples_table((
("پیگمنت زرد", "CLCE-539/1", "PI-Y36", "2"),
("پیگمنت قهوه‌ای", "CLCE-539/2", "PI-DBR3", "3"),
("پیگمنت بژ", "CLCE-539/3", "PI-BG31", "4"),
("پیگمنت بژ", "CLCE-539/4", "PI-BG32", "5"),
("پیگمنت آبی", "CLCE-539/5", "PI-BL53", "6"),
("پیگمنت آبی", "CLCE-539/6", "PI-BL54", "7"),
("پیگمنت مشکی", "CLCE-539/7", "PI-BK38", "8"),
("پیگمنت مشکی", "CLCE-539/8", "PI-BK39", "9"),
("پیگمنت صورتی", "CLCE-539/9", "PI-P26", "10"),
))
\
#colbreak()
== تست‌های انجام شده
با استفاده از این پیگمنت‌ها نمونه جوهر ساخته و در کنار نمونه آزمایشگاهی ساخته شده با پیگمنت استاندارد کیمیا رازی با شرایط زیر تست شد.
- روش اعمال: قطره‌ای
- لعاب: سه لعاب مختلف (براق و مات)
- دمای پخت: ۱۰۳۰، ۱۱۵۰ و ۱۱۸۰ °C
- مرجع مقایسه: پیگمنت استاندارد کیمیا رازی
\
فرمول نمونه جوهر بر اساس درصد وزنی:
#ink_formula_table((
("پیگمنت", 30),
("حلال", 60),
("دیسپرسانت", 10),
))
\
تست‌ها شامل:
- بررسی کیفیت سطح
- شدت رنگ
- تم رنگ
// تست پایداری جوهر در مقابل رسوب‌گذاری و ته‌نشینی نیز انجام شده است.
#colbreak()
\
== نتایج تست‌ها
// وضعیت نمونه‌های پیگمنت تست شده در مقایسه با نمونه استاندارد کیمیا رازی:
#columns(2, gutter: 8pt)[
#pigment_result_block("پیگمنت زرد", (
([*معیار*], [*CLCE-539/1*]),
([کیفیت سطح], [خوب]),
([تم رنگ], [چرک]),
([شدت رنگ], [خوب]),
([نتیجه نهایی], [نامناسب (تم چرک)]),
))
#pigment_result_block("پیگمنت قهوه‌ای", (
([*معیار*], [*CLCE-539/2*]),
([کیفیت سطح], [خوب]),
([تم رنگ], [خوب]),
([شدت رنگ], [کمتر]),
([نتیجه نهایی], [نامناسب (شدت رنگ کمتر)]),
))
\
#pigment_result_block("پیگمنت بژ", (
([*معیار*], [*CLCE-539/3*], [*CLCE-539/4*]),
([کیفیت سطح], [خوب], [خوب]),
([تم رنگ], [خوب], [خوب]),
([شدت رنگ], [خوب], [خوب]),
([نتیجه نهایی], [متفاوت از رفرنس], [متفاوت از رفرنس]),
))
#pigment_result_block("پیگمنت آبی", (
([*معیار*], [*CLCE-539/5*], [*CLCE-539/6*]),
([کیفیت سطح], [خوب], [خوب]),
([تم رنگ], [خوب], [تم سایان]),
([شدت رنگ], [کمتر], [خوب]),
([نتیجه نهایی], [نامناسب (شدت رنگ کمتر)], [مناسب برای سایان]),
))
\
#pigment_result_block("پیگمنت مشکی", (
([*معیار*], [*CLCE-539/7*], [*CLCE-539/8*]),
([کیفیت سطح], [خوب], [خوب]),
([تم رنگ], [قهوه‌ای], [خوب]),
([شدت رنگ], [کمتر], [کمتر]),
([نتیجه نهایی], [نامناسب (شدت رنگ کمتر)], [نامناسب (شدت رنگ کمتر)]),
))
\
=== پیگمنت صورتی
به دلیل موجود کافی در انبار تست این پیگمنت به زمان دیگری موکول شد.
]
\
== جمع بندی نتايج
- بین پیگمنت‌های بژ، نمونه CLCE-539/3 مشابه پیگمنت OC860A و نمونه CLCE-539/4 زردتر از آن است.
- در پیگمنت‌های آبی، نمونه CLCE539/5 مشابه کد ICK12/K315 و نمونه CLCE539/6 دارای تم سایان است.
\
== پیشنهادات
هیچ کدام از پیگمنت‌ها برای انجام تست صنعتی در نظر گرفته نشد ولی در صورت بروز مشکل در تأمین پیگمنت‌های مصرفی کنونی، می‌توان این نمونه‌ها را به عنوان کاندید جایگزینی در نظر گرفت.
\
\
== نظر مدیر کارخانه

View File

@@ -51,10 +51,14 @@
#report-table( #report-table(
columns: (1.3fr, 2.2fr), columns: (1.3fr, 2.2fr),
[*کد نمونه*], [*نتیجه*], [*کد نمونه*],
[KRBR-1201T], [شدت رنگ بیشتر], [*نتیجه*],
[KRBR-1202T], [شدت رنگ بیشتر], [KRBR-1201T],
[ICJ/408], [شدت رنگ بیشتر], [شدت رنگ بیشتر],
[KRBR-1202T],
[شدت رنگ بیشتر],
[ICJ/408],
[شدت رنگ بیشتر],
) )
بین نمونه‌های قهوه‌ای، ICJ/408 بیشترین شدت رنگ را دارد. کد KRBR-1202T به نمونه رفرنس نزدیک‌تر است. بین نمونه‌های قهوه‌ای، ICJ/408 بیشترین شدت رنگ را دارد. کد KRBR-1202T به نمونه رفرنس نزدیک‌تر است.
@@ -63,12 +67,18 @@
#report-table( #report-table(
columns: (1.3fr, 2.2fr), columns: (1.3fr, 2.2fr),
[*کد نمونه*], [*نتیجه*], [*کد نمونه*],
[KRBG-1600T], [تم رنگ تیره‌تر], [*نتیجه*],
[KRHN-1700T], [تم رنگ تیره‌تر], [KRBG-1600T],
[KRGY-1900T], [تم رنگ تیره‌تر], [تم رنگ تیره‌تر],
[KRGY-1901T], [مشابه رفرنس (کمی تیره‌تر)], [KRHN-1700T],
[KRYL-1400T], [زردی بیشتر], [تم رنگ تیره‌تر],
[KRGY-1900T],
[تم رنگ تیره‌تر],
[KRGY-1901T],
[مشابه رفرنس (کمی تیره‌تر)],
[KRYL-1400T],
[زردی بیشتر],
) )
#colbreak() #colbreak()
@@ -77,13 +87,20 @@
#report-table( #report-table(
columns: (1.3fr, 2.2fr), columns: (1.3fr, 2.2fr),
[*کد نمونه*], [*نتیجه*], [*کد نمونه*],
[ICJ/610], [تم سبز], [*نتیجه*],
[ICJ/EH600], [تم قهوه‌ای], [ICJ/610],
[ICJ/EH630], [تم قهوه‌ای], [تم سبز],
[ICJ/EH680], [کمترین شدت رنگ، تم قهوه‌ای], [ICJ/EH600],
[KRBL-1300T], [تم سبز], [تم قهوه‌ای],
[KRBL-1314T], [بیشترین شدت رنگ], [ICJ/EH630],
[تم قهوه‌ای],
[ICJ/EH680],
[کمترین شدت رنگ، تم قهوه‌ای],
[KRBL-1300T],
[تم سبز],
[KRBL-1314T],
[بیشترین شدت رنگ],
) )
] ]

View File

@@ -15,99 +15,107 @@
company: "کیمیا رازی", company: "کیمیا رازی",
title: "گزارش تست مواد اولیه", title: "گزارش تست مواد اولیه",
subtitle: "دپارتمان جوهر", subtitle: "دپارتمان جوهر",
destinations: (none), destinations: none,
purpose: none, purpose: none,
authors: ("دیاکو سلطانپور"), authors: "دیاکو سلطانپور",
date: "", date: "",
doc, doc,
) = { ) = {
set math.equation(numbering: "(1)", supplement: auto) set math.equation(numbering: "(1)", supplement: auto)
set par(leading: 1em) set par(leading: 1em)
// Set and show rules from before. // Set and show rules from before.
set text( set text(
font: font, font: font,
size: fontsize size: fontsize,
) )
set page( set page(
paper: "a4", paper: "a4",
header: header: context {
context {if counter(page).get().first() > 1 [ if counter(page).get().first() > 1 [
#grid( #grid(
gutter: 5pt, gutter: 5pt,
columns: (4.2%,25%,3%,20%), columns: (4.2%, 25%, 3%, 20%),
grid.cell(align: right, stroke: 1pt, image(height: 19pt,"kimia razi logo bw.png")), grid.cell(align: right, stroke: 1pt, image(
align: top+right, height: 19pt,
title, "kimia razi logo bw.png",
"|", )),
subtitle, align: top + right,
grid.hline(start: 0),)]}, title,
background: place( "|",
dx: -54%, subtitle,
dy: 63.5%, grid.hline(start: 0),
rotate( )]
-90deg, },
text(13pt,font: "IRZar", background: place(
// TODO: do not use grid. use #text and fr if possible dx: -54%,
grid( dy: 63.5%,
columns: (15%,25%, 40% ,5%), rotate(
rows: 20pt, -90deg,
align: top, text(
context[ 13pt,
#h(1fr) #company #h(2fr)|], font: "IRZar",
[#h(2fr) #title #h(4fr)|], // TODO: do not use grid. use #text and fr if possible
[#h(2fr)#destinations.map(destination => destination.name).join("\n") #h(2fr)], grid(
grid.cell(fill: black, columns: (15%, 25%, 40%, 5%),
align: center, rows: 20pt,
stroke: 1pt, align: top,
text(fill: white, context [
context(counter(page).display("۱/۱", both: true,)))), #h(1fr) #company #h(2fr)|],
grid.hline(start: 0), [#h(2fr) #title #h(4fr)|],
) [#h(2fr)#(
) destinations.map(destination => destination.name).join("\n")
) ) #h(2fr)],
) grid.cell(fill: black, align: center, stroke: 1pt, text(
) fill: white,
set document( context (counter(page).display("۱/۱", both: true)),
title: title, )),
author: authors.map(author => author.name), grid.hline(start: 0),
),
),
),
),
)
set document(
title: title,
author: authors.map(author => author.name),
)
set align(right)
if subtitle != none {
text(align(center, { strong(company) }))
}
if subtitle != none {
text(align(center, { subtitle }))
}
text(18pt, align(center, { strong(title) }))
set text(13pt, font: "IRLotus")
align(center, line(length: 85%))
/*
pad(x: 40pt,
grid(
columns: (2fr, 3fr, 2fr, 3fr),
gutter: (2em,22pt),
[بازدید از:], grid.cell(align: left, strong(destinations.map(destination => destination.name).join("\n"))), [هدف بازدید:], grid.cell(align: left, strong(purpose)),
[تیم اعزامی:], grid.cell(align: left, strong(authors.map(author => author.name).join("\n"))), [تاریخ بازدید:], grid.cell(align(left, strong(date))),)
) )
align(center, line(length: 85%))
set align(right) v(10pt)
if subtitle != none { */
text(align(center,{strong(company)})) set heading(numbering: "۱.۱- ")
} set math.equation(numbering: "(1)")
if subtitle != none { set footnote(numbering: "۱.")
text(align(center,{subtitle})) set footnote.entry(separator: line(length: 100%, stroke: 0.5pt))
} set footnote.entry(indent: 0em)
text(18pt, align(center,{strong(title)})) set align(right)
set text(13pt, font: "IRLotus")
align(center, line(length: 85%))
/*
pad(x: 40pt,
grid(
columns: (2fr, 3fr, 2fr, 3fr),
gutter: (2em,22pt),
[بازدید از:], grid.cell(align: left, strong(destinations.map(destination => destination.name).join("\n"))), [هدف بازدید:], grid.cell(align: left, strong(purpose)),
[تیم اعزامی:], grid.cell(align: left, strong(authors.map(author => author.name).join("\n"))), [تاریخ بازدید:], grid.cell(align(left, strong(date))),)
)
align(center, line(length: 85%))
v(10pt)
*/
set heading(numbering: "۱.۱- ")
set math.equation(numbering: "(1)")
set footnote(numbering: "۱.")
set footnote.entry(separator: line(length: 100%, stroke: 0.5pt))
set footnote.entry(indent: 0em)
set align(right)
show heading: it => [ show heading: it => [
#set align(right) #set align(right)
#counter(heading).display( #counter(heading).display(
it.numbering it.numbering,
) #it.body ) #it.body
#v(10pt) #v(10pt)
] ]
@@ -118,7 +126,7 @@
justify: true, justify: true,
) )
columns(1, doc) columns(1, doc)
} }

View File

@@ -9,93 +9,131 @@
// Email: dyaco8464@yahoo.com // Email: dyaco8464@yahoo.com
/////////////////////////////// ///////////////////////////////
#let fonts = (
body: "IRNazanin",
sidebar: "IRZar",
)
#let paper( #let paper(
font: "IRNazanin", font: fonts.body,
fontsize: 13pt, fontsize: 13pt,
company: "کیمیا رازی", company: "کیمیا رازی",
title: "گزارش تست مواد اولیه", title: "گزارش تست مواد اولیه",
subtitle: "دپارتمان جوهر", subtitle: "دپارتمان جوهر",
destinations: (none), destinations: (),
purpose: none, purpose: "",
authors: ("دیاکو سلطانپور"), authors: (
(
name: "دیاکو سلطانپور",
affiliation: "کیمیا رازی - واحد جوهر",
email: "diaco@kimiarazi.com",
note: "ink dept",
),
),
date: "", date: "",
doc, doc,
) = { ) = {
set math.equation(numbering: "(1)", supplement: auto) set math.equation(numbering: "(1)", supplement: auto)
set par(leading: 1em) set par(leading: 1em)
// Set and show rules from before. // Set and show rules from before.
set text( set text(
font: font, font: font,
size: fontsize size: fontsize,
) )
set page( set page(
paper: "a4", margin: (left: 2cm, right: 2cm, top: 2.5cm, bottom: 2.5cm),
header: paper: "a4",
context {if counter(page).get().first() > 1 [ header: context {
#grid( if counter(page).get().first() > 1 [
gutter: 5pt, #grid(
columns: (4.2%,25%,3%,20%), gutter: 5pt,
grid.cell(align: right, stroke: 1pt, image(height: 19pt,"kimia razi logo bw.png")), columns: (auto, 1fr, auto, auto),
align: top+right, grid.cell(align: right, stroke: 1pt, image(
title, height: 19pt,
"|", "template_files/kimia razi logo bw.png",
subtitle, )),
grid.hline(start: 0),)]}, align: top + right,
background: place( company,
dx: -54%, "|",
dy: 63.5%, subtitle,
rotate( grid.hline(start: 0),
-90deg, )]
text(13pt,font: "IRZar", },
// TODO: do not use grid. use #text and fr if possible background: place(
grid( dx: -64%,
columns: (15%,25%, 40% ,5%), dy: 73%,
rows: 20pt, rotate(
align: top, -90deg,
context[ text(13pt, font: fonts.sidebar, grid(
#h(1fr) #company #h(2fr)|], columns: (30%, 30%, 5%),
[#h(2fr) #title #h(4fr)|], rows: 20pt,
[#h(2fr)#destinations.map(destination => destination.name).join("\n") #h(2fr)], align: top,
grid.cell(fill: black, [#h(1fr) #title #h(5fr)],
align: center, [#h(1fr) #(destinations.map(destination => destination.name).join(", ")) #h(5fr)],
stroke: 1pt, grid.cell(fill: black, align: center, stroke: 1pt, text(
text(fill: white, fill: white,
context(counter(page).display("۱/۱", both: true,)))), context (counter(page).display("۱/۱", both: true)),
grid.hline(start: 0), )),
) grid.hline(start: 0),
) )),
) ),
) ),
) numbering: "۱",
set document( )
title: title, set document(
author: authors.map(author => author.name), title: title,
) author: authors.map(author => author.name),
)
set align(right) // ===== TITLE SECTION =====
if subtitle != none { block(width: 100%)[
text(align(center,{strong(company)})) #grid(
columns: (auto, auto, 1fr),
align: top,
[
#align(right)[
#set par(leading: 0.9em, spacing: 0em)
#text(21pt, font: font, weight: "bold", strong(company))
#if subtitle != none and subtitle != "" {
text(14pt, " | " + subtitle)
} }
text(18pt, align(center,{strong(title)})) #linebreak()
set text(13pt, font: "IRLotus") #text(14pt, strong(title))
if subtitle != none { ]
text(align(center,{subtitle})) ],
} [],
align(center, line(length: 100%)) [#align(left, image(
// set heading(numbering: "۱.۱- ") "template_files/kimia razi logo bw.png",
set math.equation(numbering: "(1)") height: 1.8cm,
set footnote(numbering: "۱.") ))],
set footnote.entry(separator: line(length: 100%, stroke: 0.5pt)) )
set footnote.entry(indent: 0em)
set align(right)
show heading: it => [
#set align(right)
#it.body
#v(10pt)
] ]
// set heading(numbering: "۱.۱- ")
set math.equation(numbering: "(1)")
set footnote(numbering: "۱.")
set footnote.entry(separator: line(length: 100%, stroke: 0.5pt))
set footnote.entry(indent: 0em)
set align(right)
show heading: it => context {
let y = here().position().y
let body-top = if counter(page).get().first() > 1 {
page.margin.top + 28pt
} else {
page.margin.top
}
let not-at-top = y > body-top + 12pt
[
#if not-at-top and it.level <= 2 [
#line(length: 100%)
#v(8pt)
]
#set align(right)
#it.body
#v(10pt)
]
}
set text(spacing: 100%) set text(spacing: 100%)
set par( set par(
@@ -104,7 +142,7 @@
justify: true, justify: true,
) )
columns(1, doc) columns(1, doc)
} }
// Renders a centered, non-breakable result table. // Renders a centered, non-breakable result table.
@@ -118,15 +156,13 @@
#let test_result_table(cols) = { #let test_result_table(cols) = {
block( block(
breakable: false, breakable: false,
align(center, align(center, table(
table( columns: (auto,) * (cols.first().len()),
columns: (auto,) * (cols.first().len()), inset: 8pt,
inset: 8pt, stroke: 0.5pt,
stroke: 0.5pt, fill: (x, y) => if y == 0 { luma(230) },
fill: (x, y) => if y == 0 { luma(230) }, ..cols.flatten(),
..cols.flatten(), )),
)
)
) )
} }
@@ -179,15 +215,88 @@
// "۹", // "۹",
// "Esmaltes", // "Esmaltes",
// ) // )
#let general_info_table(received_date, report_date, sample_type, sample_count, supplier) = { #let general_info_table(
grid( received_date,
columns: (auto, auto), report_date,
inset: 10pt, sample_type,
[- تاریخ دریافت نمونه:], [#received_date], sample_count,
[- تاریخ گزارش:], [#report_date], supplier,
[- نوع نمونه:], [#sample_type], ) = {
[- تعداد:], [#sample_count], block(
[- تأمین کننده:], [#supplier], breakable: false,
align(center, table(
columns: (auto, auto, auto, auto, auto),
align: right,
stroke: 0.5pt,
inset: 8pt,
fill: (x, y) => if y == 0 { luma(235) },
[*تاریخ دریافت نمونه*],
[*تاریخ گزارش*],
[*نوع نمونه*],
[*تعداد*],
[*تأمین کننده*],
[#received_date],
[#report_date],
[#sample_type],
[#sample_count],
[#supplier],
)),
)
}
// Renders the test conditions as a structured key/value table.
// Each row is a tuple of (label, value).
// Usage:
// #test_conditions_table((
// ([روش اعمال], [قطره‌ای]),
// ([دمای پخت], [۱۰۳۰، ۱۱۵۰، ۱۱۸۰ °C]),
// ))
#let test_conditions_table(rows) = {
block(
breakable: false,
align(center, table(
columns: (auto, auto),
align: right,
stroke: 0.5pt,
inset: 8pt,
fill: (x, y) => if y == 0 { luma(235) },
[*شرط آزمون*],
[*مقدار*],
..rows.flatten(),
)),
)
}
// Renders the ink formula as a horizontal component / weight-% table and
// appends an automatic total column. Component names are rendered LTR (English).
// Each row is a tuple of (component, weight).
// Usage:
// #ink_formula_table((
// ("Pigment", 30),
// ("Sol-1", 60),
// ("Super Disp.", 10),
// ))
#let ink_formula_table(rows) = {
let total = rows.fold(0, (acc, row) => acc + row.at(1))
let last-col = rows.len()
block(
breakable: false,
align(center, table(
columns: (auto,) * (rows.len() + 1),
align: center,
stroke: 0.5pt,
inset: 8pt,
fill: (x, y) => {
if x == last-col { luma(245) }
else if y == 0 { luma(235) }
},
..rows
.map(row => [*#text(dir: ltr, row.at(0))*])
.flatten(),
[*جمع*],
..rows.map(row => [#row.at(1)]).flatten(),
[*#total*],
)),
) )
} }
@@ -197,20 +306,18 @@
#let received_samples_table(rows) = { #let received_samples_table(rows) = {
block( block(
breakable: false, breakable: false,
align(center, align(center, table(
table( columns: (auto, auto, auto, auto),
columns: (auto, auto, auto, auto), align: right,
align: right, stroke: 0.5pt,
stroke: 0.5pt, inset: 7pt,
inset: 7pt, fill: (x, y) => if y == 0 { luma(235) },
fill: (x, y) => if y == 0 { luma(235) }, [*نوع پیگمنت*],
[*نوع پیگمنت*], [*کد تأمین کننده*],
[*کد تأمین کننده*], [*کد داخلی*],
[*کد داخلی*], [*شماره سند*],
[*شماره سند*], ..rows.flatten(),
..rows.flatten(), )),
)
)
) )
} }

View File

@@ -5,16 +5,16 @@
) )
#let destination-names(destinations) = { #let destination-names(destinations) = {
if destinations == none { "" } if destinations == none { "" } else {
else { destinations.map(d => d.name).join(" - ") } destinations.map(d => d.name).join(" - ")
}
} }
#let report-meta-row(label-width, label, value) = grid( #let report-meta-row(label-width, label, value) = grid(
columns: (label-width, 1fr), columns: (label-width, 1fr),
gutter: (2em, 0pt), gutter: (2em, 0pt),
align: right + top, align: right + top,
[#label], [#label], [#strong(value)],
[#strong(value)],
) )
#let report-meta-label-width = 8em #let report-meta-label-width = 8em
@@ -40,50 +40,52 @@
) = { ) = {
set page( set page(
margin: (left: 2cm, right: 2cm, top: 2.5cm, bottom: 2.5cm), margin: (left: 2cm, right: 2cm, top: 2.5cm, bottom: 2.5cm),
paper: "a4", paper: "a4",
header: header: context {
context {if counter(page).get().first() > 1 [ if counter(page).get().first() > 1 [
#grid( #grid(
gutter: 5pt, gutter: 5pt,
columns: (auto, 1fr, auto, auto), columns: (auto, 1fr, auto, auto),
grid.cell(align: right, stroke: 1pt, image(height: 19pt,"template_files/kimia razi logo bw.png")), grid.cell(align: right, stroke: 1pt, image(
align: top+right, height: 19pt,
company, "template_files/kimia razi logo bw.png",
"|", )),
subtitle, align: top + right,
grid.hline(start: 0),)]}, company,
background: place( "|",
dx: -64%, subtitle,
dy: 73%, grid.hline(start: 0),
rotate( )]
-90deg, },
text(13pt, font: fonts.sidebar, background: place(
grid( dx: -64%,
columns: (30%,30%,5%), dy: 73%,
rows: 20pt, rotate(
align: top, -90deg,
[#h(1fr) گزارش ماموریت #destination-names(destinations) #h(5fr)], text(13pt, font: fonts.sidebar, grid(
context[ columns: (30%, 30%, 5%),
#let side_authors = if authors.len() == 0 { rows: 20pt,
"" align: top,
} else { [#h(1fr) گزارش ماموریت #destination-names(destinations) #h(5fr)],
authors.map(author => author.name).join(" - ") context [
} #let side_authors = if authors.len() == 0 {
#let textwidth = measure(side_authors).width ""
#if authors.len() > 0 and textwidth > page.width * 0.28 { } else {
side_authors = authors.first().name + " و ..." authors.map(author => author.name).join(" - ")
} }
#h(1fr) #side_authors #h(4fr)], #let textwidth = measure(side_authors).width
grid.cell(fill: black, #if authors.len() > 0 and textwidth > page.width * 0.28 {
align: center, side_authors = authors.first().name + " و ..."
stroke: 1pt, }
text(fill: white, #h(1fr) #side_authors #h(4fr)],
context(counter(page).display("۱/۱", both: true,)))), grid.cell(fill: black, align: center, stroke: 1pt, text(
grid.hline(start: 0), fill: white,
) context (counter(page).display("۱/۱", both: true)),
) )),
) grid.hline(start: 0),
), )),
),
),
numbering: "۱", numbering: "۱",
) )
set text(lang: "fa", dir: rtl, font: font, size: fontsize) set text(lang: "fa", dir: rtl, font: font, size: fontsize)
@@ -97,14 +99,17 @@
#set par(leading: 0.9em, spacing: 0em) #set par(leading: 0.9em, spacing: 0em)
#text(21pt, font: fonts.body, weight: "bold", strong(company)) #text(21pt, font: fonts.body, weight: "bold", strong(company))
#if subtitle != none and subtitle != "" { #if subtitle != none and subtitle != "" {
text(14pt, " | "+subtitle) text(14pt, " | " + subtitle)
} }
#linebreak() #linebreak()
#text(14pt, strong(title)) #text(14pt, strong(title))
] ]
], ],
[], [],
[#align(left, image("template_files/kimia razi logo bw.png", height: 1.8cm))], [#align(left, image(
"template_files/kimia razi logo bw.png",
height: 1.8cm,
))],
) )
] ]
set align(right) set align(right)
@@ -115,9 +120,17 @@
#set par(leading: 0.9em, spacing: 0em) #set par(leading: 0.9em, spacing: 0em)
#stack( #stack(
spacing: 14pt, spacing: 14pt,
report-meta-row(report-meta-label-width, [مقصد:], destination-names(destinations)), report-meta-row(
report-meta-label-width,
[مقصد:],
destination-names(destinations),
),
report-meta-row(report-meta-label-width, [هدف مأموریت:], purpose), report-meta-row(report-meta-label-width, [هدف مأموریت:], purpose),
report-meta-row(report-meta-label-width, [تیم اعزامی:], authors.map(author => author.name).join(" - ")), report-meta-row(
report-meta-label-width,
[تیم اعزامی:],
authors.map(author => author.name).join(" - "),
),
report-meta-row(report-meta-label-width, [تاریخ:], date), report-meta-row(report-meta-label-width, [تاریخ:], date),
) )
]) ])