/////////////////////////////// // This Typst template is for working paper draft. // It is based on the general SSRN paper. // Copyright (c) 2024 // Author: Diaco // License: MIT // Version: 0.9.0 // Date: 2024-05-16 // Email: dyaco8464@yahoo.com /////////////////////////////// #let fonts = ( body: "IRNazanin", sidebar: "IRZar", ) #let paper( font: fonts.body, fontsize: 13pt, company: "کیمیا رازی", title: "گزارش تست مواد اولیه", subtitle: "دپارتمان جوهر", destinations: (), purpose: "", authors: ( ( name: "دیاکو سلطانپور", affiliation: "کیمیا رازی - واحد جوهر", email: "diaco@kimiarazi.com", note: "ink dept", ), ), date: "", doc, ) = { set math.equation(numbering: "(1)", supplement: auto) set par(leading: 1em) // Set and show rules from before. set text( font: font, 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: (auto, 1fr, auto, auto), grid.cell(align: right, stroke: 1pt, image( height: 19pt, "template_files/kimia razi logo bw.png", )), align: top + right, company, "|", subtitle, grid.hline(start: 0), )] }, background: place( dx: -64%, dy: 73%, rotate( -90deg, 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, author: authors.map(author => author.name), ) // ===== TITLE SECTION ===== block(width: 100%)[ #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) } #linebreak() #text(14pt, strong(title)) ] ], [], [#align(left, image( "template_files/kimia razi logo bw.png", height: 1.8cm, ))], ) ] // 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 par( leading: 1.2em, first-line-indent: 0em, justify: true, ) columns(1, doc) } // Renders a centered, non-breakable result table. // Each row is a tuple of content cells; the first row is the header. // Usage: // #test_result_table(( // ([*معیار*], [*CLCE-539/1*]), // ([کیفیت سطح], [خوب]), // ([نتیجه نهایی], [مناسب]), // )) #let test_result_table(cols) = { block( breakable: false, align(center, table( columns: (auto,) * (cols.first().len()), inset: 8pt, stroke: 0.5pt, fill: (x, y) => if y == 0 { luma(230) }, ..cols.flatten(), )), ) } // Renders a level-3 heading + result table as a non-breakable unit. // Usage: // #pigment_result_block("پیگمنت زرد", ( // ([*معیار*], [*CLCE-539/1*]), // ([کیفیت سطح], [خوب]), // ([نتیجه نهایی], [نامناسب]), // )) #let pigment_result_block(name, rows) = { block(breakable: false)[ === #name #test_result_table(rows) ] } // Renders a standalone pigment info block (no heading). // Use inside a sample_section for additional codes under the same heading, // or alone when a group shares a heading. // Usage: // #sample_entry("CLCE-539/4", "PI-BG32", "5") #let sample_entry(supplier_code, internal_code, document_no) = { grid( columns: (auto, auto), inset: 10pt, [- کد تأمین کننده:], [#supplier_code], [- کد داخلی], [#internal_code], [- شماره سند:], [#document_no], ) } // Renders a level-3 heading + pigment info block as a non-breakable unit. // Use for each pigment group in the received samples section. // Usage: // #sample_section("پیگمنت زرد", "CLCE-539/1", "PI-Y36", "2") #let sample_section(title, supplier_code, internal_code, document_no) = { block(breakable: false)[ === #title #sample_entry(supplier_code, internal_code, document_no) ] } // Renders the general report information table. // Usage: // #general_info_table( // "۱۴۰۵/۰۱/۱۷", // "۱۴۰۵/۰۱/۲۴", // "پیگمنت", // "۹", // "Esmaltes", // ) #let general_info_table( 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], )), ) } // 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*], )), ) } // Renders the received samples as a structured table. // Each row should contain: // (pigment_name, supplier_code, internal_code, document_no) #let received_samples_table(rows) = { block( breakable: false, align(center, table( columns: (auto, auto, auto, auto), align: right, stroke: 0.5pt, inset: 7pt, fill: (x, y) => if y == 0 { luma(235) }, [*نوع پیگمنت*], [*کد تأمین کننده*], [*کد داخلی*], [*شماره سند*], ..rows.flatten(), )), ) }