Enhance product test template with improved font management, structured header, and refined table layouts
This commit is contained in:
@@ -9,15 +9,27 @@
|
||||
// Email: dyaco8464@yahoo.com
|
||||
///////////////////////////////
|
||||
|
||||
#let fonts = (
|
||||
body: "IRNazanin",
|
||||
sidebar: "IRZar",
|
||||
)
|
||||
|
||||
#let paper(
|
||||
font: "IRNazanin",
|
||||
font: fonts.body,
|
||||
fontsize: 13pt,
|
||||
company: "کیمیا رازی",
|
||||
title: "گزارش تست مواد اولیه",
|
||||
subtitle: "دپارتمان جوهر",
|
||||
destinations: none,
|
||||
purpose: none,
|
||||
authors: "دیاکو سلطانپور",
|
||||
destinations: (),
|
||||
purpose: "",
|
||||
authors: (
|
||||
(
|
||||
name: "دیاکو سلطانپور",
|
||||
affiliation: "کیمیا رازی - واحد جوهر",
|
||||
email: "diaco@kimiarazi.com",
|
||||
note: "ink dept",
|
||||
),
|
||||
),
|
||||
date: "",
|
||||
doc,
|
||||
) = {
|
||||
@@ -31,51 +43,44 @@
|
||||
size: fontsize,
|
||||
)
|
||||
set page(
|
||||
margin: (left: 2cm, right: 2cm, top: 2.5cm, bottom: 2.5cm),
|
||||
paper: "a4",
|
||||
header: context {
|
||||
if counter(page).get().first() > 1 [
|
||||
#grid(
|
||||
gutter: 5pt,
|
||||
columns: (4.2%, 25%, 3%, 20%),
|
||||
columns: (auto, 1fr, auto, auto),
|
||||
grid.cell(align: right, stroke: 1pt, image(
|
||||
height: 19pt,
|
||||
"kimia razi logo bw.png",
|
||||
"template_files/kimia razi logo bw.png",
|
||||
)),
|
||||
align: top + right,
|
||||
title,
|
||||
company,
|
||||
"|",
|
||||
subtitle,
|
||||
grid.hline(start: 0),
|
||||
)]
|
||||
},
|
||||
background: place(
|
||||
dx: -54%,
|
||||
dy: 63.5%,
|
||||
dx: -64%,
|
||||
dy: 73%,
|
||||
rotate(
|
||||
-90deg,
|
||||
text(
|
||||
13pt,
|
||||
font: "IRZar",
|
||||
// TODO: do not use grid. use #text and fr if possible
|
||||
grid(
|
||||
columns: (15%, 25%, 40%, 5%),
|
||||
rows: 20pt,
|
||||
align: top,
|
||||
context [
|
||||
#h(1fr) #company #h(2fr)|],
|
||||
[#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,
|
||||
context (counter(page).display("۱/۱", both: true)),
|
||||
)),
|
||||
grid.hline(start: 0),
|
||||
),
|
||||
),
|
||||
text(13pt, font: fonts.sidebar, grid(
|
||||
columns: (30%, 30%, 5%),
|
||||
rows: 20pt,
|
||||
align: top,
|
||||
[#h(1fr) #title #h(5fr)],
|
||||
[#h(1fr) #(destinations.map(destination => destination.name).join(", ")) #h(5fr)],
|
||||
grid.cell(fill: black, align: center, stroke: 1pt, text(
|
||||
fill: white,
|
||||
context (counter(page).display("۱/۱", both: true)),
|
||||
)),
|
||||
grid.hline(start: 0),
|
||||
)),
|
||||
),
|
||||
),
|
||||
numbering: "۱",
|
||||
)
|
||||
set document(
|
||||
title: title,
|
||||
@@ -206,14 +211,25 @@
|
||||
sample_count,
|
||||
supplier,
|
||||
) = {
|
||||
grid(
|
||||
columns: (auto, auto),
|
||||
inset: 10pt,
|
||||
[- تاریخ دریافت نمونه:], [#received_date],
|
||||
[- تاریخ گزارش:], [#report_date],
|
||||
[- نوع نمونه:], [#sample_type],
|
||||
[- تعداد:], [#sample_count],
|
||||
[- تأمین کننده:], [#supplier],
|
||||
block(
|
||||
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],
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -240,8 +256,8 @@
|
||||
)
|
||||
}
|
||||
|
||||
// Renders the ink formula as a component / weight-% table and appends an
|
||||
// automatic total row. Component names are rendered LTR (English).
|
||||
// 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((
|
||||
@@ -251,19 +267,24 @@
|
||||
// ))
|
||||
#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, auto),
|
||||
columns: (auto,) * (rows.len() + 1),
|
||||
align: center,
|
||||
stroke: 0.5pt,
|
||||
inset: 8pt,
|
||||
fill: (x, y) => if y == 0 { luma(235) },
|
||||
[*جزء*],
|
||||
[*درصد وزنی*],
|
||||
..rows.map(row => (text(dir: ltr, row.at(0)), [#row.at(1)])).flatten(),
|
||||
table.cell(fill: luma(245), [*مجموع*]),
|
||||
table.cell(fill: luma(245), [*#total*]),
|
||||
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*],
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user