commit df5c53727cbcbf18070f1710a0e9918530dccab1 Author: Waldo Date: Sun Nov 9 12:56:49 2025 +0100 Initial Tinkering diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..74bd862 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": "Development - Win64" +} \ No newline at end of file diff --git a/chemex.typ b/chemex.typ new file mode 100644 index 0000000..1085c86 --- /dev/null +++ b/chemex.typ @@ -0,0 +1,203 @@ +#import "@preview/typsium-ghs:0.1.0": * +#import "@preview/one-liner:0.2.0": fit-to-width +#import "@preview/subpar:0.2.2" + + +#let repeated-table(num-repeats: 2, ..args) = { + let options = args.named() + let data = args.pos() + + // STEP 1: transform table options to apply to a multiple of the original columns + + let columns = options.at("columns", default: ()) + let (column-count, columns) = if type(columns) == int { + // for numbers, that's number of columns + (columns, columns * num-repeats) + } else if type(columns) == array and columns != () { + // for arrays with elements, the number of elements is number of columns + (columns.len(), columns * num-repeats) + } else { + // lengths, auto or an empty array mean there's one column + (1, (auto,) * num-repeats) + } + options.columns = columns + + // TODO transform other per-column fields, such as align + + // STEP 2: separate header and footer from the table body, with repeated cells + + let header = if data.len() > 0 and type(data.first()) == content and data.first().func() == table.header { + let (children, ..args) = data.remove(0).fields() + table.header(..args, ..children * num-repeats) + } + + let footer = if data.len() > 0 and type(data.last()) == content and data.last().func() == table.footer { + let (children, ..args) = data.pop().fields() + table.footer(..args, ..children * num-repeats) + } + + // STEP 3: rearrange the data, so that after a number of rows the next repetition begins + + // split into rows + let rows = data.chunks(column-count) + // split into repeats of rows + let num-rows = calc.ceil(rows.len() / num-repeats) + let repeats = rows.chunks(num-rows) + // pad the last repeat so that all have the same number of rows + let empty-row = (none,) * column-count + repeats.last() += (empty-row,) * (num-rows - repeats.last().len()) + // join repeats into combined rows + let rows = array.zip(..repeats) + // combine into flat data + data = rows.flatten() + + // STEP 4: re-add header and footer to the data + + if header != none { + data.insert(0, header) + } + if footer != none { + data.push(footer) + } + + // STEP 5: produce table + + table(..options, ..data) +} + + +#let my-subfig(..args) = subpar.grid( + + show-sub-caption: (num, it) => { + set text(size: 7pt) + text(weight: "bold", num) + it.body + }, + ..args +) + +// Define your image paths +#let image_paths = ( + "figures/dummy.jpg", + "figures/dummy.jpg", +) + +#let step_image_paths = ( + "figures/dummy.jpg", + "figures/dummy.jpg", + "figures/dummy.jpg", + +) + +#let step_descriptions = ( + "Essen sie alle Kinder", + "Essen sie alle Fische", + lorem(20), + +) + + + +// NOTE: For Linebreaks, use \n in the text +#let amounts = ("500g", 2, 7, 6, 7, 2, 2, 7, 6, 7, 2) +#let material_names = ("Heißkleber", "Watteschen", "Plastic", "Wattestäbchen", "Wattestäbchen", "Watteschen", "Plastic", "Wattestäbchen", "Wattestäbchen","Heißkleber","Heißkleber","Heißkleber","Heißkleber","Heißkleber") // user input + +#let tablecolumns = calc.ceil(amounts.len() / 6) + +#let materials = material_names.map(name => text(name)) + + +#let has_images = step_image_paths.any(path => path != "" and path != "none") + +#let step_image_size = 4cm + + +#let steps = step_descriptions.enumerate().map(((i, desc)) => { + let img = if i < step_image_paths.len() { step_image_paths.at(i) } else { "none" } + grid( + columns: if has_images { (step_image_size, auto) } else { (auto) }, + inset: (0pt, 0pt), + if img != "none" { + pad(right: 10pt, image(img)) + } else { + none + }, + pad(bottom: 0.2cm, text("Schritt " + str(i+1) + ":\n" + desc)), + v(0.2cm) + ) +}) + + +#let figures = image_paths.map(path => image(path)) + +//title and hazard + +#grid( + columns: (0.7fr, 1fr), + align: (horizon, right+horizon), + stroke: (bottom:0.7pt + black), + inset: (5pt), + par( + text("Methan-Mamba", size: 22pt)), + grid( + columns: 9, + rows: 30pt, + ..range(1,10).map(x=> ghs(x)) + ) +) + +// Materials and Overview + +#show table.cell: set text(size: 9pt) +#grid( + columns: (auto, 1fr), + stroke: (bottom:0.7pt + black), + inset: (5pt), + grid( + rows: (auto), + text("Material", weight: "bold"), + v(0.4cm), + repeated-table( + num-repeats: tablecolumns, + stroke: (_, y) => if y > 0 { (top: 0.3pt) }, + columns: (auto, auto), + inset: 6pt, + align: (right, left), + ..for x in amounts.zip(material_names) {( + ..for y in x {( + [#y], + )} + )} +) + + ), + grid( + text("Übersicht", weight: "bold"), + v(0.4cm), + my-subfig( + ..figures, + columns: (auto, auto), + ), + v(0.1cm) + ), + ) + +// Durchführung +#grid( + columns: (1fr), + stroke: (bottom:0.7pt + black), + inset: (5pt), + grid( + rows: (auto), + text("Durchführung", weight: "bold"), + v(0.4cm), + ..steps + ), +) + +// Safety Notices + + + +// Interpretation + diff --git a/figures/dummy.jpg b/figures/dummy.jpg new file mode 100644 index 0000000..56f9403 Binary files /dev/null and b/figures/dummy.jpg differ diff --git a/refs.bib b/refs.bib new file mode 100644 index 0000000..e69de29