repo
stringlengths
26
115
file
stringlengths
54
212
language
stringclasses
2 values
license
stringclasses
16 values
content
stringlengths
19
1.07M
https://github.com/darkMatter781x/OverUnderNotebook
https://raw.githubusercontent.com/darkMatter781x/OverUnderNotebook/main/entries/auton/close-awp/close-awp.typ
typst
#import "../auto-util.typ": * #auton( "Close Autonomous Win Point", datetime(year: 2024, month: 2, day: 25), "defensive.cpp", [AWP for the close side requires that we remove the matchload zone triball and touch the horizontal elevation bar. This is the code that accomplishes that.], )[ ```cpp void runDefensive() { // front right corner of the drivetrain aligned with the inside of the puzzling facing right Robot::chassis->setPose( {MIN_X + TILE_LENGTH + Robot::Dimensions::drivetrainLength / 2, MIN_Y + TILE_LENGTH - Robot::Dimensions::drivetrainWidth / 2, RIGHT}, false); // back up to get in better position to remove the matchload zone triball Robot::chassis->moveToPoint( MIN_X + TILE_LENGTH, MIN_Y + TILE_LENGTH - Robot::Dimensions::drivetrainWidth / 2, 2000, { .forwards = false, .maxSpeed = 72, }); Robot::chassis->waitUntilDone(); // turn to be parallel with matchload barrier Robot::chassis->turnTo(1000000, -1000000, 2000, true, 48); Robot::chassis->waitUntilDone(); // let wing expand Robot::Actions::expandBackWing(); pros::delay(500); // remove the matchload zone triball Robot::chassis->turnTo(1000000, 0, 2000); Robot::chassis->waitUntilDone(); // let ball roll away pros::delay(1000); // retract wing so it doesn't get in the way Robot::Actions::retractBackWing(); // intake any straggler triballs Robot::Actions::intake(); // touch horizontal elevation bar Robot::chassis->moveToPose(0 - Robot::Dimensions::drivetrainLength / 2 - 3.5, MIN_Y + TILE_RADIUS, RIGHT, 2000); // if a triball enters the intake, outtake it while (pros::competition::is_autonomous()) { if (isTriballInIntake()) { Robot::Actions::outtake(); pros::delay(500); } pros::delay(10); } } ``` ]
https://github.com/TypstApp-team/typst
https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/layout/page-margin.typ
typst
Apache License 2.0
// Test page margins. --- // Set all margins at once. #[ #set page(height: 20pt, margin: 5pt) #place(top + left)[TL] #place(bottom + right)[BR] ] --- // Set individual margins. #set page(height: 40pt) #[#set page(margin: (left: 0pt)); #align(left)[Left]] #[#set page(margin: (right: 0pt)); #align(right)[Right]] #[#set page(margin: (top: 0pt)); #align(top)[Top]] #[#set page(margin: (bottom: 0pt)); #align(bottom)[Bottom]] // Ensure that specific margins override general margins. #[#set page(margin: (rest: 0pt, left: 20pt)); Overridden]
https://github.com/maxgraw/bachelor
https://raw.githubusercontent.com/maxgraw/bachelor/main/apps/document/src/0-base/listing.typ
typst
#set heading(numbering: none, supplement: [Abschnitt]) = Listing #outline( title: none, target: figure.where(kind: raw), ) #pagebreak()
https://github.com/pncnmnp/typst-poster
https://raw.githubusercontent.com/pncnmnp/typst-poster/master/examples/example_2_column_18_24.typ
typst
MIT License
#import "../poster.typ": * #show: poster.with( size: "18x24", title: "A typesetting system to untangle the scientific writing process", authors: "<NAME>, <NAME>, <NAME>, <NAME>", departments: "Department of Computer Science", univ_logo: "./images/ncstate.png", footer_text: "Conference on Typesetting Systems, 2000", footer_url: "https://www.example.com/", footer_email_ids: "<EMAIL>", footer_color: "ebcfb2", // Use the following to override the default settings // for the poster header. num_columns: "2", univ_logo_scale: "100", title_font_size: "34", authors_font_size: "20", univ_logo_column_size: "4", title_column_size: "10", footer_url_font_size: "15", footer_text_font_size: "24", ) = #lorem(3) #lorem(100) #figure( image("../images/Women_operating_typesetting_machines.png", width: 50%), caption: [#lorem(10)] ) #lorem(60) = #lorem(2) #lorem(30) + #lorem(10) + #lorem(10) + #lorem(10) #lorem(50) #set align(center) #table( columns:(auto, auto, auto), inset:(10pt), [#lorem(4)], [#lorem(2)], [#lorem(2)], [#lorem(3)], [#lorem(2)], [$alpha$], [#lorem(2)], [#lorem(1)], [$beta$], [#lorem(1)], [#lorem(1)], [$gamma$], [#lorem(2)], [#lorem(3)], [$theta$], ) #set align(left) #lorem(80) $ mat( 1, 2, ..., 8, 9, 10; 2, 2, ..., 8, 9, 10; dots.v, dots.v, dots.down, dots.v, dots.v, dots.v; 10, 10, ..., 10, 10, 10; ) $ == #lorem(5) #lorem(65) #figure( image("../images/Standard_lettering.png", width: 100%), caption: [#lorem(8)] ) = #lorem(3) #block( fill: luma(230), inset: 8pt, radius: 4pt, [ #lorem(80), - #lorem(10), - #lorem(10), - #lorem(10), ] ) #lorem(30)
https://github.com/DashieTM/ost-5semester
https://raw.githubusercontent.com/DashieTM/ost-5semester/main/compiler/weeks/week13.typ
typst
#import "../../utils.typ": * #section("Just in Time Compiler JIT") - faster than interpreter -> obviously - not everything will be compiled usually - only critical parts - so called *hot spots* - code that is run over and over again -> main loop in game #subsection("Profiling") The interpreter keeps track of the amount of times a specific code section is being run. -> Via methods and traces. #align( center, [#image("../../Screenshots/2023_12_11_08_18_23.png", width: 60%)], ) #align( center, [#image("../../Screenshots/2023_12_11_08_18_46.png", width: 60%)], ) #subsection("Intel 64 architecture") - 14 general registers #align( center, [#image("../../Screenshots/2023_12_11_08_19_25.png", width: 60%)], ) #align( center, [#image("../../Screenshots/2023_12_11_08_19_48.png", width: 100%)], ) - special registers #align( center, [#image("../../Screenshots/2023_12_11_08_20_13.png", width: 70%)], ) - media registers -> 64, 128 and 256 bit - floating point registers -> double etc. #subsubsection("Callstack") #align( center, [#image("../../Screenshots/2023_12_11_08_25_36.png", width: 100%)], ) #subsubsection("Mov") #align( center, [#image("../../Screenshots/2023_12_11_08_26_18.png", width: 70%)], ) #subsubsection("Aithmetic Instructions") #align( center, [#image("../../Screenshots/2023_12_11_08_26_39.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_12_11_08_31_43.png", width: 80%)], ) #align( center, [#image("../../Screenshots/2023_12_11_08_32_38.png", width: 70%)], ) #subsubsection("Jumps") #align( center, [#image("../../Screenshots/2023_12_11_09_16_57.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_12_11_09_17_57.png", width: 100%)], ) #subsection("Conversion") #align( center, [#image("../../Screenshots/2023_12_11_08_40_02.png", width: 70%)], ) #align( center, [#image("../../Screenshots/2023_12_11_08_40_16.png", width: 70%)], ) #subsection("Local and Global Registers") - local - evaluation stack - display evaluation stack entries in registers -> register stack - global - save variables in registers - faster than memory access #subsection("Allocation Record") - parameters are stored within registers - first 4 parameters for winshit: RCS, RDX, R8, R9 - first 6 parameters for unix: RDI, RSI, RDX, RCX, R8, R9 #align( center, [#image("../../Screenshots/2023_12_11_09_18_31.png", width: 40%)], ) #align(center, [ #text(red)[load variable] #image("../../Screenshots/2023_12_11_09_18_46.png", width: 100%) ]) #align(center, [ #text(red)[relocate variable] #image("../../Screenshots/2023_12_11_09_19_34.png", width: 100%) ]) #text(red)[JIT] #align( center, [#image("../../Screenshots/2023_12_11_09_19_49.png", width: 60%)], ) ```cs switch (opCode) { // ... case LDC: var target = Acquire(); var value = (int)instruction.Operand; assembler.MOV_RegImm(target, value); Push(target); break; case LOAD: var index = (int)instruction.Operand; /* if parameter index */ reg = allocation.Parameters[index – 1]; Push(reg); break; case STORE: var source = Pop(); var target = allocation.Locals[index-1-nofParams]; assembler.MOV_RegReg(target, source); Release(source); break; case ISUB: var operand2 = Pop(); var operand1 = Pop(); var result = Acquire(); assembler.MOV_RegReg(result, operand1); assembler.SUB_RegReg(result, operand2); Release(operand1); Release(operand2); Push(result); break; case IDIV: Reserve(RAX); Reserve(RDX); ForceStack(1, RAX); var operand2 = Pop(); Pop(); // is RAX assembler.CDQ(); assembler.IDIV(operand2); Push(RAX); Release(operand2); Release(RDX); break; // ... } ``` #subsubsection("Allocation matching") One problem is that different branches might want to use different registers, in that case you might need to move values to these registers: #align( center, [#image("../../Screenshots/2023_12_11_09_32_41.png", width: 100%)], ) #align( center, [#image("../../Screenshots/2023_12_11_09_32_53.png", width: 100%)], ) ```cs switch (opCode) { case if_true: var offset = (int)instruction.Operand; var target = code[position + 1 + offset]; var label = labels[target]; matchAllocation(label); if (previous == CMPEQ) { assembler.JE_Rel(label); } break; // ... } ``` #subsubsection("Register runout") When using JIT, you might run into the issue of running out of registers, solutions include pushing temporary values to the stack and pushing local variables and parameters to the stack.
https://github.com/valentinvogt/npde-summary
https://raw.githubusercontent.com/valentinvogt/npde-summary/main/src/setup.typ
typst
#import "@preview/physica:0.9.3": eval, Order, Set #import "boxes.typ": * #import "@preview/natrix:0.1.0": * #import "colors.typ": * #let neq(content) = math.equation( block: true, numbering: "(1)", content, ) #let colMath(x, color) = text(fill: color)[$#x$] #let accentcolor = rgb(255, 0, 255) #let unimportant = ( fill: unimportant-color, stroke: gray + 1.5pt ) // Bold math for vectors #let ba = $ bold(a) $ #let bm = $ bold(m) $ #let bx = $ bold(x) $ #let bu = $ bold(u) $ #let bv = $ bold(v) $ #let bw = $ bold(w) $ #let bA = $ bold(A) $ #let balpha = $ bold(alpha) $ #let bmu = $ bold(mu) $ #let bH = $ bold(H) $ #let jac = $ upright("D") $ // Wider hat #let mhat = content => $ hat(content, size: #140%)$ #let Khat = $ hat(K, size: #120%)$ #let bxhat = $ hat(bx) $ #let msh = $ cal(M) $ #let grad = $bold("grad")thin $ #let gradsub = content => $bold("grad"_(#content)) $ #let div = $"div"thin $ #let openint(a,b) = $lr(\] #a, #b \[)$ #let fvH = $bold(cal(H))$ #let curl = $bold("curl")thin $ #let recop = $upright("R")_M arrow(bmu)$ #let eps = $epsilon.alt$ #let argmin = math.op("arg min", limits: true) #let argmax = math.op("arg max", limits: true) #let this-template(doc) = [ #show: thmrules #show link: set text(fill: link-color) #show ref: it => { let eq = math.equation let el = it.element if el != none and el.func() == eq { // Override equation references. link( it.at("target"), numbering(el.numbering, ..counter(eq).at(el.location())), ) [] } else { it } } #set page(numbering: "1") #set text(text-color) #set page(fill: page-color) #doc ]
https://github.com/mangkoran/utm-thesis-typst
https://raw.githubusercontent.com/mangkoran/utm-thesis-typst/main/04_declaration_cooperation.typ
typst
MIT License
#import "@preview/tablex:0.0.7": tablex, colspanx #import "utils.typ": empty #let content( parties: ( empty[party 1], empty[party 2], ) ) = [ #align(center)[ #upper[*Declaration of Cooperation*] ] #align(horizon)[ This is to confirm that this research has been conducted through a collaboration between #for i in range(parties.len()) { if parties.len() == 0 { panic("parties cannot be zero") } else if i == parties.len() - 1 { [and #parties.at(i)] } else if parties.len() == 2 { [#parties.at(i) ] } else { [#parties.at(i), ] } } #tablex( auto-lines: false, columns: (auto, 1fr), [Certified by], [:], colspanx(2)[], (), colspanx(2)[], (), colspanx(2)[], (), [Signature], [:], colspanx(2)[], (), colspanx(2)[], (), colspanx(2)[], (), [Name], [:], [Position], [:], [Official Stamp], [:], colspanx(2)[], (), colspanx(2)[], (), colspanx(2)[], (), [Date], [: #datetime.today().display()], colspanx(2)[], (), colspanx(2)[], (), colspanx(2)[], (), ) ] #align(bottom)[ \*This section is to be filled up for theses with industrial collaboration ] #pagebreak(weak: true) ] #content()
https://github.com/freundTech/typst-matryoshka
https://raw.githubusercontent.com/freundTech/typst-matryoshka/main/README.md
markdown
MIT License
# matryoshka Matryoshka is a Typst package that allows you to compile Typst code to images from within Typst. This is especially useful for package authors that want to generate manuals with examples. ## Usage For usage instructions see the [documentation](https://raw.githubusercontent.com/freundTech/typst-matryoshka/main/doc/matryoshka.pdf)
https://github.com/ern1/typiskt
https://raw.githubusercontent.com/ern1/typiskt/main/templates/cover-letter.typ
typst
// This template is a work in progress #let cover-letter( // Name and descriptive title of ? firstName: none, lastName: none, phone: none, email: none, description: none, company: none, date: none, // main content body ) = { set document( title: "Cover letter", author: firstName + " " + lastName ) set text(font: "Source Sans Pro", size: 12pt) show heading.where(level: 1): set text(font: "Roboto", size: 24pt) show heading.where(level: 2): set text(size: 16pt) set align(right) [ == #firstName #lastName //#v(-0.5em) #link("tel:" + phone.trim(" "), phone) #emoji.phone \ //#h(1em)\ #link("tel:" + email, email) #emoji.mail ] v(1em) set align(left) [ //set text(size: 16pt, weight: "bold", fill: black) = #description #text(font: "Roboto", fill: rgb("#6934FF"), size: 14pt)[#company] #if date != none [ #date.display() ] else [ #datetime.today(offset: 1).display() ] #v(1em) ] { // Todo: add something here? body } }
https://github.com/Hobr/njust_thesis_typst_template
https://raw.githubusercontent.com/Hobr/njust_thesis_typst_template/main/README.md
markdown
MIT License
# 南京理工大学Typst论文模板 Work in Progress.... ## 使用 ### 推荐安装 - [Typst](https://github.com/typst/typst) - LSP: [Tinymist](https://github.com/Myriad-Dreamin/tinymist) - 格式: [Typstyle](https://github.com/Enter-tainer/typstyle) ## 计划 - [x] 谢国森老师公选论文课程 2023-2024第二学期标准 - [ ] 本科科研训练 2022级标准 - [ ] 本科毕业设计/论文 标准: [2023-10-17发布版本](http://bysj.njust.edu.cn/NewsDetail.aspx?ConfigurationID=n5IuBXqj3nE%3d&HomePageManagementID=IdcFBHw1Yn0%3d) ## 感谢 - [jiec827/njustThesis](https://github.com/jiec827/njustThesis) - [modern-nju-thesis](https://github.com/nju-lug/modern-nju-thesis) - [SHU-Bachelor-Thesis-Typst](https://github.com/shuosc/SHU-Bachelor-Thesis-Typst) - [typst-doc-cn](https://typst-doc-cn.github.io/)
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/show-node-10.typ
typst
Other
// Error: 16-20 expected content or function, found integer #show heading: 1234 = Heading
https://github.com/mkpoli/ipsj-typst-template
https://raw.githubusercontent.com/mkpoli/ipsj-typst-template/master/lib/number.typ
typst
#let n(num, thousands: ",", decimal: ".") = { let parts = str(num).split(".") let decimal_part = if parts.len() == 2 { parts.at(1) } let integer_part = parts.at(0).rev().clusters().enumerate() .map((item) => { let (index, value) = item return value + if calc.rem(index, 3) == 0 and index != 0 { thousands } }).rev().join("") return integer_part + if decimal_part != none { decimal + decimal_part } } #let d = n.with(decimal: ".", thousands: ",") // English Style #let c = n.with(decimal: ",", thousands: ".") // Continental Style #let s = n.with(decimal: ".", thousands: " ") // SI Style (English) #let f = n.with(decimal: ",", thousands: " ") // SI Style (French) #for x in (1.2, 65536, 3800.25) { [ *#x* \ #raw("d" + "(" + str(x) + ")") = #d(x) \ #raw("c" + "(" + str(x) + ")") = #c(x) \ #raw("f" + "(" + str(x) + ")") = #s(x) \ #raw("s" + "(" + str(x) + ")") = #f(x) \ \ ] }
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/layout/align-05.typ
typst
Other
// Error: 8-20 cannot add two vertical alignments #align(top + bottom, [A])
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/cetz-plot/0.1.0/src/plot/formats.typ
typst
Apache License 2.0
// Compare two floats #let _compare(a, b, eps: 1e-6) = { return calc.abs(a - b) <= eps } // Pre-computed table of fractions #let _common-denoms = range(2, 11 + 1).map(d => { (d, range(1, d).map(n => n/d)) }) #let _find-fraction(v, denom: auto, eps: 1e-6) = { let i = calc.floor(v) let f = v - i if _compare(f, 0, eps: eps) { return $#v$ } let denom = if denom != auto { for n in range(1, denom) { if _compare(f, n/denom, eps: eps) { denom } } } else { (() => { for ((denom, tab)) in _common-denoms { for vv in tab { if _compare(f, vv, eps: eps) { return denom } } } })() } if denom != none { return if v < 0 { $-$ } else {} + $#calc.round(calc.abs(v) * denom)/#denom$ } } /// Fraction tick formatter /// /// ```example /// plot.plot(size: (5,1), /// x-format: plot.formats.fraction, /// x-tick-step: 1/5, /// y-tick-step: none, { /// plot.add(calc.sin, domain: (-1, 1)) /// }) /// ``` /// /// - value (number): Value to format /// - denom (auto, int): Denominator for result fractions. If set to `auto`, /// a hardcoded fraction table is used for finding fractions with a /// denominator <= 11. /// - eps (number): Epsilon used for comparison /// -> Content if a matching fraction could be found or none #let fraction(value, denom: auto, eps: 1e-6) = { return _find-fraction(value, denom: denom, eps: eps) } /// Multiple of tick formatter /// /// ```example /// plot.plot(size: (5,1), /// x-format: plot.formats.multiple-of, /// x-tick-step: calc.pi/4, /// y-tick-step: none, { /// plot.add(calc.sin, domain: (-calc.pi, 1.5 * calc.pi)) /// }) /// ``` /// /// - value (number): Value to format /// - factor (number): Factor value is expected to be a multiple of. /// - symbol (content): Suffix symbol. For `value` = 0, the symbol is not /// appended. /// - fraction (none, true, int): If not none, try finding matching fractions /// using the same mechanism as `fraction`. If set to an integer, that integer /// is used as denominator. If set to `none` or `false`, or if no fraction /// could be found, a real number with `digits` digits is used. /// - digits (int): Number of digits to use for rounding /// - eps (number): Epsilon used for comparison /// - prefix (content): Content to prefix /// - suffix (content): Content to append /// -> Content if a matching fraction could be found or none #let multiple-of(value, factor: calc.pi, symbol: $pi$, fraction: true, digits: 2, eps: 1e-6, prefix: [], suffix: []) = { if _compare(value, 0, eps: eps) { return $0$ } let a = value / factor if _compare(a, 1, eps: eps) { return prefix + symbol + suffix } else if _compare(a, -1, eps: eps) { return prefix + $-$ + symbol + suffix } if fraction != none { let frac = _find-fraction(a, denom: if fraction == true { auto } else { fraction }) if frac != none { return prefix + frac + symbol + suffix } } return prefix + $#calc.round(a, digits: digits)$ + symbol + suffix } /// Scientific notation tick formatter /// /// ```example /// plot.plot(size: (5,1), /// x-format: plot.formats.sci, /// x-tick-step: 1e3, /// y-tick-step: none, { /// plot.add(x => x, domain: (-2e3, 2e3)) /// }) /// ``` /// /// - value (number): Value to format /// - digits (int): Number of digits for rounding the factor /// - prefix (content): Content to prefix /// - suffix (content): Content to append /// -> Content #let sci(value, digits: 2, prefix: [], suffix: []) = { let exponent = if value != 0 { calc.floor(calc.log(calc.abs(value), base: 10)) } else { 0 } let ee = calc.pow(10, calc.abs(exponent + 1)) if exponent > 0 { value = value / ee * 10 } else if exponent < 0 { value = value * ee * 10 } value = calc.round(value, digits: digits) if exponent <= -1 or exponent >= 1 { return prefix + $#value times 10^#exponent$ + suffix } return prefix + $#value$ + suffix } /// Rounded decimal number formatter /// /// ```example /// plot.plot(size: (5,1), /// x-format: plot.formats.decimal, /// x-tick-step: .5, /// y-tick-step: none, { /// plot.add(x => x, domain: (-1, 1)) /// }) /// ``` /// /// - value (number): Value to format /// - digits (int): Number of digits to round to /// - prefix (content): Content to prefix /// - suffix (content): Content to append /// -> Content #let decimal(value, digits: 2, prefix: [], suffix: []) = { prefix + $#calc.round(value, digits: digits)$ + suffix }
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/anatomy/0.1.1/export.typ
typst
Apache License 2.0
#import "lib.typ": metrics // Samples in README #let samples = ( ( content: metrics( 72pt, "EB Garamond", display: "Typewriter" ), caption: "The metrics of EB Garamond (Google Fonts)" ), ( content: metrics( 54pt, "一點明體", display: "電傳打字機", use: metrics => table( columns: 2, ..metrics.pairs().flatten().map(x => [ #x ]) ) ), caption: "The metrics of I.Ming (table attached)" ), ( content: metrics( 54pt, "Hiragino Mincho ProN", display: "テレタイプ端末" ), caption: "The metrics of Hiragino Mincho ProN" ) ).map(it => figure( it.content, caption: it.caption )) #set page( fill: white, width: 420pt, margin: 0pt ) // Sample 1 // Fit the page with exact same size of metrics #set page(height: 124.35pt) #style(styles => { let content = pad( y: 8pt, samples.at(0) ) [ #content // #measure(content, styles).height ] }) // Sample 2 #set page(height: 179.59pt) #style(styles => { let content = pad( y: 8pt, samples.at(1) ) [ #content // #measure(content, styles).height ] }) // Sample 3 #set page(height: 84.39pt) #style(styles => { let content = pad( y: 8pt, samples.at(2) ) [ #content // #measure(content, styles).height ] })
https://github.com/satshi/typst-jp-template
https://raw.githubusercontent.com/satshi/typst-jp-template/main/example.typ
typst
// 今のところjarticleとappendixを定義している。 #import "template.typ": * //オプションはfontsize, title, authors, date, abstract #show: doc => jarticle( fontsize: 11pt, title: [格子ゲージ理論の面積則の演習問題], authors: ([山口 哲(大阪大学)],), date: datetime.today().display(年月日), abstract: [ここでは、簡単な格子ゲージ理論で強結合展開を考え、Wilsonループが面積則を示すことを見ることを確かめる。このことから、格子ゲージ理論では強結合で閉じ込め相にあることが分かる。], doc, ) //// むしろ次のようにオプション無しで呼んでタイトルなどは必要なら自分で書くことを想定している。 // #show: jarticle // #set align(center) // #text(17pt)[*格子ゲージ理論の面積則の演習問題*] // 山口哲(大阪大学) // #datetime.today().display(年月日) // #text(9pt,[ // *概要* // #block(width: 90%)[#align(left, // [ここでは、簡単な格子ゲージ理論で強結合展開を考え、Wilsonループが面積則を示すことを見ることを確かめる。このことから、格子ゲージ理論では強結合で閉じ込め相にあることが分かる。] // )] // ]) // #set align(left) // expvalというコマンドを使うため。 #import "@preview/physica:0.9.2": expval #outline() = 問題 == 考える系 講義の最後の方に扱った$ℤ_2$ゲージ理論のについて考えよう。この理論は4次元の超立方格子の各リンク$ℓ$に$a_ℓ = 0 , 1$の自由度をおいたもので、その作用は$K$を定数として $ S (a) = - K ∑_(p ": plaquettes") (- 1)^(∑_(ℓ ∈ p) a_ℓ) $ である。ただし、$∑_(ℓ ∈ p)$はplaquette $p$を構成する4つのリンクについての和を表している。この理論の分配関数は $ Z = 1 / 2^V ∑_({a}) e^(- S (a) ) quad (V "は頂点の数") $ である。 == Wilsonループ この理論のWilsonループを考えよう。リンクを繋いでいってできるループ$C$に対してWilsonループ$W (C)$が定義され、その期待値は $ expval(W(C)) = 1/Z 1/2^V ∑_{a} e^(-S(a)) (-1)^(∑_(ℓ ∈ C)a_ℓ) $ と表される。 $K ≪ 1$の場合、このWilsonループの期待値が「面積則」になることを次のようにして示せ。 簡単のため、ループ$C$を12平面上で辺の長さが $L_1 , L_2$ の長方形に取る。長さの単位は格子間隔が $1$ となるようにとることにする。$expval(W(C))$を$K$でべき展開し、$0$ にならない最低次を見ることにより、$L_1 , L_2$依存性が $ expval(W(C)) ∼ exp(- T L_1 L_2) $ となることを示せ。また定数 $T$ を求めよ。 == ヒント 書籍@Creutz:1983njd, @Rothe:1992nt, @AokiLatticeBook や他の文献で、ゲージ群がSU$(N)$ (SU$(3)$)の場合の解説がある。これらの文献では群の積分の公式を導いて用いている。今回考えたモデルのように、ゲージ群が $ℤ_2$ の場合には、代わりに必要な公式は $b = 0, 1$ として $∑_(a = 0 , 1) (- 1)^(a b)$ がどうなるかというものである。 //ここから付録 #show: appendix = 解説 == 分配関数 $ S (a) = - K ∑_(p ": plaquettes") (- 1)^(∑_(ℓ in p) a_ℓ) $ として、分配関数は $ Z = 1 / 2^V ∑_({ a }) e^(- S lr((a))) , $<pf> Wilsonループの期待値は $ expval(W (C)) = 1/Z 1/2^V ∑_({a}) e^(-S(a)) (-1)^(∑_(ℓ in C)a_(ℓ)) $<wl> と表される。これらを$K ≪ 1$の場合に$K$でべき展開し、その最低次を考える。 まず、分配関数は $ Z = 1 / 2^V ∑_({ a }) (1 + O (K)) = 2^(E - V) + O (K) $ となる。ここで$E$はリンクの数である。 == Wilsonループ 次にWilsonループの期待値 @wl の和について考える。$e^(- S (a))$を展開すると各項は$(- 1)^(a_ℓ)$の単項式になる。このとき、あるリンク$ℓ$に対して$(- 1)^(a_ℓ)$を非自明に因子に持つ項があったとすると、$∑_(a_ℓ = 0 , 1) (- 1)^(a_ℓ) = 0$となるために、その項からの寄与は$0$になってしまう。したがって、残る項はすべてのリンクに対して$(- 1)^(a_ℓ)$が偶数回入っているものである。その中で$K$の最低次の項は、@area のように作用から来るplaquettesがWilsonループを端に持つ最小面積の面を埋め尽くすものである。これは$A := L_1 L_2$個のplaquettesが入っているので、$K^A$に比例する項である。 ここまでで@wl の$0$でない最低次の項は$K^A$であることが分かったので、その項を計算していく。 $ expval(W (C)) &=1/Z 1/2^V ∑_({a}) (K^A)/(A!) ( ∑_p (-1)^(∑_(m in p) a_(m)))^A (-1)^(∑(ℓ in C) a_ℓ) + O(K^(A+1)) \ &=1/Z 1/2^V ∑_({a})K^A + O(K^(A+1)) \ &=K^A + O (K^(A+1)) tilde exp(-(- log K) A). $<result> ただし、一行目から二行目へは$(dots.h.c)^A$の展開で、面をきっちり埋め尽くすような項が$A !$項あり、それぞれがWilsonループからの寄与を合わせて$1$であることを用いた。また二行目から三行目へは分配関数の結果 @pf を用いた。 @result は面積則を示していて、$T = - log K$である。 #figure( [#box(width: 8cm, image("area.svg"))], caption: [Wilsonループの期待値への$0$でない$K$の最低次の寄与。赤線、黒線はともにリンク変数の$lr((- 1))^(a_ℓ)$寄与があることを表す。赤線はWilsonループの挿入から、黒線は作用からの寄与を表す。すべてのリンクに関して線は偶数個(0または2)になっているので$(- 1)^(a_ℓ)$の寄与はキャンセルしている。作用からのplaquettesは$A := L_1 L_2$個ある。], ) <area> #bibliography( // title: none, style: "american-physics-society", "ref.bib")
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/layout/pad-01.typ
typst
Other
// Pad can grow. #pad(left: 10pt, right: 10pt)[PL #h(1fr) PR]
https://github.com/wenjia03/JSU-Typst-Template
https://raw.githubusercontent.com/wenjia03/JSU-Typst-Template/main/Templates/实验报告(无框)/template/toc.typ
typst
MIT License
#import "../utils/style.typ": * #set page(footer: [ #set align(center) #set text(size: 10pt, baseline: -3pt) #counter(page).display( "I", ) ] ) // 目录 #v(1em) #align(center)[ #text(font: 字体.宋体, size: 字号.三号, "目 录") ] #parbreak(); #show outline: it => { set text(font: 字体.宋体, size: 字号.小四) set par(leading: 1em ) it } #outline( title: none, indent : true, )
https://github.com/MilanR312/ugent_typst_template
https://raw.githubusercontent.com/MilanR312/ugent_typst_template/main/template/methods/globals.typ
typst
MIT License
//#let default_fontsize = 11pt; #let default_font = "STIX Two Text" #let default_fontsize = 12pt //#let default_font = "Garamond" #let ublue = rgb(30, 100, 200) #let parlead = 0.75em
https://github.com/mem-courses/linear-algebra
https://raw.githubusercontent.com/mem-courses/linear-algebra/main/homework/linear-algebra-homework7.typ
typst
#import "../template.typ": * #show: project.with( title: "Linear Algebra Homework #7", authors: ( (name: "<NAME> (#95)", email: "<EMAIL>", phone: "3230104585"), ), date: "November 9, 2023", ) #let AA = math.bold("A") #let BB = math.bold("B") #let CC = math.bold("C") #let EE = math.bold("E") #let OO = math.bold("O") #let TT = math.upright("T") #let alpha = math.bold(math.alpha) #let beta = math.bold(math.beta) = P73 习题三 52 #prob[ 已知 $a$ 是常数,且矩阵 $AA = display(mat(1,2,a;1,3,0;2,7,-a))$ 可经初等列变换化为矩阵 $BB = display(mat(1,a,2;0,1,1;-1,1,1))$. (1) 求 $a$. ] 对 $AA$ 应用初等行变换得 $AA -> display(mat(1,2,a;0,1,-a;0,0,0))$;对 $BB$ 应用初等行变换得 $BB -> display(mat(-1,1,1;0,1,1;0,0,2-a))$. 由于 $AA$ 可以通过初等列变换化为 $BB$ 的充要条件是 $AA$ 与 $BB$ 相抵,即 $r(AA) = r(BB) = 2$,故 $a=2$. #prob[(2) 求满足 $bold(A P) = BB$ 的可逆矩阵 $bold(P)$.] 由 (1) 得 $AA = display(mat(1,2,2;0,1,-2;0,0,0)),sp BB=display(mat(1,2,2;0,1,1;-1,1,1))$.TBD = P73 习题三 53 #ac #prob[设矩阵 $AA = display(mat(0,1,0,0;0,0,1,0;0,0,0,1;0,0,0,0))$,求 $AA^3$ 的秩.] $ AA = mat(0,1,0,0;0,0,1,0;0,0,0,1;0,0,0,0) => AA^2 = mat( 0,0,1,0; 0,0,0,1; 0,0,0,0; 0,0,0,0; ) => AA^3 = mat( 0,0,0,1; 0,0,0,0; 0,0,0,0; 0,0,0,0; ) $ 所以 $r(AA^3) = 1$. = P73 习题三 54 #prob[ 设 $AA$ 为 $m times n$ 矩阵,$BB$ 为 $n times m$ 矩阵,$bold(E)$ 为 $m$ 阶单位矩阵.若 $bold(A B)=bold(E)$,则($quad$). (A) 秩 $r(AA)=m$,秩 $r(BB)=m$.\ (B) 秩 $r(AA)=m$,秩 $r(BB)=n$.\ (C) 秩 $r(AA)=n$,秩 $r(BB)=m$.\ (D) 秩 $r(AA)=n$,秩 $r(BB)=n$. ] 选 (A) 项. = P73 习题三 55 #ac #prob[ 设 $AA,BB$ 为 $n$ 阶矩阵,则($quad$) (A) $r(bold(A sp A B)) = r(AA)$\ (B) $r(bold(A sp B A)) = r(AA)$\ (C) $r(bold(A sp B)) = max{r(AA),r(BB)}$\ (D) $r(bold(A sp B)) = r(AA^TT sp BB^TT)$ ] 选 (A) 项. = P73 习题三 56 #ac #prob[(1) 设 $AA$ 是一个 $n$ 阶方阵,证明:$r(AA)=1$ 当且仅当存在非零列向量 $alpha,beta$ 使得 $AA = bold(alpha beta)^TT$.] $=>$:$AA$ 的所有列向量两两线性相关,设 $AA = vecn(alpha,n)$,设 $alpha_i = k_i alpha_1 sp (i=2,3,dots.c,n)$,则取 $beta^TT = display(mat(1,k_2,k_3,dots.c,k_n))^TT$ 有 $AA = alpha beta^TT$. $arrow.double.l$:$r(AA) = r(alpha beta^TT) <= min{r(alpha), r(beta)} = 1$.若 $r(AA) = 0$ 即 $AA = OO$,则 $alpha,beta$ 中必有一个零向量,与题设矛盾.故 $r(AA) = 1$. #prob[(2) 设 $AA$ 是一个 $n$ 阶方阵且 $r(AA)=1$,证明存在常数 $k$,使得 $AA^2=k AA$ 成立.] 设 $AA = alpha beta^TT$,其中 $alpha,beta$ 非零向量.则: $ AA^2 = (alpha beta^TT)^2 = alpha (beta^TT alpha) beta^TT = (beta^TT alpha) AA $ 则 $k=beta^TT alpha$ 即所求常数. #prob[(3) 设 $AA$ 为一个二阶方阵,证明:如果存在正整数 $l>=2$ 使得 $AA^l = bold(O)$,那么 $AA^2 = bold(O)$.] 讨论 $r(AA)$: 若 $r(AA) = 0$,即 $AA = OO$,则必满足 $AA^l = AA^2 = OO$. 若 $r(AA) = 1$,即不妨令 $AA = display(mat(a,b;0,0))$,其中 $a,b$ 为不全为零的实数,则 $ AA^l = mat(a^l,a^(l-1) b;0,0) = OO => a = 0 and b != 0 $ 故 $AA^2 = display(mat(a^2,a b;0,0)=mat(0,0;0,0))=OO$. 若 $r(AA) =2$,即 $AA$ 是可逆矩阵,则 $forall l in NN_+$,$AA^l$ 均可逆,故不可能 $AA^l = OO$. = P73 习题三 57 #wa #prob[ 设 $AA$ 是一个 $s times n$ 矩阵,证明: (1) 如果 $s<=n$ 且 $r(AA) = s$(此时称矩阵 $AA$ 是行满秩的),那么必有 $n times s$ 矩阵 $BB$ 使得 $AA BB = bold(E)_s$. ] #prob[(2) 如果 $n<=s$ 且 $r(AA)=n$(此时称矩阵 $AA$ 是列满秩的),那么必有 $n times s$ 矩阵 $bold(C)$ 使得 $bold(C A) = bold(E)_n$.] TBD #warn[已纠错到错题本上.] = P74 习题三 58 #ac #prob[设 $m times n$ 矩阵 $bold(A)$ 的秩为 $r$,证明:存在秩为 $r$ 的 $m times r$ 矩阵 $bold(B)$ 和秩为 $r$ 的 $r times n$ 矩阵 $bold(C)$,使得 $bold(A) = bold(B C)$.] 存在可逆矩阵 $bold(P) in PP^(m times m)$ 和可逆矩阵 $bold(Q) in PP^(n times n)$ 使得 $ bold(P) AA bold(Q) = mat(EE_r,;,OO_(m-r,n-r)) = mat(EE_r;O_(m-r,r)) mat(EE_r,OO_(r,n-r)) $ 取 $BB = bold(P)^(-1) display(mat(EE_r,;,OO_(m-r,n-r))),sp CC = display(mat(EE_r;OO_(m-r,r)) mat(EE_r,OO_(r,n-r))) bold(Q)^(-1)$ 则 $AA = BB CC$. = P74 习题三 60 #wa #prob[ 设 $AA$ 为 $n$ 阶矩阵($n>=2$),$AA^*$ 为 $AA$ 的伴随矩阵,证明: $ r(AA^*) = cases( n\,quad& r(AA)=n, 1\,quad& r(AA)=n-1, 0\,quad& r(AA)<=n-2 ) $ ] TBD #warn[已纠错到错题本上.] = P74 习题三 62 #ac #prob[ 设矩阵 $AA$ 是 $n$ 阶幂等矩阵,即 $AA^2=AA$,证明: (1) $r(AA) + r(EE_n-AA) = n$. ] $ r(AA) + r(EE-AA) &<= n+r(AA(EE - AA)) = n+r(AA - AA^2) = n\ r(AA) + r(EE - AA) &>= r(AA + (EE - AA))= r(EE) = n\ $ 夹得 $r(AA) + r(EE - AA) = n$. #prob[(2) 如果 $AA$ 可逆,那么 $AA=EE_n$.] 若 $AA$ 可逆,则两边都左乘 $AA^(-1)$ 得 $EE = AA$,得证. = P74 习题三 63 #ac #prob[设矩阵 $AA,BB,CC$ 均为 $n$ 阶方阵,证明:如果 $AA BB CC = bold(O)$,那么 $ r(AA) + r(BB) + r(CC) <= 2n $] $ &cases( r(AA) + r(BB) <= r(AA BB) + n, r(BB) + r(CC) <= r(BB CC) + n, )\ => &r(AA) + 2 r(BB) + r(CC) <= r(AA BB) + r(BB CC) + 2n <= r(AA BB CC) + r(BB) + 2n = 2n + r(BB)\ => &r(AA) + r(BB) + r(CC) <= 2n $ = P74 习题三 64 #ac #prob[设矩阵 $AA$ 是一个 $n$ 阶方阵,证明 $r(AA^3) + r(AA) >= 2r(AA^2)$.] $ r(AA^3) >= r(AA^2) + r(AA^2) - r(AA) => r(AA^3) + r(AA) >= 2r(AA^2) $ 设分块矩阵 $display(mat(AA,BB;CC,bold(D)))$ 是对称矩阵,且 $bold(AA)$ 可逆,证明:存在可逆矩阵 $bold(P)$,使得 $ bold(P)^TT mat(AA,BB;CC,bold(D)) bold(P) = mat(AA,bold(O);bold(O),bold(D)-CC AA^(-1) BB) $ = P74 补充题三 5 #wa #prob[ 设分块矩阵 $display(mat(AA,BB;CC,bold(D)))$ 是对称矩阵,且 $bold(AA)$ 可逆,证明:存在可逆矩阵 $bold(P)$,使得 $ bold(P)^TT mat(AA,BB;CC,bold(D)) bold(P) = mat(AA,bold(O);bold(O),bold(D)-CC AA^(-1) BB) $ ] 由已知: $ (bold(P)^TT mat(AA,BB;CC,bold(D)) bold(P))^TT = bold(P)^TT mat(AA,BB;CC,bold(D))^TT bold(P) = bold(P)^TT mat(AA,BB;CC,bold(D)) bold(P)\ => mat(AA,bold(O);bold(O),bold(D)-CC AA^(-1) BB) = mat(AA,bold(O);bold(O),bold(D)-CC AA^(-1) BB)^TT = mat(AA^TT,bold(O);bold(O),(bold(D)-CC AA^(-1) BB)^TT) $ 注意到 $AA$ 可逆,故 $AA$ 必定是方阵.否则 $AA$ 必有一行或一列全零,与可逆矛盾. 同时,可得: $ cases( AA = AA^TT, bold(D)-CC AA^(-1) BB = (bold(D)-CC AA^(-1) BB)^TT ) $ 设 $AA in PP^(n times n),sp bold(D) in PP^(m times m)$,则 $BB in PP^(n times m), sp CC in PP^(m times n)$. TBD #warn[已纠错到错题本上.] = P74 补充题三 6 #ac #prob[ 设 $AA,BB$ 分别是 $n times m$ 和 $m times n$ 矩阵,证明: #set math.mat(delim: "|") (1) $display(mat(bold(E)_m,BB;AA,bold(E)_n)) = |bold(E)_n - AA BB| = |bold(E)_m - BB AA|$. #set math.mat(delim: "(") ] #set math.mat(delim: "|") $ mat(bold(E)_m,BB;AA,bold(E)_n) &= mat(EE_m, OO; AA, EE_n- AA BB) &= mat(EE_m) dot mat(bold(E)_n - AA BB) &= mat(bold(E)_n - AA BB) $ 同理可证 $display(mat(bold(E)_m,BB;AA,bold(E)_n)) = display(mat(bold(E)_m - BB AA))$. #set math.mat(delim: "(") #prob[(2) 当 $lambda != 0$ 时,$|lambda bold(E)_n - bold(A B)| = lambda^(n-m) |lambda bold(E)_m - bold(B A)|$.] #set math.mat(delim: "|") $ mat(lambda EE_m,BB;AA,EE_n) = mat(lambda EE_m - AA BB, OO; AA, EE_n) = mat(lambda EE_m, OO; AA, EE_n - 1/lambda AA BB)\ => |lambda EE_m - AA BB| = |lambda EE_m| |EE_n - 1/lambda AA BB| = lambda^(m-n) |lambda EE_n - AA BB| $ #set math.mat(delim: "(") 故原命题得证. = P75 补充题三 8 #ac #prob[ 设 $AA$ 是 $n$ 阶方阵,且 $r(AA) = r$,证明: (1) $AA$ 可表示成 $r$ 个秩为 $1$ 的方阵的和. ] $AA$ 可被可逆矩阵 $bold(P),bold(Q)$ 化为相抵标准形: $ AA = bold(P) mat(EE_r,;,OO_(n-r)) bold(Q) = bold(P) (bold(e)_11 + bold(e)_22 + dots.c + bold(e)_(r r)) +bold(Q) $ 故 $AA$ 可被表示为 $bold(P)bold(e)_(i i)bold(Q) sp (i=1,2,dots.c,r)$ 的和,其中它们的秩都等于 $r(bold(e)_(i i)) = 1$. #prob[(2) 存在一个 $n$ 阶可逆方阵 $bold(P)$,使得 $bold(P A P)^(-1)$ 的后 $n-r$ 个行全为零.] 通过初等行变换对 $AA$ 进行高斯消元,可将 $bold(A)$ 化为一个后 $n-r$ 行全为 $0$ 的方阵 $AA bold(Q)$(其中 $bold(Q)$ 是一个可逆矩阵). 再对 $AA bold(Q)$ 作任意初等列变换,则其后 $n-r$ 行仍全是零.故取 $bold(P)=bold(Q)^(-1)$,可得 $bold(P)AA bold(P)^(-1)$ 的后 $n-r$ 个行全为零. = P75 补充题三 9 #ac #prob[试证明 $PP^(n times n)$ 中任意一个矩阵均可表示为 $PP^(n times n)$ 中的一个可逆矩阵和一个幂等矩阵的乘积.] 设 $r(AA) = r$,则存在可逆矩阵 $bold(P),bold(Q)$ 使得 $ AA = bold(P) mat(EE_r,;,OO_(n-r)) bold(Q) $ 则取: $ cases(bold(B) &= bold(P)bold(Q), bold(C) &= bold(Q)^(-1) display(mat(EE_r,;,OO_(n-r))) bold(Q)) $ 即满足 $bold(B)$ 是可逆矩阵,$bold(C)$ 是幂等矩阵的要求. = P75 补充题三 11 #ac #prob[ 设矩阵 $AA in PP^(m times n)$,$BB in PP^(n times m)$,试证明: $ r(bold(E)_m - AA BB) + n = r(bold(E)_n - BB AA) + m $ ] 设 $bold(C) = display(mat(EE_n, BB; AA, EE_m))$,考虑对其应用初等变换有: $ bold(C) = mat(EE_n, BB; AA, EE_m) -> mat(EE_n, OO; AA, EE_m - AA BB) -> mat(EE_n, OO; OO, EE_m - AA BB) $ 故 $r(bold(C)) = n + r(EE_m - AA BB)$,同理可得 $r(bold(C)) = m + r(EE_n - BB AA)$,故原命题等证. = P75 补充题三 12 #ac #prob[ 设 $AA$ 是一个 $n$ 阶可逆矩阵,向量 $alpha,beta in PP^n$,证明:$ r(AA + alpha beta^TT) >= n-1 $ ] 可以进一步地证明: $ r(AA + BB) >= r(AA) - r(BB) &<=> r(AA + BB) + r(-BB) >= r(AA)\ &<=> r(AA + BB) + r(-BB) >= r((AA + BB) + (-BB))\ $ 故 $ r(alpha beta^TT) <= 1\\ r(AA + alpha beta^TT) >= n - r(alpha beta^TT) >= n-1 $
https://github.com/NathanBurgessDev/tabletop-war-game-helper
https://raw.githubusercontent.com/NathanBurgessDev/tabletop-war-game-helper/main/Dissertation/interimTemplate.typ
typst
// I got this font from Google Fonts, you'll need to install it on your system #set text(font: "EB Garamond", size: 11pt) // Vertical space before // needs to have: // Project Title // Name // ID // email // name of the programme of your study // project module // #let diss-title( title: "Your Diss Title Goes Here", author:"<NAME>", ID: "20363169", email: "psynb7", programme: "BSc Hons Computer Science", module: "COMP3003", abstract: none, body, ) = { align(center)[ #image("images/uonLogo.png", width:60%) #v(20pt) #text(size: 18pt)[*#title*] \ #v(40pt) #text(size: 14pt)[Submitted April 2024, in partial fulfilment of the conditions for the award of the degree: ]\ #text(size: 14pt, style:"italic")[*#programme*]\ #v(40pt) #text(size: 14pt)[#ID]\ #text(size: 14pt)[School of Computer Science]\ #text(size: 14pt)[University of Nottingham]\ #v(40pt) #text(size: 14pt)[I hereby declare that this dissertation is all my own work, except as indicated in the text:]\ #v(10pt) #text(size: 14pt)[Signature: NB ]\ #text(size: 14pt)[Date: 13/04/24]\ #v(40pt) #text(size: 14pt)[I hereby declare that I have all necessary rights and consents to publicly distribute this dissertation via the University of Nottingham's e-dissertation archive.\*]\ ] set page(numbering: "i",number-align: center) body }
https://github.com/desid-ms/desid_report
https://raw.githubusercontent.com/desid-ms/desid_report/main/_extensions/desid_report/biblio.typ
typst
MIT License
$if(citations)$ $if(csl)$ #set bibliography(style: "$csl$") $elseif(bibliographystyle)$ #set bibliography(style: "$bibliographystyle$") $endif$ $if(bibliography)$ #bibliography($for(bibliography)$"$bibliography$"$sep$,$endfor$) $endif$ $endif$
https://github.com/talal/pesha
https://raw.githubusercontent.com/talal/pesha/main/README.md
markdown
MIT No Attribution
# Pesha > Pesha (Urdu: پیشہ) is the Urdu term for occupation/profession. It is pronounced as pay-sha. A clean and minimal template for your CV or résumé. This template is inspired by <NAME>'s excellent [_Practical Typography_](https://practicaltypography.com) book. See [example.pdf](https://github.com/talal/pesha/blob/main/example.pdf) or [example-profile-picture.pdf](https://github.com/talal/pesha/blob/main/example-profile-picture.pdf) file to see how it looks. ## Usage You can use this template in the Typst web app by clicking "Start from template" on the dashboard and searching for `pesha`. Alternatively, you can use the CLI to kick this project off using the command ```sh typst init @preview/pesha ``` Typst will create a new directory with all the files needed to get you started. ## Configuration This template exports the `pesha` function with the following named arguments: | Argument | Type | Description | | --- | --- | --- | | `name` | [string] | A string to specify the author's name. | | `address` | [string] | A string to specify the author's address. | | `contacts` | [array] | An array of content to specify your contact information. E.g., phone number, email, LinkedIn, etc. | | `profile-picture` | [content] | The result of a call to the [image function] or `none`. For best result, make sure that your image has an 1:1 aspect ratio. | | `paper-size` | [string] | Specify a [paper size string] to change the page size (default is `a4`). | | `footer-text` | [content] | Content that will be prepended to the page numbering in the footer. | | `page-numbering-format` | [string] | [Pattern](https://typst.app/docs/reference/model/numbering/#parameters-numbering) that will be used for displaying page numbering in the footer (default is `1 of 1`). | The function also accepts a single, positional argument for the body. The template will initialize your package with a sample call to the `pesha` function in a show rule. If you, however, want to change an existing project to use this template, you can add a show rule like this at the top of your file: ```typ #import "@preview/pesha:0.4.0": * #show: pesha.with( name: "<NAME>", address: "5419 Hollywood Blvd Ste c731, Los Angeles, CA 90027", contacts: ( [(323) 555 1435], [#link("mailto:<EMAIL>")], ), paper-size: "us-letter", footer-text: [Mustermann Résumé ---] ) // Your content goes below. ``` [array]: https://typst.app/docs/reference/foundations/array/ [content]: https://typst.app/docs/reference/foundations/content/ [string]: https://typst.app/docs/reference/foundations/str/ [paper size string]: https://typst.app/docs/reference/layout/page#parameters-paper [image function]: https://typst.app/docs/reference/visualize/image/
https://github.com/goshakowska/Typstdiff
https://raw.githubusercontent.com/goshakowska/Typstdiff/main/tests/test_working_types/bullet_list/bullet_list_inserted.typ
typst
- first item - second item - inserted item
https://github.com/typst-community/valkyrie
https://raw.githubusercontent.com/typst-community/valkyrie/main/src/coercions.typ
typst
Other
/// If the tested value is not already of dictionary type, the function provided as argument is expected to return a dictionary type with a shape that passes validation. /// /// #example[``` /// #let schema = z.dictionary( /// pre-transform: z.coerce.dictionary((it)=>(name: it)), /// (name: z.string()) /// ) /// /// #z.parse("Hello", schema) \ /// #z.parse((name: "Hello"), schema) /// ```] /// /// - fn (function): Transformation function that the tested value and returns a dictionary that has a shape that passes validation. #let dictionary(fn) = (self, it) => { if (type(it) != type((:))) { return fn(it) } it } /// If the tested value is not already of array type, it is transformed into an array of size 1 /// /// #example[``` /// #let schema = z.array( /// pre-transform: z.coerce.array, /// z.string() /// ) /// /// #z.parse("Hello", schema) \ /// #z.parse(("Hello", "world"), schema) /// ```] #let array(self, it) = { if (type(it) != type(())) { return (it,) } it } /// Tested value is forcibly converted to content type /// /// #example[``` /// #let schema = z.content( /// pre-transform: z.coerce.content /// ) /// /// #type(z.parse("Hello", schema)) \ /// #type(z.parse(123456, schema)) /// ```] #let content(self, it) = [#it] /// An attempt is made to convert string, numeric, or dictionary inputs into datetime objects /// /// #example[``` /// #let schema = z.date( /// pre-transform: z.coerce.date /// ) /// /// #z.parse(2020, schema) \ /// #z.parse("2020-03-15", schema) \ /// #z.parse("2020/03/15", schema) \ /// #z.parse((year: 2020, month: 3, day: 15), schema) \ /// ```] #let date(self, it) = { if (type(it) == type(datetime.today())) { return it } if (type(it) == int) { // assume this is the year assert( it > 1000 and it < 3000, message: "The date is assumed to be a year between 1000 and 3000", ) return datetime(year: it, month: 1, day: 1) } if (type(it) == str) { let yearMatch = it.find(regex(`^([1|2])([0-9]{3})$`.text)) if (yearMatch != none) { // This isn't awesome, but probably fine return datetime(year: int(it), month: 1, day: 1) } let dateMatch = it.find( regex(`^([1|2])([0-9]{3})([-\/])([0-9]{1,2})([-\/])([0-9]{1,2})$`.text), ) if (dateMatch != none) { let parts = it.split(regex("[-\/]")) return datetime( year: int(parts.at(0)), month: int(parts.at(1)), day: int(parts.at(2)), ) } panic("Unknown datetime object from string, try: `2020/03/15` as YYYY/MM/DD, also accepts `2020-03-15`") } if (type(it) == type((:))) { if ("year" in it) { return return datetime( year: it.at("year"), month: it.at("month", default: 1), day: it.at("day", default: 1), ) } panic("Unknown datetime object from dictionary, try: `(year: 2022, month: 2, day: 3)`") } panic("Unknown date of type '" + type(it) + "' accepts: datetime, str, int, and object") }
https://github.com/ClazyChen/Table-Tennis-Rankings
https://raw.githubusercontent.com/ClazyChen/Table-Tennis-Rankings/main/history/2011/MS-11.typ
typst
#set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (1 - 32)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [1], [MA Long], [CHN], [3375], [2], [ZHANG Jike], [CHN], [3239], [3], [BOLL Timo], [GER], [3188], [4], [WANG Hao], [CHN], [3187], [5], [MA Lin], [CHN], [3134], [6], [WANG Liqin], [CHN], [3125], [7], [XU Xin], [CHN], [3089], [8], [CHEN Qi], [CHN], [3005], [9], [OVTCHAROV Dimitrij], [GER], [2968], [10], [MIZUTANI Jun], [JPN], [2966], [11], [HAO Shuai], [CHN], [2952], [12], [OH Sangeun], [KOR], [2921], [13], [<NAME>], [GER], [2913], [14], [JOO Saehyuk], [KOR], [2887], [15], [SAMSONOV Vladimir], [BLR], [2865], [16], [RYU Seungmin], [KOR], [2852], [17], [LEE Sang Su], [KOR], [2845], [18], [<NAME>], [SLO], [2832], [19], [<NAME>], [FRA], [2815], [20], [YAN An], [CHN], [2812], [21], [KISHIKAWA Seiya], [JPN], [2811], [22], [CHUANG Chih-Yuan], [TPE], [2805], [23], [<NAME>], [GRE], [2798], [24], [LIVENTSOV Alexey], [RUS], [2791], [25], [<NAME>], [DEN], [2783], [26], [<NAME>], [KOR], [2745], [27], [KIM Minseok], [KOR], [2742], [28], [YOSHIDA Kaii], [JPN], [2740], [29], [<NAME>], [CHN], [2725], [30], [SMIRNOV Alexey], [RUS], [2716], [31], [APOLONIA Tiago], [POR], [2716], [32], [<NAME>], [AUT], [2713], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (33 - 64)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [33], [GAO Ning], [SGP], [2691], [34], [<NAME>], [GER], [2690], [35], [LEE Jungwoo], [KOR], [2687], [36], [SUSS Christian], [GER], [2682], [37], [KO Lai Chak], [HKG], [2681], [38], [KARAKASEVIC Aleksandar], [SRB], [2681], [39], [NIWA Koki], [JPN], [2675], [40], [TAKAKIWA Taku], [JPN], [2672], [41], [<NAME>], [AUT], [2669], [42], [MONTEIRO Joao], [POR], [2667], [43], [<NAME>], [SWE], [2666], [44], [<NAME>], [ROU], [2654], [45], [RUBTSOV Igor], [RUS], [2653], [46], [<NAME>], [KOR], [2652], [47], [<NAME>-An], [TPE], [2650], [48], [<NAME>], [POR], [2640], [49], [<NAME>], [CHN], [2610], [50], [<NAME>], [SWE], [2607], [51], [LUNDQVIST Jens], [SWE], [2606], [52], [<NAME>], [CRO], [2605], [53], [<NAME>], [ENG], [2601], [54], [SKACHKOV Kirill], [RUS], [2599], [55], [<NAME>], [POL], [2596], [56], [<NAME>], [JPN], [2594], [57], [<NAME>], [CRO], [2589], [58], [<NAME>], [FRA], [2584], [59], [<NAME>], [AUT], [2584], [60], [<NAME>], [JPN], [2581], [61], [<NAME>], [POL], [2580], [62], [<NAME>], [TUR], [2580], [63], [KREANGA Kalinikos], [GRE], [2580], [64], [<NAME>], [CHN], [2577], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (65 - 96)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [65], [<NAME>], [IRI], [2575], [66], [<NAME> Man], [PRK], [2575], [67], [<NAME>], [JPN], [2567], [68], [TANG Peng], [HKG], [2563], [69], [<NAME>], [ESP], [2563], [70], [<NAME>], [TUR], [2559], [71], [<NAME>], [GER], [2558], [72], [<NAME>], [HUN], [2556], [73], [<NAME>], [BEL], [2552], [74], [PROKOPCOV Dmitrij], [CZE], [2551], [75], [<NAME>], [HKG], [2549], [76], [<NAME>], [HKG], [2548], [77], [<NAME>], [SGP], [2544], [78], [<NAME>], [KOR], [2543], [79], [HABESOHN Daniel], [AUT], [2542], [80], [<NAME>], [FRA], [2533], [81], [<NAME>], [QAT], [2531], [82], [ACHANTA <NAME>], [IND], [2529], [83], [<NAME>], [DOM], [2527], [84], [UEDA Jin], [JPN], [2523], [85], [<NAME>], [SVK], [2522], [86], [YANG Zi], [SGP], [2522], [87], [HUNG Tzu-Hsiang], [TPE], [2522], [88], [<NAME>], [HKG], [2518], [89], [<NAME>], [AUT], [2518], [90], [<NAME>], [CRO], [2518], [91], [<NAME>], [KOR], [2516], [92], [<NAME>], [CZE], [2509], [93], [<NAME>], [HUN], [2505], [94], [<NAME>], [GER], [2504], [95], [<NAME>], [RUS], [2501], [96], [<NAME>], [KOR], [2500], ) )#pagebreak() #set text(font: ("Courier New", "NSimSun")) #figure( caption: "Men's Singles (97 - 128)", table( columns: 4, [Ranking], [Player], [Country/Region], [Rating], [97], [KASAHARA Hiromitsu], [JPN], [2497], [98], [MADRID Marcos], [MEX], [2496], [99], [WU Jiaji], [DOM], [2494], [100], [LIU Song], [ARG], [2494], [101], [<NAME>], [SVK], [2491], [102], [KOSOWSKI Jakub], [POL], [2488], [103], [<NAME>], [ESP], [2488], [104], [LI Hu], [SGP], [2488], [105], [CH<NAME>], [BLR], [2482], [106], [<NAME>], [RUS], [2476], [107], [ZHMUDENKO Yaroslav], [UKR], [2475], [108], [<NAME>], [CHN], [2464], [109], [<NAME>], [SWE], [2462], [110], [<NAME>], [POL], [2456], [111], [<NAME>], [BLR], [2454], [112], [<NAME>], [BRA], [2453], [113], [<NAME>], [ROU], [2451], [114], [<NAME>], [CZE], [2450], [115], [<NAME>], [KOR], [2447], [116], [<NAME>], [HKG], [2445], [117], [<NAME>], [UKR], [2441], [118], [<NAME>], [ENG], [2439], [119], [<NAME>], [ESP], [2434], [120], [BLASZCZYK Lucjan], [POL], [2433], [121], [#text(gray, "RI <NAME>")], [PRK], [2432], [122], [LIU Yi], [CHN], [2430], [123], [<NAME>], [ESP], [2429], [124], [OYA Hidetoshi], [JPN], [2428], [125], [<NAME>], [GER], [2427], [126], [<NAME>], [ITA], [2426], [127], [<NAME>], [KOR], [2425], [128], [<NAME>], [LAT], [2425], ) )
https://github.com/crd2333/typst-theorem-box
https://raw.githubusercontent.com/crd2333/typst-theorem-box/master/README.md
markdown
MIT License
# typst-theorem-boxes Theorem boxes in [typst](https://github.com/typst/typst), implemented by [showybox](https://github.com/Pablo-Gonzalez-Calderon/showybox-package), providing a beautiful way to display **theorems, definitions, lemmas, corollaries, and proofs**. The boxes will be counted like `x.y`, where `x` is the **first level heading number** and `y` is the box number of the type. ![example](examples/example1.png) ## Usage ```typst #import "/path/to/thms/lib.typ": * #set heading(numbering: "1.") #show: thmrules #theorem(title: [A title], [One body.], footer: [As well as footer!])[Another body!] ``` - For more examples, see examples folder.
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/circuiteria/0.1.0/README.md
markdown
Apache License 2.0
# circuiteria Circuiteria is a [Typst](https://typst.app) package for drawing block circuit diagrams using the [CeTZ](https://typst.app/universe/package/cetz) package. <p align="center"> <img src="./gallery/platypus.png" alt="Perry the platypus"> </p> ## Examples <table> <tr> <td colspan="2"> <a href="./gallery/test.typ"> <img src="./gallery/test.png" width="500px"> </a> </td> </tr> <tr> <td colspan="2">A bit of eveything</td> </tr> <tr> <td colspan="2"> <a href="./gallery/test5.typ"> <img src="./gallery/test5.png" width="500px"> </a> </td> </tr> <tr> <td colspan="2">Wires everywhere</td> </tr> <tr> <td> <a href="./gallery/test4.typ"> <img src="./gallery/test4.png" width="250px"> </a> </td> <td> <a href="./gallery/test6.typ"> <img src="./gallery/test6.png" width="250px"> </a> </td> </tr> <tr> <td>Groups</td> <td>Rotated</td> </tr> </table> > **Note**\ > These circuit layouts were copied from a digital design course given by prof. <NAME> and recreated using this package *Click on the example image to jump to the code.* ## Usage For more information, see the [manual](manual.pdf) To use this package, simply import [circuiteria](https://typst.app/universe/package/circuiteria) and call the `circuit` function: ```typ #import "@preview/circuiteria:0.1.0" #circuiteria.circuit({ import circuiteria: * ... }) ```
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/054_Lost%20Caverns%20of%20Ixalan.typ
typst
#import "@local/mtgset:0.1.0": conf #show: doc => conf("Lost Caverns of Ixalan", doc) #include "./054 - Lost Caverns of Ixalan/001_Episode 1.typ" #include "./054 - Lost Caverns of Ixalan/002_Episode 2.typ" #include "./054 - Lost Caverns of Ixalan/003_Episode 3.typ" #include "./054 - Lost Caverns of Ixalan/004_Episode 4.typ" #include "./054 - Lost Caverns of Ixalan/005_Episode 5.typ" #include "./054 - Lost Caverns of Ixalan/006_Episode 6.typ" #include "./054 - Lost Caverns of Ixalan/007_Pawns.typ"
https://github.com/elouan660/Tyspt-templates
https://raw.githubusercontent.com/elouan660/Tyspt-templates/main/temp.typ
typst
#let Exercice(titre, auteur, date, matière, contenu) = [ #set page( footer: grid( columns: (90%, 50%), rows: 1, [#auteur], [#date] ), ) #align(left, text(size: 12pt, weight: "regular",)[#auteur \ #date]) \ #set text( font: "Open Sans" ) #align(center, text(size: 17pt, weight: "bold")[#matière \ #titre]) \ #contenu ] #Exercice("Test", "<NAME>", "DD/MM/YYYY", "test")[ #lorem(50) ]
https://github.com/soul667/typst
https://raw.githubusercontent.com/soul667/typst/main/RM/公式推导.typ
typst
// #align(center,image("img/1.png",width:10em)) #set text(font: ("Times New Roman","STSong")) #set heading(numbering: "1.") #set par(justify: true,first-line-indent: 2em) // 两端对齐,段前缩进2字符 #set list(indent:4em) #show heading: it => { it par()[#text()[#h(0.0em)]] } = 假设 以车体坐标系为原点,采用新的坐标系定义。 - X - forward - Y - left - Z - up #h(2em) 假设装甲板一开始正对世界坐标系,无任何旋转偏移。如下图所示 #import "@preview/cetz:0.2.0": * #canvas({ import draw: * let axis-line(p) = { line((0, 0), (x: 4.5), stroke: red) line((0, 0), (y: 4.5), stroke: blue) line((0, 0), (z: 4.5), stroke: green) circle((0, 0, 0), fill: black, radius: 0.05) content((-0.4, 0.1, -0.2), p) } set-viewport((0, 0, 0), (4, 4, -4), bounds: (4, 4, 4)) axis-line("A") set-viewport((4, 4, 4), (0, 0, 0), bounds: (4, 4, 4)) axis-line("B") }) 在世界坐标系下,假设装甲板中心坐标是$(x,y,z)$,装甲板宽度长度分别为$(2a,2b)$,假设旋转角度$theta=0$,四个点的坐标分别为 #import "@preview/cetz:0.2.1" 假设上述转动角度为$theta$,其有一个旋转矩阵已经确定为$R_1$(前哨站,车两种情况,一种$+25^o$,一种$-25^o$),另外一个旋转矩阵为$R_2(theta)$ 四个点以左上角开始1编号,顺时针,有四个点$P_1,P_2,P_3,P_4$
https://github.com/QuadnucYard/cpp-coursework-template
https://raw.githubusercontent.com/QuadnucYard/cpp-coursework-template/main/algo.typ
typst
// Original: // // SPDX-FileCopyrightText: 2023 <NAME> // // SPDX-License-Identifier: MIT #let iflike_block(kw1: "", kw2: "", cond: "", ..body) = ( ([#strong(kw1) #cond #strong(kw2)]), (change_indent: 2, body: body.pos()), ) #let function_like(name, kw: "function", args: (), ..body) = iflike_block( kw1: kw, cond: (smallcaps(name) + "(" + args.join(", ") + ")"), ..body, ) #let listify(v) = { if type(v) == list { v } else { (v, ) } } #let Function = function_like.with(kw: "function") #let Procedure = function_like.with(kw: "procedure") #let State(block) = ((body: block), ) #let S = State /// Inline call #let CallI(name, args) = smallcaps(name) + "(" + listify(args).join(", ") + ")" #let Call(..args) = (CallI(..args), ) #let FnI(f, args) = strong(f) + " (" + listify(args).join(", ") + ")" #let Fn(..args) = (FnI(..args), ) #let Ic(c) = sym.triangle.stroked.r + " " + c #let Cmt(c) = (Ic(c), ) // It kind of sucks that Else is a separate block but it's fine #let If = iflike_block.with(kw1: "if", kw2: "then") #let While = iflike_block.with(kw1: "while", kw2: "do") #let For = iflike_block.with(kw1: "for", kw2: "do") #let Assign(var, val) = ([#var $<-$ #val], ) #let Else = iflike_block.with(kw1: "else") #let ElsIf = iflike_block.with(kw1: "else if", kw2: "then") #let ElseIf = ElsIf #let Return(arg) = ([*return* #arg], ) /* * Generated AST: * (change_indent: int, body: ((ast | content)[] | content | ast) */ #let ast_to_content_list(indent, ast) = { if type(ast) == array { ast.map(d => ast_to_content_list(indent, d)) } else if type(ast) == dictionary { let new_indent = ast.at("change_indent", default: 0) + indent ast_to_content_list(new_indent, ast.body) } else { (pad(left: indent * 1em, ast), ) } } #let pseudocode(input: none, output: none, ..bits) = { if input != none or output != none { block(inset: (left: 0.5em, top: 0.2em), below: 0.5em, { if input != none [ *Input:* #input #linebreak() ] if output != none [ *Output:* #output #linebreak() ] }) } let content = bits.pos().map(b => ast_to_content_list(0, b)).flatten() let table_bits = for lineno in range(content.len()) { ([#{ lineno + 1 }:], content.at(lineno)) } table( columns: (18pt, 100%), // line spacing inset: 0.3em, stroke: none, ..table_bits ) } #let algorithm = figure.with(kind: "algo", supplement: "Algorithm") #let setup-algo( line-number-style: text.with(size: .7em), line-number-supplement: "Line", body, ) = { show ref: it => { if it.element != none and it.element.func() == figure and it.element.kind == "algo-line-no" { link(it.element.location(), { line-number-supplement; sym.space; it.element.body }) } else { it } } show figure.where(kind: "algo-line-no"): it => line-number-style(it.body) show figure.where(kind: "algo"): it => { let booktabbed = block( stroke: (y: 1.3pt), inset: 0pt, breakable: true, width: 100%, { set align(left) block( inset: (y: 5pt), width: 100%, stroke: (bottom: .8pt), { strong({ it.supplement sym.space.nobreak counter(figure.where(kind: "algo")).display(it.numbering) [: ] }) it.caption.body }, ) block( inset: (bottom: 5pt), above: 0.2em, breakable: true, it.body, ) }, ) let centered = pad(booktabbed) if it.placement in (auto, top, bottom) { place(it.placement, float: true, centered) } else { centered } } body }
https://github.com/ckunte/m-one
https://raw.githubusercontent.com/ckunte/m-one/master/inc/tow.typ
typst
= Tow When asked to compare the severity of sea-transportation between the _North Sea_ @nd30 and the _South China Sea_, most engineers side with the former, which they deduce from comparing sea-states. So it is rare to not get a blank stare from people when I say they may not be right. Here is why. Let us take a look at practised barge motion design criteria in each, see @mot. #figure( table( columns: (auto, 1fr, 1fr), inset: 10pt, align: horizon, [], [_North Sea_], [_South China Sea_], [Barge size], [>76m $times$ >23m], [91.4m $times$ 27.4m], [Roll ($alpha$, $T_r$)], [20$degree$, 10s], [12.5$degree$, 5s], [Pitch ($beta$, $T_p$)], [12.5$degree$, 10s], [8$degree$, 5.5s], [Heave (gh)], [0.2g], [0.2g], ), caption: [Barge motion criteria for medium sized barges], ) <mot> where, $alpha$ and $beta$ are roll and pitch single amplitude of angular accelerations respectively (in degrees), together with corresponding full-cycle periods (in seconds); and _h_ is heave single amplitude of linear acceleration (either in terms of _g_, or in metres). With all motion parameters greater, at a glance _North Sea_ appears to govern over the _South China Sea_. But is it really? Let us convert these into accelerations and inertial forces to be sure. Maximum acceleration, in a simple harmonic motion without phase information, may be computed as follows: $ theta_r = omega^2 dot a $ From the above, roll acceleration takes the form: $ theta_r = ((2pi) / T_r)^2 dot alpha $ Similarly, pitch acceleration takes the form: $ theta_p = ((2pi) / T_p)^2 dot beta $ where, $T_r$, $T_p$, and $T_h$ are full-cycle periods associated with roll, pitch, and heave respectively (in seconds). #figure( table( columns: (1fr, 1fr, 1fr, 1fr), inset: 10pt, align: horizon, [], [_North Sea_], [_South China Sea_], [_Increase_], [$theta_r$ $("rad")/s^2$], [0.14], [0.34], [143%], [$theta_p$ $("rad")/s^2$], [0.09], [0.22], [144%], [gh $m/s^2$], [1.96], [1.96], [--], ), caption: [Accelerations], ) <acc> What? How? Well, it is attributable to the full-cycle period associated with motions, the proverbial elephant in the room, because most people read or regard full-cycle periods as some sort of meta information. In the case of the _South China Sea_, however, non-linearly lower full-cycle periods in the denominator drive accelerations-up. In turn, inertial forces increase as a consequence of higher accelerations.#footnote[Newton's second law of motion.] Full cycle (motion) periods are given by: $ T_r = 2pi sqrt( (r_x^2 + m_a_"roll") / (#overline[GM]_T dot g) ) $ $ T_p = 2pi sqrt( (r_y^2 + m_a_"pitch") / (#overline[GM]_L dot g) ) $ $ T_h = 2pi sqrt( (m + m_a_"heave") / (A_w rho g) ) $ These could sometimes be simplified to: $ T_r = 2pi r_x / sqrt(#overline[GM] dot g) $ $ T_p = 2pi r_y / sqrt(#overline[GM] dot g) $ where, - $r_x$, $r_y$: radii of gyration along head and beam directions respectively - $G M_T$, $G M_L$: metacentric height in transverse and longitudinal directions respectively - $m_a_r$, $m_a_p$, $m_a_h$: added masses There is a reason full (motion) periods are engineered for manned vessels, which is to make motions humanely _tolerable_ as the graph in @hrvm shows.@journee_mt519 The boundary of depression and intolerable ranges can occur for very low accelerations, if periods are too low. Whereas a combination of acceleration and its corresponding average frequency of oscillation determines the level of comfort aboard. However, marine cargo transports often involve unmanned dummy barges, for which human response is not seen as a governing requirement, and are therefore acceptable to operate at lower periods of motion. High dynamic acceleration is often a result of small period of motion, as seen in the case of _South China Sea_ pertaining to unmanned cargo barges. #figure( image("/img/tow_hra.png", width: 75%), caption: [Human response to vessel motions], ) <hrvm> One way to manage this is by optimising (static) metacentric height, GM, by keeping it sufficiently high from greater initial stability considerations --- but not excessively high, to warrant low periods of motion. This would not only reduce dynamic accelerations, but also help improve human response, where essential. == Effect of cargo position on inertia forces The effect of cargo position on sea-transport forces in unrestricted open-seas (in terms of _W_, which is the dry weight of cargo)for all vessel types described in 0030/ND@nd30 is shown in @lv, @mv, @sb, and @sv. #figure( image("/img/tow_lvessels.png", width: 75%), caption: [Large vessels], ) <lv> #figure( image("/img/tow_mvessels.png", width: 75%), caption: [Medium vessels and large cargo barges], ) <mv> #figure( image("/img/tow_sbarges.png", width: 75%), caption: [Small barges], ) <sb> #figure( image("/img/tow_svessels.png", width: 75%), caption: [Small vessels], ) <sv> where, $L_x$, $L_y$, and $L_z$ are are distances between barge centre of rotation and cargo centre of gravity in x (along barge length), y (along barge width), and z (vertical) respectively. The plot script for all standard vessel types, described in 0030/ND is as follows. #let ves = read("/src/ves.py") #{linebreak();raw(ves, lang: "python")} For non-standard motion responses, particularly in benign environments that exhibit lower single amplitude motion and lower full-cycle period, the following code could be used. It requires all values to be input. #let ves_c = read("/src/ves_c.py") #{linebreak();raw(ves_c, lang: "python")} $ - * - $
https://github.com/dainbow/FunctionalAnalysis2
https://raw.githubusercontent.com/dainbow/FunctionalAnalysis2/main/main.typ
typst
#import "conf.typ": * #let title = [ Функциональный анализ 2.0. ] #show: doc => conf(title, doc) #align(center, text(17pt)[ *#title* ]) #align(center)[ Disclaymer: доверять этому конспекту или нет выбирайте сами ] #align( center, )[ Big thanks for #link("https://t.me/ltc2021", "<NAME>") и #link("https://t.me/wolfawi", "<NAME>") в частности. ] #include "themes/1.typ" #include "themes/2.typ" #include "themes/3.typ" #include "themes/4.typ" #include "themes/5.typ" #include "themes/6.typ" #include "themes/7.typ" #include "themes/8.typ"
https://github.com/tiankaima/typst-notes
https://raw.githubusercontent.com/tiankaima/typst-notes/master/ea2724-ai_hw/hw2.typ
typst
#import "@preview/cetz:0.2.2": canvas, draw, tree == HW 2 Due 2024.03.24 #let ans(it) = [ #pad(1em)[ #text(fill: blue)[ #it ] ] ] === Question 4.1 4.1 追踪 $A^*$ 搜索算法用直线距离启发式求解从 Lugoj 到 Bucharest 问题的过程. 按照顺序列出算法扩展的节点和每个节点的 $f, g, h$ 值 #ans[ #let data_41 = ( [Luogoj(244, 0, 244)], ([Timisora(440, 111, 329)]), ( [Mehadia(316, 75, 241)], [Luogoj(384, 140, 244)], ( [Dobreta(387, 145, 242)], ( [Craiova(425, 265, 160)], [<NAME>(604, 411, 193)], ( [Pitesti(501, 403, 98)], [<NAME>\ (693, 500, 193)], [Bucharest\ (504, 504, 0)], ), ), ), ), ) #canvas( length: 1cm, { import draw: * set-style( content: (padding: .2), fill: gray.lighten(70%), stroke: gray.lighten(70%), ) tree.tree( data_41, spread: 3., grow: 1.5, draw-node: (node, ..) => { content((), node.content) }, draw-edge: (from, to, ..) => { line( (a: from, number: .6, b: to), (a: to, number: .6, b: from), mark: (end: ">"), ) }, name: "tree", ) let ab = ( ("tree.0", "tree.0-1"), ("tree.0-1", "tree.0-1-1"), ("tree.0-1-1", "tree.0-1-1-0"), ("tree.0-1-1-0", "tree.0-1-1-0-1"), ("tree.0-1-1-0-1", "tree.0-1-1-0-1-1"), ) for _ab in ab { let (a, b) = _ab line((a, .6, b), (b, .6, a), mark: (end: ">"), stroke: red) } }, ) 上方标红的路径即为 $A^*$ 搜索算法的最优路径, 从 Lugoj 到 Bucharest. ] === Question 4.2 4.2 启发式路径算法是一个最佳有限搜索, 它的目标函数是 $f(n) = (2-omega) g(n) + w h(n)$. 算法中$w$取什么值保证算法是最优的?当$w=0$时, 这个算法是什么搜索?$w=1$呢?$w=2$呢? #ans[ - $w=0 => f(n) = 2g(n)$ 此时算法与 UCS 算法相同, 选择最小的 $g(n)$ - $w=1 => f(n) = g(n) + h(n)$ 此时算法与 $A^*$ 算法相同, 选择最小的 $f(n)$ - $w=2 => f(n) = 2h(n)$ 此时算法与 Greedy 算法相同, 选择最小的 $h(n)$ 考虑到 $ f(n) = (2-omega)[g(n) + omega/(2-omega) h(n)] $ 这与以 $ h_1(n) = omega/(2-omega)h(n) $ 作为启发式函数的 $A^*$ 算法相同. 当 $omega<1$ 时, $h_1(n)<h(n)$. 当且仅当 $omega=1$ 时, $h_1(n)=h(n)$, 此时算法是最优的. ] === Question 4.6 4.6 设计一个启发函数, 使它在八数码游戏中有时会估计过高, 并说明它在什么样的特殊问题下会导致次最优解.(可以借助计算机的帮助) 证明:如果 $h$ 被高估的部分从来不超过 $c$, $A^*$ 算法返回的解的耗散多出的部分也不超过 $c$. #ans[ - *设计一个启发函数, 使它在八数码游戏中有时会估计过高, 并说明它在什么样的特殊问题下会导致次最优解. * #image("./imgs/Solution_4.6.jpg", width: 70%) - *证明:如果 $h$ 被高估的部分从来不超过 $c$, $A^*$ 算法返回的解的耗散多出的部分也不超过 $c$.* 考虑 $h(n)<=h^*(n)+c$, 并且令$G^'$为耗散超过$c$的解 ($g(G^') > C^* + c$). 考虑在到达最优解的路径上所有节点$n$: $ f(n) = g(n) + h(n) <= g(n) + h^*(n) + c = g(G) + h^*(G) + c = C^* + c <= g(G^') $ 在到达最优解之前不会到达 $G^'$, 这样 $A^*$ 算法返回的解的耗散多出的部分也不超过 $c$. ] === Question 4.7 4.7 证明如果一个启发式是一致的, 它肯定是可采纳的. 构造一个非一致的可采纳启发式. #ans[ - 一致:$h(n) <= c(n, a, n') + h(n')$ - 可采纳:$h(n) <= h^*(n)$ 一致 $=>$ 可采纳性:按归纳法, $k=1$ 时, 取 $n^'$为目标节点, $h(n) <= c(n, a, n')$; 假设 $k$ 时成立, 则 $h(n) <= c(n, a, n') + h(n') <= c(n, a, n') + h^*(n') = h^*(n)$, 所以距离 $k+1$ 步远的节点上 $h(n)$ 也是可采纳的. 构造一个非一致的可采纳启发式: #image("./imgs/Solution_4.7.jpg", width: 50%) ]
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/valkyrie/0.1.0/src/lib.typ
typst
Apache License 2.0
#import "types.typ": * #import "context.typ": context #import "base-type.typ" as advanced /// This is the main function for validating an object against a schema. *WILL* return the given object after validation if successful, or none and *MAY* throw a failed assertion error. /// /// - object (any): Object to validate against provided schema. Object *SHOULD* statisfy the schema requirements. An error *MAY* be produced if not. /// - schema (schema): Schema against which `object` is validated. *MUST* be a valid valkyrie schema type. /// - ctx (context): Context passed to schema validator function, containing flags that *MAY* alter behaviour. /// - scope (scope): An array of strings used to generate the string representing the location of a failed requirement within `object`. *MUST* be an array of strings of length greater than or equal to `1`. /// -> any, none #let parse( object, schema, ctx: context(), scope: ("argument",), ) = { // don't expose to external import "base-type.typ": assert-base-type // Validate named arguments assert-base-type(schema, scope: scope) // Validate arguments per schema object = (schema.validate)( schema, ctx: ctx, scope: scope, object) // Require arguments match schema exactly in strict mode if ( ctx.strict ){ for (argument-name, argument-value) in object { assert( argument-name in schema, message: "Unexpected argument " + argument-name) }} return object }
https://github.com/OverflowCat/BUAA-Automatic-Control-Components-Sp2024
https://raw.githubusercontent.com/OverflowCat/BUAA-Automatic-Control-Components-Sp2024/neko/实验/1.typ
typst
#set text(lang: "zh", font: "Noto Serif CJK SC") #show "。": "." = 实验一 = 实验(1):他励直流电动机的工作及机械特性 == 1、测量他励直流电动机的固有工作特性(转速调整特性、转矩特性和效率特性) 取 $I_"an" = 0.4 A.$ #figure( caption: "他励直流电动机的转速调整特性和转矩特性", table( columns: (auto, 9.84%, 9.84%, 9.84%, 9.84%, 9.84%, 9.84%, auto, 9.84%), align: (auto, auto, auto, auto, auto, auto, auto, auto, auto), table.header([], [1], [2], [3], [4], [5], [6], [7], [8]), [$I_a (A)$], [0.12], [0.20], [0.28], [0.32], [0.36], [0.40], [0.44], [0.48], [$n ("r/min")$], [0.501], [0.783], [1.024], [1.134], [1.238], [1.339], [1.459], [1.583], [$T (N dot.op M)$], [1718], [1701], [1688], [1678], [1672], [1665], [1658], [1650], ), ) // $ P_1 = U I = U_"dn" I_"an" = 220 times 0.4 = 88 "W" $ // $ P_N = T_N Omega = (2 n_N pi T_N) / 60 = 0.105 n_N T_N. = 0.105 times 1.339 times 1665 = 234.1 "W". $ // $ eta = P_N / P_1 = // $n_N = 1.339 "r/min", T = 1665 upright("N") dot.op upright("m"),$ 则 // $ P_N = T_N Omega = (2 n_N pi T_N) / 60 = 0.105 n_N T_N. $ // 又 $ P_N = U_"dn" I_"an" = 220 times 0.4 = 88 "W",$ // 故 $ T_N = P_N / (0.105 n_N) = 88 / (0.105 times 1.339) = 625.9 upright("N") dot.op upright("m"). $ // $ eta = P_2 / P_1 = (0.105 n C_T Phi I_a) / (U I) = 0.105 n C_T Phi. // $ // $ P_N = 0.105 n T_N = 0.105 $ == 2、他励直流电动机的机械特性 调节电枢回路电阻W1使电机转速降低至 1200 r/min。取 $I_"an" = 0.2 A.$ #figure( caption: [机械特性表格 $n = f (T)$], align(center)[#table( columns: 6, align: (auto, auto, auto, auto, auto, auto), table.header([], [1], [2], [3], [4], [5]), table.hline(), [$T (N dot.op M)$], [0.410], [0.647], [0.783], [0.916], [1.162], [$n ("r/m i n")$], [1508], [1373], [1284], [1194], [1059], )], ) #figure(image("dist/1.svg")) 根据两表数据在同一个坐标中绘制他励直流电动机的固有特性、工作特性和机械特性,分析、比较并得出各自的特点。 - 固有特性:电磁转矩越大,转速越低,是一条下斜直线 - 机械特性:$n_0$ 不变 == 思考题 + 额定励磁的条件下,增大电枢端电压起动直流电动机,为何必须缓慢增大?否则有什么后果? 电机启动时,若直接施加额定电压,电枢回路中的电阻和电感会产生过大的启动电流,这可能损坏电机或导致过热。 + 通过改变电动机励磁或端电压极性以改变电动机旋转方向,为何必须先停机,再换接端子极性?可否正常运转姿态下直接通过刀开关或接线端子直接改变旋转方向?为什么? 正常运转姿态下直接换向,转子冲击强烈,易损坏传动零件。 + 直流电动机励磁回路断线后,会产生什么后果? - 由于励磁磁通减小,电枢电流会大幅度上升,可能导致电机烧毁。 - 电机转速可能急剧升高或下降,导致换向不良,损坏转子。 = 实验(2):直流电动机启动和调速实验 #figure( caption: "直流电动机电气数据表(额定值)", table( columns: (auto, auto, auto, auto, auto, auto, auto, auto), table.header([], "型号", [功率 (W)], [电压 (V)], [电流 (A)], [转速 (rpm)], [励磁电压], [励磁电流]), [直流电动机], [], [1'], [220], [1.25], [1500], [220], [], ), ) #figure( caption: "他励直流电动机改变电枢电压调速实验(恒转矩负载)", table( columns: 8, table.header([序号], [1], [2], [3], [4], [5], [6], [7]), [$U_a$ (V)], [100], [120], [140], [160], [180], [200], [220], [$n$ (r/min)], [388], [536], [687], [836], [977], [1133], [1280], [$I_a$ (A)], [0.052], [0.053], [0.055], [0.056], [0.059], [0.061], [0.063], ), ) #figure( caption: "他励直流电动机改变励磁电流调速(恒功率负载)", table( columns: 8, table.header([序号], [1], [2], [3], [4], [5], [6], [7]), [$U_a$ (V)], [200], [180], [160], [140], [120], [150], [170], [$n$ (r/min)], [1330], [1377], [1440], [1509], [1594], [1505], [1436], [$I_a$ (A)], [0.081], [0.086], [0.088], [0.091], [0.093], [0.094], [0.092], ), ) == 思考题 + 说明电动机起动时,起动电阻W1和磁场调节电阻W2应调到什么位置?为什么? 电动机起动时,起动电阻W1应调到最大位置,磁场调节电阻W2应调到最小位置,使励磁电流最大。 + 在电动机轻载及额定负载时,增大电枢回路的调节电阻,电机的转速如何变化?增大励磁回路的调节电阻,转速又如何变化? 轻载及额定负载时增大电枢回路的调节电阻,电机的转速会降低;增大励磁回路的调节电阻,转速会增加。 + 用什么方法可以改变直流电动机的转向? + 反接电枢两端的电压 + 改变调整励磁绕组的极性 + 为什么要求直流他励电动机磁场回路的接线要牢靠?起动时电枢回路必须串联起动变阻器? - 一旦磁场小于最低允许值。电机的速度将超过最大允许值,可能损坏电机。 - 电机起动时,电枢回路串联起动变阻器,可以减小启动电流,减小电机损坏的可能性。 + 直流电动机在基速以下采用改变电枢端电压调速,称作“恒转矩调速方法”,在基速以上采用弱磁调速,称作“恒功率调速方法”,为什么? 直流电动机在基速以下采用改变电枢端电压调速,因为此时磁通量保持不变,转矩与电流成正比,实现恒转矩输出;而在基速以上采用弱磁调速,因为此时电枢电压已达额定值,只能通过降低磁通来提高转速,而功率保持不变,实现恒功率输出。
https://github.com/LugsoIn2/typst-htwg-thesis-template
https://raw.githubusercontent.com/LugsoIn2/typst-htwg-thesis-template/main/lib/tableOfContents.typ
typst
MIT License
#import "textTemplate.typ": * #let tableOfContents(lang: "", table-of-contents-font: "Arial", font-color: "", ) = { let languageText = textTemplate(pagetype: "tableOfContents" ,lang: lang) // --- -------------- ---- // --- -------------- ---- // -- Table of Contents -- align(right, outline( title: { text(font: table-of-contents-font, fill: font-color, size: 30pt, weight: 700, languageText.at(0)) v(15mm) }, indent: 2em )) }
https://github.com/pedrofp4444/BD
https://raw.githubusercontent.com/pedrofp4444/BD/main/report/cover.typ
typst
#let blue = rgb("365F91") #let gray = rgb("808080") #let light_gray = rgb("A6A6A6") #let cover(title: "", authors: (), string_date) = { let render_authors = grid(columns: authors.len(), column-gutter: 15pt, ..authors.map(it => [ #text(size:12pt, weight: "bold", it.name) \ #text(size: 11pt, it.number) ]) ) { set page(paper: "a4", margin: (x: 0cm,y: 0cm)) rect(fill: blue,height: 100%, width:23.3%) place(bottom + left,dx: 59pt,dy:-40pt, { text(weight:"bold", size: 120pt, fill: white, [B]) text(weight:"bold", size: 120pt, fill: blue, [D]) }) { set place(top+left, dx: 200pt) place(dy: 120pt, image("images/uminho.png", height: 8%)) place(dy: 200pt, { text(size: 10pt, weight: "bold", fill: gray, [Universidade do Minho\ ]) text(size: 9pt, fill: gray, [Escola de Engenharia\ Licenciatura em Engenharia Informática\ ]) }) place(dy: 300pt, { text(size: 20pt, fill: blue, weight: "bold", [Unidade Curricular de \ Base de Dados\ ]) text(size: 10pt, [Ano Letivo de 2023/2024]) }) place(dy: 520pt, text(size: 20pt, weight: "bold", title)) place(dy: 590pt, render_authors) place(dy: 640pt, text(size: 12pt, string_date)) } } { align( top+right, table( columns: 2 * (115pt, ), align: top + left, rows: (20pt, 20pt, 20pt, 40pt), stroke: (dash: "densely-dotted", thickness: 0.75pt), [Data da Receção], [], [Responsável], [], [Avaliação], [], [Observações], [], ) ) align(bottom + left, { text(size: 18pt, weight: "bold", title) v(30pt) set text(size: 12pt) render_authors v(10pt) string_date }) } }
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/bytefield/0.0.2/example.typ
typst
Apache License 2.0
#import "bytefield.typ": * = Bytefield == Random Example #bytefield( bits(32, fill: red.lighten(30%))[Test], bytes(5)[Break], bits(24, fill: green.lighten(30%))[Fill], bytes(12)[Addr], padding(fill: purple.lighten(40%))[Padding], ) == Reversed bit order Select `msb_first: true` for a reversed bit order. #bytefield( msb_first: true, all_header_bits: true, byte[MSB],bytes(2)[Two], bit[#flagtext("URG")], bits(7)[LSB], ) == Show all bits in the bitheader Show all bit headers with `bitheader: "all"` #bytefield( bits:16, msb_first: true, bitheader: "all", ..range(16).map(i => bit[#flagtext[B#i]]).rev(), ) == Custom bit header #bytefield( bits:16, bitheader: (0,5, 7, 12,15), bits(6)[First], bits(2)[Duo], bits(5)[Five], bits(3)[Last], ) == IPv4 #ipv4 == IPv6 #ipv6 == ICMP #icmp == ICMPv6 #icmpv6 == DNS #dns == TCP #tcp #tcp_detailed == UDP #udp
https://github.com/kdog3682/mathematical
https://raw.githubusercontent.com/kdog3682/mathematical/main/0.1.0/src/draw/shapes.typ
typst
#import "@local/typkit:0.1.0": * #import "@preview/cetz:0.2.2" #import "utils.typ" #let points(points, ..sink) = { for p in points { cetz.draw.circle(p, radius: 3pt, stroke: none, fill: black, ..sink) } } #let polygon(points, ..sink) = { cetz.draw.line(..points, close: true, ..sink) } #let square((x, y), length: 1, ..sink) = { let points = ( (x, y), (x + length, y + length), ) cetz.draw.rect(..points, ..sink) } #let vline(y1, y2, ..sink) = { let args = sink.pos() let x = if args.len() == 1 { args.first() } else { 0 } let points = ((x, y1), (x, y2)) return cetz.draw.line(..points, ..sink.named()) } #let hline(x1, x2, ..sink) = { let y = sink.pos().len() == 1 let args = sink.pos() let y = if args.len() == 1 { args.first() } else { 0 } let points = ((x1, y), (x2, y)) return cetz.draw.line(..points, ..sink.named()) } #let point(p, ..sink) = { let attrs = build-attrs( radius: 0.2, stroke: none, fill: black, key: "circle", sink ) cetz.draw.circle(p, ..attrs) } #let grid(width: 10, height: 10) = { cetz.draw.grid((0, 0), (width, height), help-lines: true) }
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/hydra/0.3.0/src/core.typ
typst
Apache License 2.0
#import "/src/util.typ" /// Get the last anchor location. Panics if the last anchor was not on the page of this context. /// /// - ctx (context): The context from which to start. /// -> location #let get-anchor-pos(ctx) = { let starting-locs = query(selector(ctx.anchor).before(ctx.loc), ctx.loc) let message = ( "No `anchor()` found while searching from outside the page header, did you forget to set", "`paper`/`page-size` or `top-margin`?", ).join(" ") assert.ne(starting-locs.len(), 0, message: message) let anchor = starting-locs.last().location() assert.eq(anchor.page(), ctx.loc.page(), message: "`anchor()` must be on every page before the first use of `hydra`" ) anchor } /// Get the element candidates for the given context. /// /// - ctx (context): The context for which to get the candidates. /// -> candidates #let get-candidates(ctx) = { let look-behind = selector(ctx.primary.target).before(ctx.loc) let look-ahead = selector(ctx.primary.target).after(ctx.loc) let prev-ancestor = none let next-ancestor = none if ctx.ancestors != none { let prev = query(selector(ctx.ancestors.target).before(ctx.loc), ctx.loc) let next = query(selector(ctx.ancestors.target).after(ctx.loc), ctx.loc) if ctx.ancestors.filter != none { prev = prev.filter(x => (ctx.ancestors.filter)(ctx, x)) next = next.filter(x => (ctx.ancestors.filter)(ctx, x)) } if prev != () { prev-ancestor = prev.last() look-behind = look-behind.after(prev-ancestor.location()) } if next != () { next-ancestor = next.first() look-ahead = look-ahead.before(next-ancestor.location()) } } let prev = query(look-behind, ctx.loc) let next = query(look-ahead, ctx.loc) if ctx.primary.filter != none { prev = prev.filter(x => (ctx.primary.filter)(ctx, x)) next = next.filter(x => (ctx.primary.filter)(ctx, x)) } let prev = if prev != () { prev.last() } let next = if next != () { next.first() } ( primary: (prev: prev, next: next), ancestor: (prev: prev-ancestor, next: next-ancestor), ) } /// Checks if the current context is on a starting page, i.e. if the next candidates are on top of /// this context's page. /// /// - ctx (context): The context in which the visibility of the next candidates should be checked. /// - candidates (candidates): The candidates for this context. /// -> bool #let is-on-starting-page(ctx, candidates) = { let next = if candidates.primary.next != none { candidates.primary.next.location() } let next-ancestor = if candidates.ancestor.next != none { candidates.ancestor.next.location() } let next-starting = if next != none { next.page() == ctx.loc.page() and next.position().y <= ctx.top-margin } else { false } let next-ancestor-starting = if next-ancestor != none { next-ancestor.page() == ctx.loc.page() and next-ancestor.position().y <= ctx.top-margin } else { false } next-starting or next-ancestor-starting } /// Checks if the previous primary candidate is still visible. /// /// - ctx (context): The context in which the visibility of the previous primary candidate should be /// checked. /// - candidates (candidates): The candidates for this context. /// -> bool #let is-active-visible(ctx, candidates) = { // depending on the reading direction and binding combination the leading page is either on an odd // or even number, if it is leading it means the previous page is visible let cases = ( left: ( ltr: calc.odd, rtl: calc.even, ), right: ( ltr: calc.even, rtl: calc.odd, ), ) let is-leading-page = (cases.at(repr(ctx.binding)).at(repr(ctx.dir)))(ctx.loc.page()) let active-on-prev-page = candidates.primary.prev.location().page() == ctx.loc.page() - 1 is-leading-page and active-on-prev-page } /// Check if showing the active element would be redudnant in the current context. /// /// - ctx (context): The context in which the redundancy of the previous primary candidate should be /// checked. /// - candidates (candidates): The candidates for this context. /// -> bool #let is-active-redundant(ctx, candidates) = { let active-visible = ( ctx.book and candidates.primary.prev != none and is-active-visible(ctx, candidates) ) let starting-page = is-on-starting-page(ctx, candidates) active-visible or starting-page } /// Display a heading's numbering and body. /// /// - ctx (context): The context in which the element was found. /// - candidate (content): The heading to display, panics if this is not a heading. /// -> content #let display(ctx, candidate) = { util.assert.element("candidate", candidate, heading, message: "Use a custom `display` function for elements other than headings", ) if candidate.has("numbering") and candidate.numbering != none { numbering(candidate.numbering, ..counter(heading).at(candidate.location())) [ ] } candidate.body } /// Execute the core logic to find and display elements for the current context. /// /// - ctx (context): The context for which to find and display the element. /// -> content #let execute(ctx) = { if ctx.anchor != none and ctx.loc.position().y >= ctx.top-margin { ctx.loc = get-anchor-pos(ctx) } let candidates = get-candidates(ctx) let prev-eligible = candidates.primary.prev != none and (ctx.prev-filter)(ctx, candidates) let next-eligible = candidates.primary.next != none and (ctx.next-filter)(ctx, candidates) let active-redundant = is-active-redundant(ctx, candidates) if prev-eligible and not active-redundant { (ctx.display)(ctx, candidates.primary.prev) } else if next-eligible and not ctx.skip-starting { (ctx.display)(ctx, candidates.primary.next) } }
https://github.com/kazewong/lecture-notes
https://raw.githubusercontent.com/kazewong/lecture-notes/main/Physics/GravitationalWave/gravitational_wave.typ
typst
#set page( paper: "us-letter", header: align(center, text(17pt)[ *Gravitational wave* ]), numbering: "1", ) #set heading(numbering: "1.") #outline( indent: 1em ) #set text( font: "Times New Roman", size: 11pt ) #set par(justify: true) = Introduction Almost every references I read on gravitational wave start with some tensor algebras and basica general relativity (GR). While I do not have problem with those presentations, I reckon that is not how I would teach myself. From a theorist perspective, learning about GW is like building a lego tower, you have to start with the foundation and work your way up. This is great for building a solid foundation(assuming you go over all the exercise), but I feel like I never know where I am going, especially when it is being taught in a multiple weeks or even semester class. To me, it is more important to have the entire blueprint of the course in front of me first. I need to know the map of navigating through different sections of the lecture and how they are related to one another before I know how to get there. I often tell myself or say in a lecture: "this is some detail we will revisit later". And this is exactly what I am going to write this lecture note. And the fun part of this way going through the material is you get to be the driver as well. To start with, just read this introduction and maybe the second chapter for some basic information, then you can decide which part of this lecture interested you most and dig in. I try to make this lecture as nonlinear as possible. We are not building a tower from the ground up, it is more like we are going into a theme park or a zoo, you should be able to pick whatever interested you the most and go wild. There will be some sections that are prerequesite for others, but I will note that down in each section such that you know how to navigate between them. We are going to start with some observational properties about GW, such as what is the data we are looking at, how GW interact with detectors, and how are the features in the data related to the source properties. Then, we are going to take a tour of how do we extract information from a signal stream and relate that to properties of the source. We are then going to go through a bit more detail in how gravitational wave model are represented in the form of a waveform model. After that, we are jumping a bit into the guts of different kinds of GW detectors. At this point, you actually have most of the ingridients to start a summer research project. Then we are going a bit more hardcore into different type of sources that might be interesting if you care about GW. Now I fully understand my style of writing could be confusing to some people, and it is almost certainly less structured than other materials. I like to try new things does not mean the new things are inherently better. I encourage the readers to also read through some other more estabilish materials such as, especially when you need to quote or cite some establish facts. = Observational properties of gravitational wave = Solving parameter estimation problems = Basic Waveform model = Gravitational wave detectors == Ground-based Interferometers == Space-based Interferometers == Pulsar timing array == Cosmic microwave background inprints = Source models == Vanilla black holes == Binary neutron stars = Making of waveform models = Finally General relativity and numerical relativity = Beyond general relativity == Lensing == nonGR effect = Population models
https://github.com/DaAlbrecht/thesis-TEKO
https://raw.githubusercontent.com/DaAlbrecht/thesis-TEKO/main/content/Projectplan.typ
typst
#import "@preview/tablex:0.0.5": tablex, cellx In this thesis, the use cases outlined in @Use_cases have been implemented. To ensure timely completion within the established timeframe, a project schedule has been developed. The choice of utilizing the Waterfall project management methodology is based on the specific characteristics of this thesis project. The Waterfall methodology has been selected as a suitable approach due to several key factors: - the project is being conducted independently, without the involvement of a team, making the linear and sequential nature of Waterfall a practical fit. - the project operates within strict time constraints - the thesis description has already been submitted in advance, precluding any changes to the requirements. Therefore, the Waterfall methodology aligns well with the project's unique circumstances. As seen in @a_plan the project schedule is divided into seven different phases and has the following milestones: == Milestones The following milestones have been defined for the project schedule: #figure( table( columns: (auto,auto), rows: auto, align: (left,left), [*Milestone*], [*Date*], [Start thesis], [15.09.2023], [Email the state of the thesis to the supervisor], [22.09.2023], [1. meeting with the thesis supervisor], [03.10.2023], [2. meeting with the thesis supervisor], [19.10.2023], [Proof reading], [23.10.2023], [End thesis], [30.10.2023], [Presentation], [11.11.2023] ), caption: "Project Milestones", ) Two meetings with the thesis supervisor are planned. The first meeting is to gain early feedback about the thesis structure while the second meeting is to discuss the implementation documentation structure and potential questions. The proofreading is planned to be done by a third party to ensure that the thesis is free of spelling and grammar mistakes. #pagebreak() == Project phases The project consists of the following phases: 1. planning / specifics for TEKO 2. requirements engineering 3. research 4. evaluation 5. implementation 6. verification 7. thesis 8. presentation #linebreak() In the first phase, the project schedule is created. Additionally, the thesis template is made and a skeleton for the table of content is added. In the first phase, the TEKO specific requirements such as a short curriculum vitae is also written. The first phase ends with the introduction of the problem statement. The second phase is the requirements engineering phase. In this phase the stakeholders and use cases are identified and the requirements are gathered. RabbitMQ is a new topic in this thesis and therefore the third phase is deticated to researching RabbitMQ components, queues and the AMQP protocol. This research is the basis for the evaluation phase. In the fourth phase, different AMQP client libraries are evaluated. The evaluation is based on the research done in the previous phase. Additionally, an architecture for the microservice is designed. The fifth phase is the implementation phase. The implementation is based on the architecture designed in the previous phase. The sixth phase is the verification phase. In this phase the microservice is verified against the requirements. In the seventh phase, the thesis gets finished and the additional chapters like a cover page or acknowledgments are added. The last phase is the presentation. In this phase a short presentation is created and micro webpage in the thesis portal is launched. #pagebreak() #include "../personal/Profitability.typ"
https://github.com/piepert/philodidaktik-hro-phf-ifp
https://raw.githubusercontent.com/piepert/philodidaktik-hro-phf-ifp/main/src/parts/spue/spue.typ
typst
Other
#import "/src/template.typ": * #make-part([Schulpraktische Übung], subtitle: [Hinweise zum Planen und Durchführen einer Unterrichtssunde]) #include "anforderungen/main.typ" #include "planung/main.typ" #include "leistungsmessung/main.typ"
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/010%20-%20Duel%20Decks%3A%20Jace%20vs.%20Vraska/001_The%20Gorgon%20and%20the%20Guildpact.typ
typst
#import "@local/mtgstory:0.2.0": conf #show: doc => conf( "The Gorgon and the Guildpact", set_name: "Duel Decks: Jace vs. Vraska", story_date: datetime(day: 12, month: 03, year: 2014), author: "<NAME>", doc ) Jace appeared on Ravnica already late, judging by the speed with which a courier had found him upon arrival and by the number of times the message used the word "urgently," which was three. Lavinia, formerly the Azorius maze runner and currently Jace's aide and deputy at the Chamber of the Guildpact, tended to deploy adverbs when Jace was falling behind in his duties. The newly built halls of the Chamber of the Guildpact echoed with the distinct sound of clopping hooves. That was not a sound Jace traditionally associated with the official sanctum of the Living Guildpact. He hurried to the main receiving hall, where the corridor expanded to reveal a crowd of bellowing, steel-clad minotaurs with Boros tabards. Lavinia stood among the complainants, the only one not bellowing or stamping hooves. Her Azorius armor shone with a regulation gleam. "The Orzhov violated our boundary contract!" roared the lead minotaur. "They're collecting levies on Legion land!" Other minotaurs stamped and rumbled in agreement. "Your guild has not filed a proper complaint with this office," said Lavinia evenly, drowned out by the racket. She shook a piece of paper in the air as if it were a weapon. "Once it is filed, your case will be considered in due course by this Chamber." "How can I help?" asked Jace, emerging into the room. The minotaurs immediately shifted their bellowing to him. #figure(image("001_The Gorgon and the Guildpact/01.jpg", width: 100%), caption: [Boros Battleshaper | Art by Zoltan Boros], supplement: none, numbering: none) "Guildpact!" roared the minotaurs. "The Syndicate lied about the terms of our agreement!" "Unfair! They're trying to disrupt our summit!" Jace conjured words in Lavinia's thoughts. "#emph[Sorry I'm late. Was this why you summoned me?] " "#emph[No] ," came Lavinia's thought in reply. "#emph[Petty dispute. I can handle them. I have something else that requires your attention.] " Jace tried to smile in what he hoped was a welcoming fashion at the minotaurs. "#emph[Is it murder? ] " "#emph[Why do you say that?] " "#emph[Because you're making that face. Your 'there's been a murder' face.] " "#emph[More than one, in fact. I have a 'there's been a murder' face?] " "#emph[What's this summit they're talking about?] " "#emph[Aurelia, guildmaster of the Boros, is hosting three other guild leaders at Sunhome tonight. The Legion is concerned about security, and the Orzhov apparently aren't helping matters.] " "Guildpact, what is your ruling?" the minotaurs insisted. Jace stood before the lead minotaur, a head shorter and with two fewer enormous horns. "You will file a proper complaint with Deputy Lavinia," he said, to a chorus of scoffing. "Return to Sunhome, and the deputy will handle it in due course according to Chamber procedure." Jace held his breath. He was the embodiment of the concord between Ravnica's guilds, a manifestation of stability, but he was also a very alive and mortal sack of organs. Every time he exercised his power as Guildpact, he felt both a sense of grand, mystical authority and a not-so-mystical sense that everyone on Ravnica was about to stomp a lot of times on his gastrointestinal or facial areas. He exhaled only when the lead minotaur sheathed his axe. #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) Sunlight angled into the Chamber windows from just above the skyline. Jace studied a page of notes from the crime scene. The cause of death in every case: petrification. He looked up at Lavinia. "Are we sure they're victims? Somebody didn't just... carve very lifelike statues? Really fast?" Lavinia shook her head. "Not likely. These citizens have been confirmed missing. And the petrified bodies were all found in Rozlad Square." "Golgari turf. Near the tunnels of the Stonefare." "But not inside it. The statues were out in the open. Displayed. And there's more." "Don't tell me. The killer arranged their bodies to form the Golgari symbol." Jace snapped his fingers. "No! They're arranged to spell out the #emph[killer's name] . In the shapes of his terrified victims." "Close." "Oh?" "They spell out #emph[your] name." "...Oh." Lavinia nodded. "Oh." Jace heaved a breath. He really needed to get a desk at some point, with a big leather-bound chair that he could slump into at times like this. "Well. All right." #figure(image("001_The Gorgon and the Guildpact/02.jpg", width: 100%), caption: [Lavinia of the Tenth | Art by Willian Murai], supplement: none, numbering: none) "We don't think the connection to you is public, yet. Some of my officers covered the victims and moved their bodies offsite. And we're not telling the families about the message they spell out." "I think that's wise." "On the other hand, the letters they make are pretty clear. We can't exactly reposition their limbs without damaging them." "Was there anything else at the scene? Any other message?" "Like what?" "A time. An address." "We found nothing like that." "Was there any link between the victims? Anything in common?" "They're from all over. The killer must have transported them from multiple districts." Jace hunted through the list of details, not even sure what he was hoping to find. Nothing seemed to connect. But as his eyes flicked across the page, a chill sensation sank into his stomach. "Are these names right?" "The victims'? As far as we know." "<NAME>. <NAME>. <NAME>." "What is it? Do you know them?" "Not exactly. Lavinia, I need to visit the scene immediately." She nodded and marched toward the door. "I'll get some lawmages to accompany you." Jace stopped her. "No. Not this time. Clear out all your officers and mages from Rozlad Square. I'm going alone." Lavinia's brows dropped low over her eyes. "Into the killer's trap? I won't allow it. Nor will a shred of logic." "Don't argue. Just keep everyone away from that location until I say. Go to Sunhome. Reassure the Boros." She pointed at her face. "Do you know the face I'm making now? It's a new one. It's my 'I'm considering committing #emph[your] murder' face." "I know that face, actually. But just trust me. Keep everyone away from there, and head to the summit. Please." The victims' names meant something to Jace that it would never mean to Lavinia, or to any other planebound citizen of Ravnica. <NAME>. <NAME>. <NAME>. Innistrad. Shandalar. Zendikar. #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) Rozlad Square was dark and quiet, its walls covered in fungi and lichens. It was empty of Lavinia's officers, but it was not abandoned. In the center of the plaza stood a figure in a jade green cloak, her face obscured by a hood. Possibly human, judging by the silhouette. And she was certainly there to see Jace. Only a Planeswalker would know the names of all those worlds. And only a Planeswalker who knew that #emph[Jace] was a Planeswalker would target him in particular, by selecting victims by those names. Whoever petrified those bodies knew a lot about <NAME> that he had tried to keep tightly under wraps. "I'm glad you got my message," said the woman. "You have my attention," said Jace. "I'm alone. So let's not bring other Ravnicans into this." "Oh, I've sent my compatriots away." The woman pulled back her hood with one hand, and produced a long dagger with the other. She was human, gaunt and dark-eyed, with a collar of spikes under her cloak. "So it's just the two of us. Why don't you come closer." #figure(image("001_The Gorgon and the Guildpact/03.jpg", width: 100%), caption: [Assassin Token | Art by <NAME>], supplement: none, numbering: none) Jace frowned, but stepped closer. "I'm not armed. I don't want anyone else harmed. I just want to talk. But I don't think that's what you want. Do you mind if I read you?" Jace focused his mind, preparing the spell to reach into the thoughts of the woman before him. But before he could peer into her mind, the woman stiffened. A cry made it halfway out of her throat before stone spread over her and enveloped her form. She became a stone statue before his eyes, a lifeless object. "Have you already read #emph[me] , <NAME>?" came a different woman's voice from behind him. Jace spun around to look, and then he immediately averted his eyes. Before him was a gorgon. Her mane of snakelike tendrils undulated around her head. Her eye sockets glowed like lanterns in the gloom, but they did not seem to be aimed at him. He found he could still move and breathe. "Vraska," he said. "No, I haven't." "But you've heard of me." "I didn't know you were a Planeswalker. But I'd heard your name." "I have <NAME> at an informational disadvantage, then. How does that feel?" she asked, strolling about the square around him. "Have you deduced why you're here?" "I suspect you brought me here because you want to show me something," said Jace, blinking downward, trying to resist the urge to follow her with his eyes. "I just hope it's not that gaze of yours." "No, no, no. I want you to show #emph[me] , Beleren. I arranged this visit because I want you to prove to us what's inside you. Show us whether you'll be our ally. An ally of Ravnica." "Murdering Ravnicans is a strange way to be Ravnica's ally," Jace said to the cobblestones. "So is stealing control of the Guildpact!" Vraska snapped. Her tendrils snaked and knotted frantically, then slowly calmed down again. "This not your plane. And yet you take such a strong interest in it." #figure(image("001_The Gorgon and the Guildpact/04.jpg", width: 100%), caption: [Jace vs Vraska | Art by <NAME>], supplement: none, numbering: none) "I am only trying to keep the guilds from killing each other. This responsibility has fallen to me, and I take it seriously. I assume that you haven't brought us here to offer your help." "So what #emph[do] I want?" Jace considered this. "To destroy me." "Why would I want that?" "To... take my place." He didn't know if anyone else could become the Living Guildpact after him. But he knew that if there weren't one, it would certainly open doors for an ambitious gorgon. "No. You want to rule Ravnica." "You being dead would conveniently free my hands. You and your colossal cheat have imposed artificial limits on me. So, yes," she said casually. "I'm ready to kill you now." Vraska snapped around and looked Jace full in the face. Her tendrils swam in the air and her eyes flashed, illuminating Jace's form and lighting the plaza around him. Instead of turning to stone, Jace melted away into nothingness. Or at least the image of him did. "Can we dispense with the illusions, then?" said Vraska loudly to the air around her. Jace appeared from behind a column. "As long as you actually send Milada, Kobrev, Zdenya, and Dibor away." Vraska smirked. "Four assassins, plus the one you killed yourself," Jace said. "I appreciate the compliment. But I think you're fully able to kill me on your own." Vraska gestured a signal toward the corners of the plaza. Shadows shifted near the walls as hiding figures moved away. Jace felt their minds grow distant. "Thank you. Are you going to kill me now?" asked Jace, now truly averting his gaze. Vraska shook her head reprovingly. "Think, now. That's not my ideal scenario, is it?" "Probably not. Magical enforcement of the Guildpact can be used to your advantage. Especially if that Guildpact happens to be a person." "Correct." "So you want to leave me in the office of the Guildpact, and manipulate me. Swing my decisions in your favor. I presume you have something on me? Some form of leverage?" Vraska's tendrils rippled around her face. Jace caught sight of a fangy smile. "Tell me, do you know the names of all the assassins who currently surround the home of <NAME>?" Jace's face darkened. "The person who seems to live in Emmara's home is one of my illusions," he said carefully. "Emmara has gone into deep cover. Her entire house is an elaborate trap. Your assassins will be arrested as soon as they strike." #figure(image("001_The Gorgon and the Guildpact/05.jpg", width: 100%), caption: [Emmara Tandris | Art by <NAME>], supplement: none, numbering: none) "Probably a bluff," said Vraska. She strolled in a semicircle, observing Jace, until she was standing behind him. "But a sufficient one. It doesn't matter anyway. What's really going to happen is that I'm going to threaten many, many things you care about. And then you are going to agree to work for me." "That is not going to happen." "Oh, but I can make things very uncomfortable for you. Just imagine the headlines. 'The Living Guildpact Unable to Prevent Petrification Murders!' 'Ten More Statues Left on Doorstep of Chamber of the Guildpact!' Not to mention the angry, angry guild representatives I'll have storming your chambers." "Drop this now. Go back underground. If you make yourself unobtrusive, I can handle quieting down this case. And Lavinia." "Become my assistant, and you won't have to deal with her again. Every person who crosses me will meet their deserved fate." "I've told you no. Ravnica is under my protection." Vraska hissed, suddenly close behind him, and Jace felt a tendril touch his ear. "How fortunate for Ravnica," she snarled. "Are you going to protect it the way you protected Kallist? Or Kavin?" She had certainly dug deeply into his past. He wondered what else she had found out about his life, and what her sources could be. "And what about <NAME>?" "I've made mistakes, yes. But I choose to use my position to atone for—wait, what about Garruk?" Vraska snorted. "You don't know what's become of him, do you?" "Why? What's happened?" "Never mind. I'm sure you've already failed him as well. You're a plague, Beleren. A scourge to all those you claim to protect. Declaring your loyalty to me will be your first favor to this world." A tendril wrapped around Jace's neck. Jace grabbed at it and tried to peel it back, but Vraska was strong, and her hair engulfed his face. He felt his throat clamp shut as the tendrils slithered tighter and tighter. Jace struck into her mind, and immediately wished he hadn't. Her thoughts swirled with hundreds of ways of killing him or making him suffer. He saw himself choked to death. Tossed from a bridge in a sack. Pulled down into the muck of the undercity tunnels by grimy, clawed hands. Paralyzed and forced to watch snakes crawl into his clothes, while feeling their needle-like fangs sink into him. Her creativity was boundless. He needed to push deeper, but he also needed to breathe. He conjured a spell. Vraska was not impressed by the first illusion of another Jace lunging at her. She batted it away and it dissipated instantly. But the next Jace rushed toward her quickly enough to slash at her cheek with hands that were sharp as daggers. She hissed and clawed the image away. But the next one came even faster, and the next bolted toward her from the opposite direction. Jace felt the gorgon's grip loosen as he sent image after image of himself at her. As the Jaces attacked, they changed. Their hands became claws. Their hair became snakes. Their eyes glowed with sinister light. They hissed as they emerged from the shadows from all directions, surrounding Vraska in a nightmarish horde. Vraska couldn't fight them all. She began blasting them with her gaze. They came at her, turning to stone one by one as she lashed them with petrification. As the stone statues multiplied, they became a cage. She was penned in by a dozen effigies of Jace. He hoped they were real enough to her to make her feel trapped, at least for the moment. Vraska held the real Jace by her claws. She squeezed his neck again. "Send them away," Vraska whispered, and his breath was cut off. And then the statues' lips began to move. "You win," they said in unison, in Jace's voice. #figure(image("001_The Gorgon and the Guildpact/06.jpg", width: 100%), caption: [Jace's Ingenuity | Art by <NAME>], supplement: none, numbering: none) "Back them off." She said it like a snarl, but there was a flicker of hesitation in her voice. The statues retreated slightly, but she was still caged by their stone forms. "Jace will help you," they said. "But he has to know the plan first." "You'll do what I tell you, when I tell you, Beleren." "Kill him, and he can't influence the guilds for you," the statues intoned. "He has to know whether you'll be a worthy partner. Whether you're smart enough. Tell us. How do you intend to take over this city?" Vraska squeezed for a moment, pressing all the blood out of Jace's head. But her grip relaxed again. "With your help, I will neuter all the guildmages. Disempower them by having you redraw territory borders, rupturing their mana bonds. Defang the guilds by taking their spellcasters. Then, one by one, I will assassinate the guild leaders." "You, Vraska, will assassinate #emph[every] guildmaster?" "I was born to kill," she said. "And many in the shadows answer to me." "Thank you," said the statues. Then they all tilted their heads. "Did you get all that?" they chanted. Vraska looked around at all of them. "What?" For a moment, the statues' eyes flashed, bathing Vraska in a blinding strobe. She put a hand up to her face to shield herself from the glare. "There is a summit of many guild leaders going on at Sunhome tonight," droned the Jace statues. "Your statements have been broadcast to all those who've attended." Vraska snarled. "Deal's over, Beleren," she said. "Now you die." She grasped the neck that she held in her claws, and crushed it. It broke into rocky pieces. She looked down, and instead of seeing a dead Jace, she saw that she had been holding the petrified form of her own assassin—the woman she had killed earlier. He had switched places with her at some point. Vraska howled in fury. She spun and slashed at the cage of Jaces. Instead of breaking into pieces or dissipating into the air, they closed in on her. They sprouted ever more snakes from their heads, their eyes, their fingers, and constricted in around her. They grabbed her wrists. They intertwined with her tendrils. With a shriek, she blasted them all back. Then she took a breath, closed her eyes, and planeswalked away. #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) "I don't know how you did it," said Lavinia, back at the Chamber of the Guildpact. "But there she was, floating in the middle of Sunhome, telling her plans to everyone at the summit. A remote confession. But what's to say she won't return?" "She'll lay low for a while," Jace said, rubbing the welts on his neck. "It should buy us some time, I hope." "You couldn't just end her? Or command her to stop?" Jace shook his head. "I barely had the presence of mind to distract her, distort her perceptions. She certainly wasn't giving me an opening to destroy her mind—she fought me at every step." "At least the guilds are aware of her now," said Lavinia. "The Boros want to turn the undercity upside down. They seemed almost giddy about it." He looked out the window. Streetlamps threw illumination down at the cobblestones and up at the city spires. The skyline looked like the looming mountain ranges of Zendikar. "I'm sure you and Isperia can help guide them." #figure(image("001_The Gorgon and the Guildpact/07.jpg", width: 100%), caption: [Mountain | Art by Adam Paquette], supplement: none, numbering: none) Lavinia studied him. "You've got that face. Your 'I'm going to be away for a while, and don't ask where I'll be' face." "It should only be a couple of days." "You should stay. There'll be arbitrations to do. Reassurances." He gathered his cloak around him. "The Guildpact is supposed to keep people safe," he murmured. "But I've only brought them more danger. And I think something's up with Garruk." "Who?" "Someone I may not have failed yet."
https://github.com/yonatanmgr/university-notes
https://raw.githubusercontent.com/yonatanmgr/university-notes/main/0366-%5BMath%5D/03661101-%5BCalculus%201A%5D/src/lectures/03661101_lecture_11.typ
typst
#import "/template.typ": * #show: project.with( title: "חדו״א 1א׳ - שיעור 11", authors: ("<NAME>",), date: "8 בפברואר, 2024", ) #set enum(numbering: "(1.א)") === (טענה) מבחן המנה הכללי יהי $sum an$ טור חיובי (כאן $an > 0$). + אם קיימים $0<q<1$ ו-$N_0 in NN$ כך שמתקיים: $frac(a_(n+1),a_n) <= q, forall n >= N_0$, אזי $sum an$ מתכנס. + אם $exists N_0 in NN$ כך ש-$frac(a_(n+1),a_n) >= 1, forall n >= N_0$, אזי $sum an$ מתבדר. ==== הוכחה + נניח $frac(a_(n+1),a_n) <= q < 1, forall n >= N_0$. נרשום: $ an = a_N_0 dot overbrace(a_(N_0+1)/a_N_0, <=q) dot overbrace(a_(N_0+2)/a_(N_0+1), <=q) dot dots.h.c dot overbrace(an/a_(n-1), <= q), forall n > N_0 $ ואז $0< an <= overbrace(a_N_0 dot q^(n-N_0), b_n), forall n > N_0$. ו-$sum a_N_0 q^(n-N_0)$ מתכנס כטור הנדסי עם המנה $q$, כאשר $abs(q) < 1$. לכן, לפי מבחן ההשוואה בין טורים חיוביים גם $sum an$ מתכנס. + מהנתון נובע $an >= a_(n-1) >= dots >= a_N_0, forall n > N_0$. כלומר, $an >= a_N_0, forall n > N_0$ ולכן $an cancel(->) 0$. \ אחרת, $0>=a_N_0$, בסתירה ל-$a_N_0 > 0$ ואז הטור $sum an$ מתבדר. #QED === (טענה) מבחן המנה הגבולי יהי $sum an$ טור חיובי (כאן $an > 0$). נסמן $l = overline(lim) frac(a_(n+1), an)$ ו-$u = underline(lim) frac(a_(n+1), an)$. + אם $l < 1$ אזי הטור $sum an$ מתבדר. + אם $u > 1$ אזי הטור $sum an$ מתבדר. ==== הוכחה + נניח כי $l < 1$. כלומר, $exists q. tb(l<q<1,q=l+epsilon "," exists epsilon >0,"")$. מהטענה המתאימה עבור $limsup$ נובע ש-$frac(a_(n+1), an) <= q$ כמעט תמיד. כלומר, $exists N_0 in NN$ כך ש-$frac(a_(n+1), an) <= q, forall n >= N_0$, ואז לפי מבחן המנה הכללי (סעיף 1) הטור $sum an$ מתכנס. + נניח כי $u > 1$. כלומר, $exists Q. tb(1<Q<u,Q=u-epsilon "," exists epsilon >0,"")$. מהטענה המתאימה עבור $liminf$ נובע ש-$frac(a_(n+1), an)>=Q = u- epsilon$ כמעט תמיד. יחד עם זאת, נובע גם כי $frac(a_(n+1), an) >= 1$ כמעט תמיד. כלומר, $exists N_0 in NN$ כך ש-$frac(a_(n+1), an) >= 1, forall n >= N_0$. ואז, ממבחן המנה הכללי (סעיף 2) הטור $sum an$ מתבדר. #QED ==== הערה אם $l=1$ או $u=1$ לא ניתן לדעת על ההתכנסות של הטור $sum an$: - $sum 1/n$ מתבדר, וגם $frac(a_(n+1), an) = frac(n, n+1) -> 1$ $arrl$ $l=u=1$. - $sum 1/n^2$ מתכנס, וגם $frac(a_(n+1), an) = frac(n^2, (n+1)^2) -> 1$ $arrl$ $l=u=1$. #pagebreak() === (טענה) מבחן העיבוי יהי $suminf(a,n)$ טור כך ש-$a_n >= a_(n+1) >=0$ לכל $n in NN$. אזי: $suminf(a,n)$ מתכנס $iff$ $sum_(n=0)^oo 2^n a_(2^n)$ מתכנס. ==== רעיון ההוכחה $ suminf(a,n) &= a_1 + (a_2 + a_3) + (a_4 + a_5 + a_6 + a_7) + (a_8 + a_9 + dots.h.c + a_15) + dots.h.c \ &<= a_1 + (a_2 + a_2) + ( a_4 + a_4 + a_4 + a_4) + (a_8 + a_8 + dots.h.c + a_8) + dots.h.c \ &= a_1 + 2a_2 + 4a_4 + 8a_8 + dots.h.c = sum_(n=0)^oo 2^n a_(2^n) \ &<= a_1 + (a_2 + a_2) + (a_3 + a_3 + a_4 + a_4) + (a_5 + a_5 + a_6 + a_6 + a_7 + a_7 + a_8 + a_8) + dots.h.c \ &<= 2 suminf(a,n) $ === (דוגמה) לאיזה $p in RR$ הטור $sum_(n=1)^oo 1/n^p$ מתכנס? ==== פתרון נחלק למקרים: - אם $p<=0$ הטור מתבדר כי $1/n^p cancel(->) 0$. - אם $p>0$ נשתמש במבחן העיבוי: $sum_(n=1)^oo 1/n^p$ מתכנס $iff$ $sum_(n=0)^oo 2^n 1/2^(n p)$ מתכנס. אך הטור האחרון הוא הנדסי, עם המנה: $ q = frac(2^(n+1) dot frac(1, 2^((n+1) p)), 2^n dot 1/2^(n p)) = 2 dot 1/2^p = 2^(1-p) $ ואז הטור מתכנס אם ורק אם $2^(1-p) = abs(q)<1$ כלומר כאשר $p>1$. כלומר - הטור $sum 1/n^p$ מתכנס אם ורק אם $p>1$. === (דוגמה) האם $sum_(n=2)^oo 1/(n ln(n))$ מתכנס או מתבדר? ==== פתרון הטור מתבדר כי: $sum_(n=0)^oo cancel(2^n) dot 1/(cancel(2^n) ln(2^n)) = sum_(n=1)^oo 1/(n ln(2))$ מתבדר. == טורים עם סימנים מתחלפים === (הגדרה) מתכנס בתנאי אם $sum an$ מתכנס אבל הטור $sum abs(an)$ מתבדר, אז הטור $sum an$ נקרא *מתכנס בתנאי*. === (משפט) משפט לייבניץ תהי $(an)$ סדרה חיובית, מונוטונית יורדת ל-$0$. אזי הטור $sum_(n=1)^oo (-1)^n an$ מתכנס. ==== הוכחה נוכיח שמתקיים קריטריון קושי להתכנסות טורים. נתון $an > 0$ ו-$lim an = 0$. אזי, $forall epsilon>0 exists N(epsilon) in NN$ כך שמתקיים: $0 < a_(N(epsilon)) = abs(a_(N(epsilon))-0)<epsilon$. אז, עבור $m >= N(epsilon)$ ו-$p in NN$ נקבל: $ abs(sum_(n=m+1)^(m+p) (-1)^n a_n) &= abs((-1)^(m+1) a_(m+1) + (-1)^(m+2) a_(m+2) + (-1)^(m+3) a_(m+3) + dots.h.c pm a_(m+p)) \ &= abs((-1)^(m+1) (a_(m+1) - a_(m+2) + a_(m+3) - dots.h.c pm a_(m+p))) \ &= underbracket(a_(m+1) - a_(m+2), >=0) + underbracket(a_(m+3), >= 0) - dots.h.c pm a_(m+p) <= a_(m+1) < a_(N(epsilon)) < epsilon $ #QED === (טענה/תרגיל) נתון $an >= 0$ לכל $n in NN$ ו-$limsup root(n, an) = +oo$. צ״ל כי הטור $sum an$ מתבדר. ==== הוכחה מהנתון קיימת תת״ס $(ank)$ כך ש-$root(n_k, ank) -> +oo$. כלומר, $forall M>0 exists k_M in NN : forall k > k_M, root(n_k, ank)>M$. בפרט, עבור $M=2$: $ exists k_0 in NN : root(n_k, ank) > 2, forall k > k_0 \ ank > 2^(n_k), forall k > k_0 => a_n cancel(->) 0 $ ואז הטור $sum an$ מתבדר.
https://github.com/roenass/cocteles
https://raw.githubusercontent.com/roenass/cocteles/main/README.md
markdown
[//]: # %!TEX TS-program = markdown # A Collection of Cocktails The '.typ' file is the Source of Truth. It's a [Typst](https://github.com/typst/typst) document. The PDF is simply this document, typeset. It uses the `in-dexter` package for manual indexing, which is available in the [Typst Universe](https://typst.app/universe). ## The Collection The cocktails in this collection are hand-gathered by an erratic process of chasing rabbitholes. Among of these rabbitholes, one or two deal with drinking in particular settings in Hollywood's distant past. Some liberties have been taken, as the document explains; and, obviously, for many cocktails there are multiple subtle or not so subtle variations, sometimes vehemently championed by factions well dug-in in that trench on that hill they've chosen to die on. Choices have been made, but nothing's written in stone. Play around.
https://github.com/maantjemol/Aantekeningen-Jaar-2
https://raw.githubusercontent.com/maantjemol/Aantekeningen-Jaar-2/main/Financieel%20management/aantekeningen.typ
typst
// Update this import to where you put the `lapreprint.typ` file // It should probably be in the same folder #import "../template/lapreprint.typ": template #import "../template/frontmatter.typ": loadFrontmatter #import "@preview/drafting:0.2.0": * #let defaultColor = rgb("#f2542d") #show: template.with( title: "Financieel Management in de Publieke Sector", subtitle: "Samenvatting + aantekeningen", short-title: "Public Finance Samenvatting", venue: [ar#text(fill: red.darken(20%))[X]iv], // This is relative to the template file // When importing normally, you should be able to use it relative to this file. theme: defaultColor, authors: ( ( name: "<NAME> . ", ), ), kind: "Samenvatting", abstract: ( (title: "Samenvatting", content: lorem(100)), ), open-access: true, margin: ( ( title: "Key Points", content: [ - #lorem(10) - #lorem(5) - #lorem(7) ], ), ), font-face: "Open Sans" ) #set page( margin: (left: 2in, right: 0.8in), paper: "us-letter" ) #let marginRatio = 0.8 #let default-rect(stroke: none, fill: none, width: 0pt, content) = { pad(left:width*(1 - marginRatio), rect(width: width*marginRatio, stroke: stroke)[ #content ]) } #set-page-properties() #show terms: it => [ #margin-note(rect: default-rect, side: left, stroke: 0pt)[#text(defaultColor, weight: 600, size: 10pt)[#it.children.first().term:]\ #it.children.first().description] ] #set heading(numbering: none) #show heading: set text(defaultColor, weight: "medium") // = Samenvatting <samenvatting> // Cijfer is 100% tentamen. Alles gaat via artikelen // // You can put this after the content that fits on the first page to set the margins back to full-width // = Tentamenvragen: // - Principaal-agent theorie/probleem / Common pool-probleem // - Tentamenvraag over verbetering: gebruik transparantie = Introductie <introductie> Het gaat vooral om bedrijfseconomische instrumenten in de context van de publieke sector. Algemene economie houdt een belangrijke rol. / Financieel management: Planning en beheersing van financiële taken en transacties. Niet de *wat* en *waarom* maar de *hoe* == Markfalen: Markt faalt als de markt niet optimaal werkt. De overheid houdt dat in de gaten. Collective goederen zijn goederen die niet door de markt worden geleverd. Asymmetrische informatie is ook een reden voor marktfalen. == Hoe wordt er ingegrepen? Er zijn een paar manieren waarop er wordt ingegrepen: - Regulering: De overheid kan regels opleggen. - Belastingen: De overheid kan belastingen heffen. - Subsidies: De overheid kan subsidies geven. - Uitbesteed: De overheid kan dingen uitbesteden. - Zelf produceren: De overheid kan zelf dingen produceren. == Gaat het ingrijpen goed? Nee, lang niet altijd. Dit worden *Budgetimperfecties* genoemd. / Budgetimperfecties: Markt imperfecties maar dan in de publieke sector. == Non-market failures: Non-market failures zijn falen van de overheid. Dit kan komen door: - Output slecht gedefinieerd en moeilijk te meten. - Kwaliteit is moeilijk vast te stellen. - Geen concurrentie. - Geen criteria voor stopzetten beleid (vergeten dingen stop te zetten) - Beloning voor formuleren van probleem en ontwerpen van oplossing. Er wordt niet terug gekeken. - Politieke conjunctuur: == Principaal-agent theorie/probleem: - Kiezer: Principaal - Politicus: Agent - Probleem: politici willen _rents_ (andere doelen dan de kiezer) - Speelt ook in relatie politici $<->$ ambtenaren Een oplossing zou een contract kunnen zijn. Dit is lastig, want het is onzeker en complex. Je kan niet alles vastleggen in contracten / Open einde regelingen: Begrotingsbesluit waardoor een financiële regeling geen budgettair plafond wordt toegekend == Praktische voorbeelden: - Geen verborgen uitgaven/fondsen - Beperk *open einde regelingen*. - Beperk _contingent liabilities_ (a potential liability that may occur in the future) - Begroot (raam) niet te optimistisch - Onafhankelijke informatie Zie voor meer voorbeelden de slides van _Week 1_. #pagebreak() == Fasen: Er zijn verschillende fasen 1. Planning (besluitvorming) 2. Beheersing (management) controle, uitvoering 3. Verslaggeving 4. Controle en verantwoording / Adagium: running a government like a business. == New Public Management (NPM): NPM zegt dat methoden en technieken uit de marktsector ook in de publieke sector kunnen worden toegepast. *Adagium* == _Gevolgen van NPM_: - Meer nadruk op efficiëntie - Planning- en budgetteringstechnieken - Sturen op prestaties - Meer concurrentie - Managementtechnieken - Privatisering - Terminologie is overgenomen == _Kritiek op NPM_: - Meer autonomie $->$ minder democratische controle - Bureaucratisering - Fragmentatie van beleid en uitvoering - Steeds complexere informatie - Managementcultus Gevolgen hiervan zijn crisissen en schandalen, en soms wordt er ook minder doelmatig en "goed" gepresteerd. #pagebreak() = Hoe werkt het systeem nu? <systeem> == BBP: Bruto Binnenlands Product Is niet zo nuttig om over de tijd te vergelijken omdat een verandering kan komen door een verandering in prijs of in hoeveelheid. Daarom is het nuttiger om te kijken naar het _reële BBP_. == Begrotingssaldo Financieringssaldo: het tekort of het overschot op de begroting van het Rijk exclusief de aflossing op de staatsschuld, uitgedrukt in geld. / Tekortnorm: 3% van het BBP == Primaire saldo: Alle overheidsinkomsten min alle overheidsuitgaven exclusief rentebetalingen op de staatsschuld. == Wanneer is de staats schuld stabiel? Gelijk aan tekort $S$ delen door groei $G$ van het BBP. $ -S/G = d_0 $ == Schulddynamiek: $ Delta b = (i-g)/(1+g)b_(t-1) - p s_t + d d a_t $ $g$ = groei / Annuïteit: jaarlijks gelijk blijvend bedrag om te betalen == Annuïteit: == Contante waarde: Hoeveel moet ik nu op een spaarrekening zetten om over $x$ jaar een bepaald bedrag te hebben? bvb: $ 613,91 = 1000/(1+0.05)^10 $ 613,91 inleggen om over 10 jaar 1000 te hebben == Houdbaarheidssaldo: De contante waarde van alle toekomstige overheidsoverschotten en -tekorten. Bij een houdbaarheidstekort moeten toekomstige generaties betalen voor de huidige generatie. == Vermogenssaldo: Voor financiële gezondheid kijk je naar het vermogenssaldo. Dit is de som van de bezittingen en schulden van de overheid. == trendmatig begrotingsbeleid: Begrotingsbeleid dat is gericht op het stabiliseren van de economie op de lange termijn. Dit is een vorm van contracyclisch beleid. == MTO (middellangetermijnraming): Een raming van de overheidsfinanciën voor de komende jaren. Dit is een belangrijk instrument voor het begrotingsbeleid. - Saldo waarbij de schuld stabiel blijft op 60% van het BBP Is je schuld minder dan 60% van het BBP? Dan mag je een tekort hebben van 1% van het BBP. Is je schuld groter dan 60% van het BBP? Dan moet je een overschot hebben van 0,5% van het BBP. MTO gehaald? Dan mogen de uitgaven niet sneller stijgen dan de economie groei. Niet gehaald? Dan moet je *minder* uitgeven. == Buitensporig tekort: Buitensporig tekort: - feitelijk tekort > 3% van het BBP - begrotingstekort > 3% van het BBP er is ook een Buitensporig tekort als je schuld > 60% van het BBP de overschrijding moet met 1/20e per jaar worden verminderd = Hoe wordt dit systeem? <systeem_later> Waarom wordt het veranderd? Omdat het te ingewikkeld is. We willen ook zeker weten dat schulden dalen. Bepaalde dingen willen we ook stimuleren. Bijdragen aan anticyclische beleid. In het nieuwe raamwerk wordt er alleen gestuurd op een uitgavenpad. Er wordt niet meer gestuurd op een tekort. Er wordt ook niet meer gestuurd op een schuld. Er wordt alleen gestuurd op een uitgavenpad. MTO komt te vervallen. evenals de eis van afname van 1/20e per jaar. == Uitgavenpad: / Netto Primaire uitgaven: Alle ontvangsten min alle uitgaven exclusief rentebetalingen op de staatsschuld. Alle lidstaten moeten een uitgavenpad opstellen en alle lidstaten moeten een begrotingsinspanning doen. == Schuldwaarborg: schuldratio > 60%: - tussen 60% en 90%: 0.5% per jaar - > 90%: 1% per jaar == Back loading clausule: Ieder jaar dezelfde inspanning doen. == Waarborg: Als je tekort groter is dan 3% van het BBP, dan moet je een begrotingsinspanning doen van 0.5% van het BBP. = Budget & Begroting _A budget is the financial mirror of society’s economic and social choices._ de financiële gevolgen van genomen beslissingen. Functie van de begroting: - *Afweging (allocatie, keuze)*: laat de overheid toe om prioriteiten te stellen en middelen toe te wijzen aan verschillende beleidsdomeinen - *Staatsrechtelijk:* de begroting is een wettelijk document dat de toestemming van het parlement vereist - *Democratisch:* de begroting is een instrument voor de controle van de uitvoerende macht door het parlement - *Macro-economisch:* de begroting heeft een impact op de economie - *Beheer:* de begroting is een instrument voor het beheer van de overheidsfinanciën - *Verantwoording:* de begroting is een instrument voor de verantwoording van de overheid aan de burgers - *Controle:* de begroting is een instrument voor de controle van de overheid door de burgers == Waar heeft de begroting betrekking op? - *Input:* Uitgaven en ontvangsten, kosten en baten - *Prestatie/output/programma:* Verantwoord Begroten - *Outcome/effect:* Zero based budgeting: elk jaar beginnen met een leeg budget == Wettelijke basis: - *Grondwet:* de begroting is een wettelijk document - *Begrotingswet zelf* == Principaal en agent: - Agent (kabinet, B&W, GSetc.) stelt begroting op - Principaal (parlement, gemeenteraad) keurt begroting goed *EU:* - Commissie stelt begroting op - EP keurt goed (meerderheid) - Raad: unanimiteit == Regels: - Volledigheid - Vergelijkbare maatstaf - Bruto ramen - Openbaarheid - Prealabiliteit - Periodiciteit - Onderworpen aan controle #pagebreak() == Periodiciteit: - Meestal: één jaar, kalender jaar - Rijksbegroting: 4 jaar, - EU: 7 jaar, meerjarenbegroting, == Begrotingsproces: De rijksbegroting bestaat uit hoofdstukken. Elk hoofdstuk heeft een eigen minister. === Hoofdstukken: - De Koning, Staten Generaal, Hoge Colleges van Staat. - Departementen zoals buitenlandse zaken, defensie, etc. - Begrotingsfondsen zoals gemeentefonds === Miljoenennota: toelichting op de rijksbegroting Derde dinsdag van september: aanbieding begroting(en) aan Tweede Kamer. Daarna behandeling in de Tweede Kamer. Dan evenetuele wijzigingen en behandeling in de Eerste Kamer. === Uitvoering - *Voorlopige rekening*: verantwoording over het afgelopen jaar (t-1) - *Voorjaarsnota*: bijstelling van de begroting (t) - *Begroting*: begroting voor het volgende jaar (t+1) - *Najaarsnota*: bijstelling van de begroting (t) #pagebreak() = Baten, lasten en belastingfaciliteiten: Het wordt bijna overal gebruikt, behalve bij het Rijk en de EU. Bij hun is het kas en verplichtingen. Alles gaat om vermogen. Het gaat om je netto vermogen. Er zijn twee belangrijke begrippen: - *Exploitatie begroting:* inkomsten en uitgaven, = baten en lasten / resultatenrekening - *Balans:* bezittingen en schulden Je begint het jaar met ja *balans*. Vervolgens gebeuren er allemaal dingen. Aan het einde van het jaar heb je een nieuwe *balans*. De stromen die er tussen zitten zijn de *baten* en *lasten*. == Waarom dit stelsel? - Het maakt zuivere afweging mogelijk - Investeringen worden niet zoveel benadeeld, omdat afschrijven - Verkoop van bezit is geen ontsnapping als je in de problemen zit. - Het maakt de werkelijke kosten zichtbaar. - Beter inzicht in toekomstige lasten en risico's - Inzicht in bezittingen en schulden - Praktisch is het handig dat iedereen hetzelfde systeem gebruikt. In de praktijk is dat helaas niet zo. - Je bouwt reserves op. Dat kan niet bij begrotingen - Schuiven voor het idee dat het er beter uit ziet heeft geen zin - Waardemutaties/afschrijvingen worden inzichtelijk == Zuivere afweging: Uitgaven staan niet in de exploitatie rekening maar op het kasstroom overzicht. === Jaarlijkse lasten: - Afschrijvingen - Kapitaallasten (rente) - Eventuele herwaarderingen ($+"/"-$) == Verkoop van bezit: Netto vermogen blijft gelijk. / Toekomstige lasten: AOW, zorg, milieu, stijging waterpeil, etc. == Resultaat: Je toekomstige lasten worden vroeg zichtbaar. Je kan dan ook beter anticiperen. Lasten worden naar voren gehaald. #pagebreak() = Functies van de overheid: - *Allocatiefunctie:* de overheid kan de markt corrigeren (_bijvoorbeeld subsidies voor zonnepanelen_) - *Stabilisatiefunctie:* de overheid kan de economie stabiliseren - *Herverdelingsfunctie:* de overheid kan de inkomensverdeling corrigeren (lorenzcurve) == Belastinguitgaven: / Voorbeelden: Hypotheekrente aftrek, toeslagen Belastinguitgaven zijn eigenlijk kortingen op belastingen die de overheid geeft aan burgers en bedrijven. Dit wordt gedaan om mensen en bedrijven aan te moedigen zich op een bepaalde manier te gedragen. == Fiscale regelingen: Uitzonderingen in het belastingstelsel (zoals heffingskorting). === Gevolgen - Hogere belastingtarieven - Meer complexiteit De fiscale regelingen leiden niet tot meer uitgaven, je krijgt als overheid gewoon minder geld binnen. Je kan het algemeen belastingtarief gewoon verlagen door Hypotheekrente aftrek af te schaffen. Door de Hypotheekrente moet de belasting compenseren op andere plekken. == heffingskorting: Een korting op de belasting die je moet betalen. === Kortingen: - _Algemene heffingskorting_: iedereen krijgt dit - _Arbeidskorting_: als je werkt - _Inkomensafhankelijke combinatiekorting_: als je werkt en kinderen hebt - _Jonggehandicaptenkorting_: als je jonggehandicapte bent - _Ouderenkorting_: als je oud bent - _heffingskorting voor groene beleggingen_: als je groen belegt = Week 5B: Kosten baten analyse (KBA): KBA is een methode om de maatschappelijke kosten en baten van een project in kaart te brengen. == Waardering: wat een mensen leven waard is Veel kosten en baten hebben geen (markt)prijs, daarom moet er worden gewaardeerd. Veel dingen hebben ook te maken met schade aan natuur, ziekte, dood, etc. === Lost earnings: Als iemand overlijdt, dan is er een verlies aan inkomen. Dit kan je berekenen door te kijken naar wat iemand verdient zou hebben. === Willingness to pay: Hoeveel mensen bereid zijn te betalen voor een bepaalde dienst. Dit kan je bijvoorbeeld berekenen door te kijken naar hoeveel mensen bereid zijn te betalen voor een bepaalde dienst. === Contingent valuation: Mensen vragen hoeveel ze bereid zijn te betalen voor een bepaalde dienst. Hoeveel heeft men over voor behoud van plant/dier/mensen === Klopt niet: - Monetariseren van mensenlevens is onjuist, veel zaken zijn niet in geld uit te drukken - Disconteren (waarderen) is onjuist, toekomst is belangrijk == 4 soorten problemen: === Waardering is onnauwkeurig en ongeloofwaardig - Niet alles is in geld uit te drukken, mensenleven is van onschatbare waarde. - Er zit een verschil tussen de waardering van het risico vs de waardering van het leven zelf. - Het maakt ook best wel een verschil of de risico's dicht bij jezelf zijn of niet. === Discontering bagatelliseert toekomstige schade en onomkeerbaarheid problemen - Bedragen in de toekomst zijn minder waard dan bedragen nu. - KBA maakt toekomst minder belangrijk === Geen rekening gehouden met rechtvaardigheid/ethiek \ KBA negeert verdelingseffecten. Het is niet eerlijk dat de ene groep meer betaalt dan de andere groep. Goed criterium is *Pareto-verbetering*. In de praktijk is dit niet altijd mogelijk. Daarom (Hicks-Kaldor) _potentiële_ Pareto-verbetering. Kan als er kan gecompenseerd worden met geld. Werkt niet bij mensenlevens, daar valt niets te compenseren. Dit kan opgelost worden op een aantal manieren: - Sommige dingen niet doen, ook al hebben ze uiteindelijk een goed saldo. - Extra maatregelen toevoegen. === Niet objectief, niet transparant \ KBA werkt met veel benaderingen en schattingen. Dit maakt het niet objectief. We weten veel niet dus we kunnen niet alles objectief beoordelen. Een paar opties: - Beslissen zonder info - Beslissen met een beetje info #pagebreak() == Alternatieven KBA: - _Technology based approach:_ pas de beste / meest **doelmatige** technologie toe - _Verhandelbare emissierechten:_ doelmatig en doeltreffend - _Informational regulation:_ informeer de consument - _Muitcriteria-analyse:_ - Drie soorten criteria: economisch, sociaal (niet meetbaar), ecologisch (meetbaar) - Meet kosten en baten in eigen dimensie - Geef al die verschillende dingen een gewicht - Weeg af met het risico - Tel de scores op en vergelijk - Inhoudelijk geen verschil omdat de gewichten nog steeds vast gesteld moeten worden. - _Risk assessment:_ Alleen mogelijke uitkomsten en hun waarschijnlijkheid, zonder waardering en zonder onderscheid van tijd. - _Cost effectiveness analysis:_ alle varianten om risico te verminderen op een rij. Per onderdeel de kosten vermeld - Gezochten naar de laagste kosten per eenheid minder betalen - _Risk benefit analysis:_ Baten van therapie afwegen tegen de risico's - _Wel KBA maar niet disconteren (terugrekenen)_ - _Breng kosten en baten in eigen dimensie in beeld._ Druk kosten en baten uit in geld als dat kan, bereken daar contante waarde. Netto contante waarde + niet in geld uitgedrukte kosten en baten is de uitkomst.
https://github.com/soul667/typst
https://raw.githubusercontent.com/soul667/typst/main/PPT/typst-slides-fudan/README.zh-CN.md
markdown
**Language**: [\[English\]](README.md) \[简体中文\] # 复旦主题的 Typst 幻灯片模板 本项目是一个复旦主题的 [Typst](https://typst.app/) 幻灯片模板,依赖于 [Polylux](https://andreaskroepelin.github.io/polylux/book/polylux.html) 库,基于其官方主题 [Clean](https://github.com/andreasKroepelin/polylux/blob/9184eeff02c5d03368b21024486ad2a2b8f65e0c/themes/clean.typ)。 ## 预览 ![预览1](images/demo-1.png) ![预览2](images/demo-2.png) ![预览3](images/demo-3.png) ![预览4](images/demo-4.png) ![预览5](images/demo-5.png) ![预览6](images/demo-6.png) ## 使用方法 ### 1. 安装 Typst 或在线使用 Typst Typst 既可以[在线使用](https://typst.app/),也可以[下载安装 `typst` 命令行工具](https://github.com/typst/typst)使用。 初次使用 Typst 时,建议先在线使用,体验完整功能。 ### 2. 导入 Polylux 包 遗憾的是,目前 Typst 的[包管理](https://github.com/typst/packages)功能仍处于试验阶段,因此不像 TeX 那样有一个完整的包管理系统。 如果你在线使用,可以直接在 Typst 的编辑器中导入 Polylux 包: ```typst // 下面的 0.2.0 请自行根据 Polylux 仓库中的最新版本号进行修改 #import "@preview/polylux:0.2.0": * ``` 如果你使用 `typst` 命令行工具,可以跳过本步骤,因为本库已经包含了 Polylux 包作为子模块。 ### 3. 下载和导入本模板 > **TODO** > > 尚未完成在线使用的说明,请暂时按照本地使用的步骤进行。 如果你使用 `typst` 命令行工具,克隆本仓库: ```shell # 如果你安装了 Git: git clone https://github.com/w568w/typst-slides-fudan.git --recursive # 或,如果你安装了 GitHub CLI: gh repo clone w568w/typst-slides-fudan # 或,如果你配置了 Git over SSH: git clone <EMAIL>:w568w/typst-slides-fudan.git --recursive ``` > **注意** > > 请不要忘记 `--recursive` 选项,否则将不会克隆 Polylux。 如果你都没有安装,可以单击仓库页面上的 `Code` 按钮,然后单击 `Download ZIP` 下载本仓库的压缩包,解压后即可使用。 强烈建议你从 `demo.typ` 开始,这是一个简单的示例,演示了本模板的所有功能。 > **注意** > > 由于 `demo.typ` 引用了 `themes` 目录下的库,请勿将 `demo.typ` 单独移动到其他目录下,否则 Typst 将编译失败。 ## 待办事项 - [ ] 完成在线使用的说明 - [ ] 介绍模板的使用方法 ## 协议 本项目的所有代码和文档均以 [GNU 通用公共许可证 v3.0](LICENSE) 协议发布。
https://github.com/vEnhance/1802
https://raw.githubusercontent.com/vEnhance/1802/main/r08.typ
typst
MIT License
#import "@local/evan:1.0.0":* #show: evan.with( title: [Notes for 18.02 Recitation 8], subtitle: [18.02 Recitation MW9], author: "<NAME>", date: [30 September 2024], ) #quote(attribution: [Calvin in _Calvin and Hobbes_])[I like maxims that don't encourage behavior modification.] This handout (and any other DLC's I write) are posted at #url("https://web.evanchen.cc/1802.html"). = Calculus of multiple variables == Multivariate domains vs multivariate codomains In 18.01, you did calculus on functions $F : RR -> RR$. So "multivariable calculus" could mean one of two things to start: - Work with $F : RR -> RR^n$ instead (i.e. make the codomain multivariate). - Work with $F : RR^n -> RR$ instead (i.e. make the domain multivariate). What you should know now is *the first thing is WAY easier than the second*. We're pretty much only going to spend 1-2 lectures on the first and then switch to the second kind for the rest of 18.02. == Components Why is $F : RR -> RR^n$ so much easier? Because there's pretty much only one thing you need to ever do: #align(center)[ *TLDR Just always use components.* ] That is, if $F : RR -> RR^3$ (say), basically 90%+ of the time what you do is write $ F(t) = angle.l f_1(t), f_2(t), f_3(t) angle.r = f_1(t) bf(e)_1 + f_2(t) bf(e)_2 + f_3(t) bf(e)_3 $ and then just do single-variable calculus or calculations on each $f_i$. Need to differentiate $F$? Differentiate each component. Need to integrate $F$? Integrate each component. Need the absolute value of $F$? Square root of sum of components. And so on. (See @brainfart on page 3 for another example.) == Adding two vectors There's a shape of question that comes up in 18.02 sometimes where you need to parametrize some curve that has two different things influencing it. 90%+ of the time you just add the two vectors. The cycloid you saw in class was one hard-ish example of this. The curve looked scary. But you just ignore the shape, and just think about the equation $ bf(r)(t) = angle.l t v , a angle.r + angle.l a cos theta(t), a sin theta(t) angle.r. $ Working out the angle is a bit annoying; but the point is no calculus or theory is involved, just work out the geometry. Then when you want the velocity, just differentiate $bf(r)(t)$, and so on. = Recitation problems from official course / 1: A hunter walks toward the origin along the positive $x$-axis, with unit speed; at time $t = 0$ they are at $x = 10$. Their arrow (of unit length) is aimed always toward a rabbit hopping with constant velocity $sqrt(5)$ in the first quadrant along the line $y = 2 x$; at time $t = 0$ it is at the origin. / 1a: Write down the vector-valued function $bf(A) (t)$ for the arrow at time $t$. (Clarification: this vector starts from the hunter's location, points towards the rabbit, and has length $1$.) / 1b: The hunter shoots and (thankfully) misses when closest to the rabbit; when does that happen? / 2: Remember the product rule for the derivative: $(f (t) g (t))' = f' (t) g (t) + f (t) g' (t)$. Let $bf(a) (t) , bf(b) (t) in bb(R)^3$ be two vector-valued functions of $t$. / 2a: Show how taking the derivative interacts with dot product: $ (bf(a) (t) dot.op bf(b) (t))' = bf(a)' (t) dot.op bf(b) (t) + bf(a) (t) dot.op bf(b)' (t). $ / 2b: Show how taking the derivative interacts with cross product: $ (bf(a) (t) times bf(b) (t))' = bf(a)' (t) times bf(b) (t) + bf(a) (t) times bf(b)' (t). $ / 3: A point $P$ moves in space, with position vector $bf(r) (t) = arrow(O P) = 3 cos (t) bf(i) + 5 sin (t) bf(j) + 4 cos (t) bf(k)$. / 3a: Show it moves on the surface of a sphere centered at the origin. / 3b: Show it also moves on a plane through the origin (so with the first part, actually moves on a great circle given by intersecting the plane with the sphere). / 3c: Show its speed is constant. / 3d: Show the acceleration is directed toward the origin. Also: I'm authorized to go over any midterm problems people want to see (now or in office hours). = If you're thinking about majoring in course 18... After the review session on Thursday evening#footnote[Which by the way was a disaster, so if you didn't come, good call. I'll try to come up with a better plan in the future, since I apparently volunteered to lead the next two. Suggestions welcome. Right now I'm thinking literally to run a mock exam for 50 minutes and then go over solutions afterwards, given the number of people attending.], one student mentioned to me they were thinking about majoring in course 18. Here's the advice I gave. It may come as a surprise to you that 18.02 isn't a real prerequisite (even indirectly) for most serious math classes ($18.x y z$ for $x >= 1$). The two most important areas to take in pure math are *18.100* (real analysis) and *18.701--18.702* (algebra); these are sort of the barrier between the world of pre-university math and serious math. Once you clear these two classes, the floodgates open and the world of modern math is yours to explore. I'm of the impression that *18.02 is not designed for future math majors*; it's a GIR. For example, if you take 18.701, the instructor will literally _throw away_ the "definitions" of linear transformations (and others) you learned in 18.02/18.06/etc. and replace them with the "correct" ones. You've seen me do this already. Similarly, you will have completely new (and rigorous) definitions of derivatives and integrals. In some sense, 18.100 is really _redoing_ all of 18.01 and 18.02 with actual proofs. A prerequisite to both 18.100 and 18.701--18.702 isn't any particular theory, but proof experience. It used to be that they just threw you to the wolves in 18.100 and you learned by trial by fire (which for the record I thought was idiotic).#footnote[This historical reason is AFAIK why 18.100 is officially listed as one of the possible prerequisites for 18.701. It doesn't make any sense subject-wise; rather it means "know what a proof is".] However, I've been told in recent years there's a class called *18.090* that tries to teach this instead. This class is new enough I don't even have any secondhand accounts, but if Poonen is on the list of instructors I trust him. #pagebreak() = Post-recitation notes == From the instructor's Slack Me trying to do question 1a.#footnote[As it happened, I was sitting around in the ill-fated flight UA 499 from Newark to Boston when I sent this, which was delayed until around 11:00pm. I got home way later than I should have. If I seem cranky this morning, that's probably why.] #figure( image("media/brainfart.png", width: 95%), caption: [Seriously, just do everything componentwise.], ) <brainfart>
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/numblex/0.1.0/README.md
markdown
Apache License 2.0
# Numblex ## Usage ```typst #import "@preview/numblex:0.1.0": * #set heading(numbering: numblex("1.", "1.", (numbering: "a.", depth: 2))) ```
https://github.com/7sDream/fonts-and-layout-zhCN
https://raw.githubusercontent.com/7sDream/fonts-and-layout-zhCN/master/chapters/09-layout/shaping.typ
typst
Other
#import "/template/template.typ": web-page-template #import "/template/components.typ": note #import "/lib/glossary.typ": tr #show: web-page-template // ## Shaping challenges (Bengali etc.) == #tr[shaping]中的难题 孟加拉文等。
https://github.com/hchap1/typst-spell-check
https://raw.githubusercontent.com/hchap1/typst-spell-check/main/README.md
markdown
# typst-spell-check A rust project to do a quick and dirty spellcheck over a Typst (typeset) document.
https://github.com/chubetho/Bachelor_Thesis
https://raw.githubusercontent.com/chubetho/Bachelor_Thesis/main/templates/listings.typ
typst
#heading("List of Listings", outlined: true, numbering: none) #outline( title: none, target: figure.where(kind: raw), ) #pagebreak(weak: true)
https://github.com/TypstApp-team/typst
https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/text/linebreak-obj.typ
typst
Apache License 2.0
// Test linebreaks with after inline elements. --- // Test punctuation after citations. #set page(width: 162pt) They can look for the details in @netwok, which is the authoritative source. #bibliography("/files/works.bib") --- // Test punctuation after math equations. #set page(width: 85pt) We prove $1 < 2$. \ We prove $1 < 2$! \ We prove $1 < 2$? \ We prove $1 < 2$, \ We prove $1 < 2$; \ We prove $1 < 2$: \ We prove $1 < 2$- \ We prove $1 < 2$– \ We prove $1 < 2$— \
https://github.com/Enter-tainer/typst-preview
https://raw.githubusercontent.com/Enter-tainer/typst-preview/main/docs/vscode.typ
typst
MIT License
#import "./book.typ": book-page #import "./templates/gh-page.typ": page-width, is-dark-theme #import "@preview/fontawesome:0.1.0": * #import "@preview/colorful-boxes:1.1.0": * #import "@preview/commute:0.1.0": node, arr, commutative-diagram #show: book-page.with(title: "Use in VSCode") #show link: underline #let commands = json("../addons/vscode/package.json").contributes.commands = Use in VSCode This extension provides #commands.len() commands, they are: #for cmd in commands [ - #raw(cmd.command): #cmd.title - #cmd.description ] We also automatically scroll sync the preview with the editor when you are editing the source file. Also, when you click on the preview page, we will automatically scroll the editor to the corresponding position.
https://github.com/isaacholt100/isaacholt
https://raw.githubusercontent.com/isaacholt100/isaacholt/main/public/maths-notes/4-cambridge%3A-part-III/ramsey-theory/ramsey-theory.typ
typst
MIT License
#import "../../template.typ": * #show: doc => template(doc, hidden: (), slides: false) #let clr(c) = [ #set text(fill: eval(c)) #c ] #let Clr(c) = smallcaps(c) = Monochromatic sets == Ramsey's theorem #notation[ $NN$ denotes the set of positive integers, $[n] = {1, ..., n}$, and $X^((r)) = {A subset.eq X: |A| = r}$. Elements of a set are written in ascending order, e.g. ${i, j}$ means $i < j$. Write e.g. $i j k$ to mean the set ${i, j, k}$ with the ordering (unless otherwise stated) $i < j < k$. ] #definition[ A *$k$-colouring* on $A^((r))$ is a function $c: A^((r)) -> [k]$. ] #example[ - Colour ${i, j} in NN^((2))$ red if $i + j$ is even and blue if $i + j$ is odd. Then $M = 2 NN$ is a monochromatic subset. - Colour ${i, j} in NN^((2))$ red if $max{n in NN: 2^n | (i + j)}$ is even and blue otherwise. $M = {4^n: n in NN}$ is a monochromatic subset. - Colour ${i, j} in NN^((2))$ red if $i + j$ has an even number of distinct prime divisors and blue otherwise. No explicit monochromatic subset is known. ] #theorem(name: "Ramsey's Theorem for Pairs")[ Let $NN^((2))$ are $2$-coloured by $c: NN^((2)) -> {1, 2}$. Then there exists an infinite monochromatic subset $M$. ]<thm:ramseys-theorem-for-pairs> #proof[ - Let $a_1 in A_0 := NN$. There exists an infinite set $A_1 subset.eq A_0$ such that $c(a_1, i) = c_1$ for all $i in A_1$. - Let $a_2 in A_1$. There exists infinite $A_2 subset.eq A_1$ such that $c(a_2, i) = c_2)$ for all $i in A_2$. - Repeating this inductively gives a sequence $a_1 < a_2 < dots.c < a_k < dots.c$ and $A_1 supset.eq A_2 supset.eq dots.c$ such that $c(a_i, j) = c_i$ for all $j in A_i$. - One colour appears infinitely many times: $c_(i_1) = c_(i_2) = dots.c = c_(i_k) = dots.c = c$. - $M = \{a_(i_1), a_(i_2), ...\}$ is a monochromatic set. ] #remark[ - The same proof works for any $k in NN$ colours. - The proof is called a "2-pass proof". - An alternative proof for $k$ colours is split the $k$ colours $1, ..., k$ into $2$ colours: $1$ and "$2 "or" ... "or" k$", and use induction. ] #note[ An infinite monochromatic set is *very* different from an arbitrarily large finite monochromatic set. ] #example[ Let $A_1 = {1, 2}$, $A_2 = {3, 4, 5}$, etc. Let ${i, j}$ be red if $i, j in A_k$ for some $k$. There exist arbitrarily large monochromatic red sets but no infinite monochromatic red sets. ] #example[ Colour ${i < j < k}$ red iff $i | (j + k)$. A monochromatic subset $M = {2^n: n in NN_0}$ is a monochromatic set. ] #theorem(name: [Ramsey's Theorem for $r$-sets])[ Let $NN^((r))$ be finitely coloured. Then there exists a monochromatic infinite set. ] #proof[ - $r = 1$: use pigeonhole principle. - $r = 2$: Ramsey's theorem for pairs. - For general $r$, use induction. - Let $c: NN^(r) -> [k]$ be a $k$-colouring. Let $a_1 in NN$, and consider all $r - 1$ sets of $NN \\ {a_1}$, induce colouring $c': (NN \\ {a_1})^((r - 1)) -> [k]$ via $c'(F) = c(F union {a_1})$. - By inductive hypothesis, there exists $A_1 subset.eq NN \\ {a_1}$ such that $c'$ is constant on it (taking value $c_1$). - Now pick $a_2 in A_1$ and induce a colouring $c': (A_1 \\ {a_2})^((r - 1)) -> [k]$ such that $c'(F) = c(F union {a_2})$. By inductive hypothesis, there exists $A_2 subset.eq A_1 \\ {a_2}}$ such that $c'$ is constant on it (taking value $c_2$). - Repeating this gives $a_1, a_2, ...$ and $A_1, A_2, ...$ such that $A_(i + 1) subset.eq A_i \\ {a_(i + 1)}$ and $c(F union {a_i}) = c_i$ for all $F subset.eq A_(i + 1)$, for $|F| = r - 1$. - One colour must appear infinitely many times: $c_(i_1) = c_(i_2) = dots.c = c$. - $M = {a_(i_1), a_(i_2), ...}$ is a monochromatic set. ] == Applications of Ramsey's theorem #example[ In a totally ordered set, any sequence has monotonic subsequence. ] #proof[ - Let $(x_n)$ be a sequence, colour ${i, j}$ red if $x_i <= x_j$ and blue otherwise. - By Ramsey's theorem for pairs, $M = {i_1 < i_2 < dots.c}$ is monochromatic. If $M$ is red, then the subsequence $x_(i_1), x_(i_2), ...$ is increasing, and is strictly decreasing otherwise. - We can insist that $\(x_(i_j)\)$ is either concave or convex: $2$-colour $NN^((3))$ by colouring ${j < k < ell}$ #clr("red") if $(i, x_(i_j)), (j, x_(i_k)), (k, x_(i_ell))$ form a convex triple, and #clr("blue") if they form a concave triple. Then by Ramsey's theorem for $r$-sets, there is an infinite convex or concave subsequence. ] #theorem(name: "Finite Ramsey")[ Let $r, m, k in NN$. There exists $n in NN$ such that whenever $[n]^((r))$ is $k$-coloured, we can find a monochromatic set of size (at least) $m$. ]<thm:finite-ramsey> #proof[ - Assume not, i.e. $forall n in NN$, there exists colouring $c_n: [n]^((r)) -> [k]$ with no monochromatic $m$-sets. - There are only finitely many ($k$) ways to $k$-colour $[r]^((r))$, so there are infinitely many of colourings $c_r, c_(r + 1), ...$ that agree on $[r]^((r))$: $c_i |_([r]^((r))) = d_r$ for all $i$ in some infinite set $A_1$, where $d_r$ is a $k$-colouring of $[r]^((r))$. - Similarly, $[r + 1]^((r))$ has only finitely many possible $k$-colourings. So there exists infinite $A_2 subset.eq A_1$ such that for all $i in A_2$, $c_i |_([r + 1]^((r))) = d_(r + 1)$, where $d_(r + 1)$ is a $k$-colouring of $[r + 1]^((r))$. - Continuing this process inductively, we obtain $A_1 supset.eq A_2 supset.eq dots.c supset.eq A_n$. There is no monochromatic $m$-set for any $d_n: [n]^((r)) -> [k]$ (because $d_n = c_i|_([n]^((r)))$ for some $i$). - These $d_n$'s are nested: $d_ell|_([n]^((r))) = d_n$ for $ell > n$. - Finally, we colour $NN^((r))$ by the colouring $c: NN^((r)) -> [k]$, $c(F) = d_n (F)$ where $n = max(F)$ (or in fact $n >= max(F)$, which is well-defined by above). So $c$ has no monochromatic $m$-set (since $M$ was a monochromatic $m$-set, then taking $ell = max(M)$, $d_ell$ has a monochromatic $m$-set), which contradicts Ramsey's Theorem for $r$-sets. ] #remark[ - This proof gives no bound on $n = n(k, m)$, there are other proofs that give a bound. - It is a proof by compactness (essentially, we proved that ${0, 1}^NN$ with the product topology, i.e. the topology derived from the metric $d(f, g) = 1/min{n in NN: f(n) != g(n)}$, is sequentially compact). ] #remark[ Now consider a colouring $c: NN^((2)) -> X$ with $X$ potentially infinite. This does not necessarily admit an infinite monochromatic set, as we could colour each edge a different colour. Such a colouring would be injective. We can't guarantee either the colouring being constant or injective though, as $c(i j) = i$ satisfies neither. ] #theorem(name: "<NAME>sey")[ Let $c: NN^((2)) -> X$ be a colouring with $X$ an arbitrary set. Then there exists an infinite set $M subset.eq NN$ such that: + $c$ is constant on $M^((2))$, or + $c$ is injective on $M^((2))$, or + $c(i j) = c(k l)$ iff $i = k$ for all $i < j$ and $k < l$, $i, j, k, l in M$, or + $c(i j) = c(k l)$ iff $j = l$ for all $i < j$ and $k < l$, $i, j, k, l in M$. ] #proofhints[ - First consider the $2$-colouring $c_1$ of $NN^((4))$ where $i j k l$ is coloured #Clr("same") if $c(i j) = c(k l)$ and #Clr("diff") otherwise. Show that an infinite monochromatic set $M_1 subset.eq NN$ (why does this exist?) coloured #Clr("same") leads to case 1. - Assume $M_1$ is coloured #Clr("diff"), consider the $2$-colouring of $M_1^((4))$, which colours $i j k l$ #Clr("same") if $c(i l) = c(j k)$ and #Clr("diff") otherwise. Show an infinite monochromatic $M_2 subset.eq M_1$ (why does this exist?) must be coloured #Clr("diff") by contradiction. - Consider the $2$-colouring of $M_2^((4))$ where $i j k l$ is coloured #Clr("same") if $c(i k) = c(j l)$ and #Clr("diff") otherwise. Show an infinite monochromatic set $M_3 subset.eq M_2$ (why does this exist?) must be coloured #Clr("diff") by contradiction. - $2$-colour $M_3^((3))$ by: $i j k$ is coloured #Clr("same") if $c(i j) = c(j k)$ and #Clr("diff") otherwise. Show an infinite monochromatic set $M_4 subset.eq M_3$ (why does this exist) must be coloured #Clr("diff") by contradiction. - $2$-colour $M_4^((3))$ by the other two similar colourings to above, obtaining monochromatic $M_6 subset.eq M_5 subset.eq M_4$. - Consider 4 combinations of these colourings on $M_6$, show 3 lead to one of the cases in the theorem, and the other leads to contradiction. ] #proof[ - $2$-colour $NN^((4))$ by: $i j k l$ is red if $c(i j) = c(k l)$ and blue otherwise. By Ramsey's Theorem for $4$-sets, there is an infinite monochromatic set $M_1 subset.eq NN$ for this colouring. - If $M_1$ is red, then $c$ is constant on $M_1^((2))$: for all pairs $i j, i' j' in M_1^((2))$, pick $m < n$ with $j, j' < m$, then $c(i j) = c(m n) = c(i' j')$. - So assume $M_1$ is blue. - Colour $M_1^((4))$ by giving $i j k l$ colour green if $c(i l) = c(j k)$ and purple otherwise. By Ramsey's theorem for $4$-sets, there exists an infinite monochromatic $M_2 subset.eq M_1$ for this colouring. - Assume $M_2$ is coloured green: if $i < j < k < l < m < n in M_2$, then $c(j k) = c(i n) = c(l m)$ (consider $i j k n$ and $i l m n$): contradiction, since $M_1$ is blue. - Hence $M_2$ is purple, i.e. for $i j k l in M_2^((4))$, $c(i l) != c(j k)$. - Colour $M_2$ by: $i j k l$ is orange if $c(i k) = c(j l)$, and pink otherwise. - By Ramsey's theorem for $4$-sets, there exists infinite monochromatic $M_3 subset.eq M_2$ for this colouring. - Assume $M_3$ is orange, then for $i < j < k < l < m < n in M_3$, we have $c(j m) = c(l n)$ (consider $j l m n$) and $c(j m) = c(i k)$ (consider $i j k m$): contradiction, since $M_3 subset.eq M_1$. - Hence $M_3$ is pink, i.e. for $i j k l$, $c(i k) != c(j l)$. - Colour $M_3^((3))$ by: $i j k$ is yellow if $c(i j) = c(j k)$ and grey otherwise. By Ramsey's theorem for $3$-sets, there exists infinite monochromatic $M_4 subset.eq M_3$ for this colouring. - Assume $M_4$ is yellow: then (considering $i j k l in M_4^((4))$) $c(i j) = c(j k) = c(k l)$: contradiction, since $M_4 subset.eq M_1$. - So for any $i j k in M_4^((3))$, $c(i j) != c(j k)$. - Finally, colour $M_4^((3))$ by: $i j k$ is gold if $c(i j) = c(i k)$ and $c(i k) = c(j k)$, silver if $c(i j) = c(i k)$ and $c(i k) != c(j k)$, bronze if $c(i j) != c(i k)$ and $c(i k) = c(j k)$, and platinum if $c(i j) != c(i k)$ and $c(i k) != c(j k)$. - By Ramsey's theorem for $3$-sets, there exists monochromatic $M_5 subset.eq M_4$. $M_5$ cannot be gold, since then $c(i j) = c(j k)$: contradiction, since $M_5 subset.eq M_4$. If silver, then we have case 3 in the theorem. If bronze, then we have case 4 in the theorem. If platinum, then we have case 2 in the theorem. ] #remark[ - A more general result of the above theorem states: let $NN^((r))$ be arbitrarily coloured. Then we can find an infinite $M$ and $I subset.eq [r]$ such that for all $x_1 ... x_r in M^((r))$ and $y_1 ... y_r in M^((r))$, $c(x_1 ... x_r) = c(y_1 ... y_r)$ iff $x_i = y_i$ for all $i in I$. - In canonical Ramsey, $I = emptyset$ is case 1, $I = {1, 2}$ is case $2$, $I = {1}$ is case 3 and $I = {2}$ is case 4. - These $2^r$ colourings are called the *canonical colourings* of $NN^((r))$. ] #exercise[ Prove the general statement. ] == Van der Waerden's theorem #remark[ We want to show that for any $2$-colouring of $NN$, we can find a monochromatic arithmetic progression of length $m$ for any $m in NN$. By compactness, this is equivalent to showing that for all $m in NN$, there exists $n in NN$ such that for any $2$-colouring of $[n]$, there exists a monochromatic arithmetic progression of length $m$. (If not, there for each $n$, there is a colouring $c_n: [n] -> {1, 2}$ with no monochromatic arithmetic progression of length $m$. Infinitely many agree on $[1]$, infinitely many agree on $[2]$, and so on - we obtain a $2$-colouring of $NN$ with no monochromatic arithmetic progression of length $m$). We will prove a slightly stronger result: whenever $NN$ is $k$-coloured, there exists a monochromatic arithmetic progression, i.e. for any $k, m in NN$, there exists $n in NN$ such that whenever $[n]$ is $k$-coloured, we have a length $m$ monochromatic progression. ] #definition[ Let $A_1, ..., A_k$ be length $m$ arithmetic progressions: $A_i = {a_i, a_i + d_i, ..., a_i + (m - 1)d_i}$. $A_1, ..., A_k$ are *focussed* at $f$ if $a_i + m d_i = f$ for all $i$. ]<def:arithmetic-progression.focussed> #example[ ${4, 8}$ and ${6, 9}$ are focussed at $12$. ] #definition[ If length $m$ arithmetic progressions $A_1, ..., A_k$ are focused at $f$ and are monochromatic with each a different colour (for a given colouring), they are called *colour-focussed* at $f$. ]<def:arithmetic-progression.colour-focussed> #theorem[ Whenever $NN$ is $k$-coloured, there exists a monochromatic arithmetic progression of length $3$, i.e. for all $k in NN$, there exists $n in NN$ such that any $k$-colouring of $[n]$ admits a length $3$ monochromatic progression. ] #proof[ - We claim that for all $r <= k$, there exists an $n$ such that if $[n]$ is $k$-coloured, then either: - There exists a monochromatic arithmetic progression of length $3$. - There exist $r$ colour-focussed arithmetic progressions of length $2$. - We prove the claim by induction on $r$: - $r = 1$: take $n = k + 1$, then by pigeonhole, some two elements of $[n]$ have the same colour, so form a length two arithmetic progression. - Assume true for $r - 1$ with witness $n$. We claim that $N = 2n (k^(2n) + 1)$ works for $r$. - Let $c: [2n (k^(2n) + 1)] -> [k]$ be a colouring. We partition $[N]$ into $k^(2n) + 1$ sets: $B_1 = {1, ..., 2n}$, $B_2 = {2n + 1, ..., 4n}$, .... - Assume there is no length $3$ monochromatic progression for $c$. By inductive hypothesis, each $B_i$ has $r - 1$ colour-focussed arithmetic progressions of length $2$. - Since $|B_i| = 2n$, each block also contains their focus. For a set $M$ with $|M| = 2n$, there are $k^(2n)$ ways to $k$-colour $M$. So by pigeonhole, there are blocks $B_s$ and $B_(s + t)$ that have the same colouring. - Let ${a_i, a_i + d_i}$ be the $r - 1$ colour-focussed arithmetic progressions in $B_s$, then ${a_i + 2n t, a_i + d_i + 2n t}$ is the corresponding set in $B_(s + t)$. Let $f$ be the focus in $B_s$, then $f + 2n t$ is the focus in $B_(s + t)$. - Now ${a_i, a_i + d_i + 2n t}$, $i in [r - 1]$, are $r - 1$ arithmetic progresions colour-focused at $f + 4 n t$. Also, ${f, f + 2n t}$ is monochromatic of a different colour to the $r - 1$ colours used. Hence, there are $r$ arithmetic progressions of length $2$ colour-focussed at $f + 4 n t$. - TODO finish proof. ] #remark[ The idea of looking at all possible colourings of a set is called a *product argument*. ] #definition[ The *Van der Waerden* number $W(k, m)$ is the smallest $n$ such that for any $k$-colouring of $[n]$, there exists a monochromatic arithmetic progression of length $m$. ] #remark[ The above theorem gives a tower-type upper bound $W(k, 3) <= k^(k^(dots.up)^(k^(4k)))$. ] = Partition regular systems = Euclidean Ramsey theory
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/scholarly-tauthesis/0.4.0/README.md
markdown
Apache License 2.0
# Tampere University Thesis Template This is a TAU thesis template written in the [`typst`][typst] typesetting language, a potential successor to LaTeΧ. The version of typst used to test this template is [`0.11.0`][v0.11.0]. ## Local installation To install this template locally, download this repository via Git or as a ZIP file from the [tags] page. Then, make a symbolic link $DATADIR/typst/packages/preview/scholarly-tauthesis/$VERSION/ -> /path/to/root/of/tauthesis/ so that a local installation of `typst` can discover the `tauthesis.typ` file no matter where you are running it from. To find out the value `$DATADIR` for your operating system, see <https://docs.rs/dirs/latest/dirs/fn.data_dir.html>. The value `$VERSION` is the version `A.B.C` ≥ `0.4.0` of this template you wish to use. If [Typst Universe] is online and this package has been approved there by the service maintainers, this template will be downloaded automatically to $CACHEDIR/typst/packages/preview/scholarly-tauthesis/$VERSION/ The value `$CACHEDIR` for your OS can be discovered from <https://docs.rs/dirs/latest/dirs/fn.cache_dir.html>. [tags]: https://gitlab.com/tuni-official/thesis-templates/tau-typst-thesis-template/-/tags [Typst Universe]: https://typst.app/universe Once the package has been installed, the command typst init @preview/scholarly-tauthesis:$VERSION creates a folder `tauthesis` with the template files in place. Simply make the `tauthesis` folder you current working directory and run repository and run ```sh typst compile main.typ ``` in the shell of your choice to compile the document from scratch. Alternatively, type ```sh typst watch main.typ &> typst.log & ``` to have a [`typst`][typst] process watch the file for changes and compile it when a file is changed. Possible error messages can then be viewed by checking the contents of the mentioned file `typst.log`. This template can also be uploaded to the typst online editor at <https://typst.app/>. However, the file paths related to the `tauthesis` file will need to be changed if this is done manually. See the tutorial at <https://typst.app/docs/tutorial/> to learn the basics of the language. Some examples are also given in the template itself. [typst]: https://github.com/typst/typst [v0.11.0]: https://github.com/typst/typst/releases/tag/v0.11.0 ## Using the template on typst.app This is very easy, once the typst maintainers have approved the `scholarly-tauthesis` package into the [Typst Universe] service. Simply create an account on <https://typst.app/> and start a new `tauthesis` project by clicking on **Start from template → scholarly-tauthesis**. ## Archiving the final version of your work Before submitting your thesis to the university archives, it needs to be converted to PDF/A format. See the related instructions ([link][pdfa-instructions]) for how to do it. Basically it boils down to feeding your compiled PDF document to the converter <https://muuntaja.tuni.fi>. **Remember to check that the output of the converter is not corrupted, before submitting your thesis to the archives.** [pdfa-instructions]: https://libguides.tuni.fi/opinnaytteet/pdfa ## Usage You can either write your entire *main matter* in the [`main.typ`](./main.typ) file, or more preferrably, split it into multiple chapter-specific files and place those in the [`contents/`](./content) folder, which this template tries to demonstrate. If you choose to write your own commands (functions) in the [`preamble.typ`](./preamble.typ) file, this needs to be imported at the start of each chapter you plan to use the commands in. Sections that come before the main matter, like the Finnish and English abstracts ([`tiivistelmä.typ`](./content/tiivistelmä.typ)|[`abstract.typ`](./content/abstract.typ)) and [`preface.typ`](./content/preface.typ) must *not* be removed from the [`contents`](./content) folder, as the automation supposes that they are located there. You should probably *not* modify the file [`tauthesis.typ`](./tauthesis.typ), unless there is a bug that needs fixing right now, and not when the maintainer of this project manages to find the time to do it. ## Contributing Issues may be created in the issue tracker of this GitLab repository, if one has a GitLab account. Merge requests may also be performed after GitLab account creation, and forking the project. See GitLab's documentation on this to find out how to do it [link][forking]. [forking]: https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html ## License This project itself uses the MIT license. See the [LICENSE](./LICENSE) file for details.
https://github.com/Blezz-tech/math-typst
https://raw.githubusercontent.com/Blezz-tech/math-typst/main/Картинки/Демо вариант 2024/Задание 01.2.typ
typst
#import "@preview/cetz:0.1.2" #import "/lib/my_cetz.typ": circumcenter, defaultStyle #set align(center) #cetz.canvas(length: 1cm, { import cetz.draw: * import cetz.vector: div, add set-style(..defaultStyle) set-style( angle: ( radius: 0.8 , label-radius: 1.2 , fill: green.lighten(80%) , stroke: ( paint: green.darken(50%)) ) ) let (A, B, C) = ((0,0), (6,0), (3,calc.sqrt(36-9)) ) line(A, B, name: "AB") line(A, C, name: "AC") line(B, C, name: "BC") let (E, F, D) = ( div(add(A, C), 2) , div(add(A, B), 2) , div(add(B, C), 2) ) for (point) in (A, B, C, E, F, D) { circle(point, radius: 0.04, fill: black ) } line(C, E, D, close: true, fill: blue.lighten(80%)) content(A, $ A $, anchor: "top-right") content(B, $ B $, anchor: "top-left") content(C, $ C $, anchor: "bottom") line(E, D, F, close: true) content(E, $ E $, anchor: "right") content(D, $ D $, anchor: "left") content(F, $ F $, anchor: "top") content(circumcenter(A, E, F), $ x $, anchor: "center") content(circumcenter(E, F, D), $ x $, anchor: "center") content(circumcenter(E, D, C), $ x $, anchor: "center") content(circumcenter(F, D, B), $ x $, anchor: "center") })
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/formalettre/0.1.0/template/src/exemple.typ
typst
Apache License 2.0
#import "@preview/formalettre:0.1.0": * #set text(lang: "fr") #show: lettre.with( expediteur: ( nom: "de La Boétie", prenom: "Étienne", voie: "145 avenue de Germignan", complement_adresse: "", code_postal: "33320", commune: "Le Taillan-Médoc", telephone: "01 23 45 67 89", email: "<EMAIL>", signature: "", ), destinataire: ( titre: "<NAME>", voie: "17 butte Farémont", complement_adresse: "", code_postal: "55000", commune: "Bar-le-Duc", sc: "", ), lieu: "<NAME>", objet: [Ceci est un objet de courrier.], date: [le 7 juin 1559], pj: "", ) #lorem(200)
https://github.com/Shivansh-Jain/Shivansh-Jain
https://raw.githubusercontent.com/Shivansh-Jain/Shivansh-Jain/main/resume.typ
typst
#show heading: set text(font: "Linux Biolinum") #show link: underline #set page( // fill: rgb("#282828"), margin: (x: 0.9cm, y: 1.3cm), ) #set par(justify: true) // #set text(fill: white) #let chiline() = {v(-3pt); line(length: 100%); v(-5pt)} = <NAME> +918959648831 | #link("mailto:<EMAIL>")[<EMAIL>] | #link("https://github.com/Shivansh-Jain")[github.com/Shivansh-Jain] | #link("https://www.linkedin.com/in/shivansh-jain-9742901a2/")[linkedin/shivansh-jain-9742901a2] == Education #chiline() *Indian Institute of Technology Madras* #h(1fr) 2024 \ Bachelor of Science, _Data Science and Applications_, CGPA: 8.2 \ *Vikram University, Ujjain* #h(1fr) 2022 \ Bachelor of Business Administration, %age: 79% \ == Work Experience #chiline() *Fiery (previously EFI)* #h(1fr) 11/2023 -- Present \ Data Scientist Intern #h(1fr) Bengaluru, India - Fine-tuned Mistral-7B with LoRA for enhanced language processing on internal data. - Worked on a solution using vector databases for similarity matching of images and text to enhance search experience. - Build a Retrieval-Augmented Generation (RAG) based chat product using Mistral-7B LLM, trained on company data for Question and Answering. *Indian Institute of Technology Madras* #h(1fr) 07/2023 -- 10/2023 \ Web Dev Intern, Placement Cell IITM BS #h(1fr) Chennai, India \ - Crafted a IITM BS placement portal, leveraging PHP and JS for a seamless user experience, with MySQL as the robust database backend, catering to admin, student, and recruiter roles. *Indian Institute of Technology Madras* #h(1fr) 08/2022 -- 09/2022 \ Academic Mentor, Programming in Python #h(1fr) Chennai, India \ - Mentored students in Python, progressing them from beginner to advanced levels, to support their coursework. == Skills #chiline() *Programming languages* - Python, JavaScript, Java, SQL, Bash, PHP *Frameworks* - Flask, Vue, Bootstrap, Jinja, FastAPI *Libraries* - NumPy, Pandas, Scikit-learn ,huggingface , pytorch, sentence transformer *databases* - SQLite, MySQL == Projects #chiline() #link("https://github.com/Shivansh-Jain/Sentiment-Analysis")[*Sentiment Prediction on Movie reviews*] \ - Built an ML model to predict sentiment of the review text. *Algoswarm Hackathon website* \ - A web application made using HTML,CSS and javascript used as a main website for a hackathon. #link("https://github.com/Shivansh-Jain/blog-lite-2.0")[*Blog Lite 2.0* ]\ - A web application made with Vue JS hosted on Flask Framework, where one can create a blog and see others blogs and intricate via likes and comments. #link("https://github.com/Shivansh-Jain/blog-lite-application")[*Blog Lite*] \ - A web application made with Flask framework, where users can share their posts/blogs. - Flask-Restful library was used for making APIs and requests library was used to make API calls. - Flask-SQLAlchemy library was used to make DB connect with Sqlite database. == Certificates #chiline() - #link("https://www.credly.com/badges/416c28a0-c62f-40f0-914d-01a802c68629/linked_in?t=rwd0ld")[Microsoft certified: Azure AI fundaments]
https://github.com/TJ-CSCCG/tongji-undergrad-thesis-typst
https://raw.githubusercontent.com/TJ-CSCCG/tongji-undergrad-thesis-typst/main/init-files/sections/02_math.typ
typst
MIT License
#import "../../paddling-tongji-thesis/tongjithesis.typ": * = 数学 <math> 在本节(@math)中,我们展示各种数学符号和环境的使用。 Typst 具有特殊的语法和库函数来排版数学公式,与#LaTeX 相似,但差别也很大。 数学公式可以与文本并列显示,也可以作为单独的块显示。如果数学公式的开头和结尾至少有一个空格(如 #raw("$ x^2 $", lang: "typ")),则会被排版到单独的块中。 毕业论文规范规定,公式应另起一行居中排版。公式后应注明编号,按章顺序编排,编号右端对齐。若你想了解更多数学排版的内容,可以参考#link("https://typst.app/docs/reference/math/")[#emph[Typst的数学模式文档]]。 == 变量 在Typst的数学模式中,单个字母总是按原样显示。而多个字母则被解释为变量和函数。要逐字显示多个字母,可以将它们放在引号中;要访问单字母变量,可以使用#link( "https://typst.app/docs/reference/scripting/#expressions", )[#emph[`#`语法]]。 #table(columns: (1fr, 1fr), [ #set align(center) #strong[代码] ], [ #set align(center) #strong[渲染结果] ], ```typ $ A = pi r^2 $ $ "area" = pi dot "radius"^2 $ $ cal(A) := { x in RR | x "is natural" } $ #let x = 5 $ #x < 17 $ ```, [ $ A = pi r^2 $ <pir2> $ "area" = pi dot "radius"^2 $ $ cal(A) := { x in RR | x "is natural" } $ #let x = 5 $ #x < 17 $ ]) == 数学符号 Typst数学模式提供了像圆周率($pi$)、点号($dot$)或实数集($RR$)等众多#link("https://typst.app/docs/reference/symbols/sym/")[#emph[符号]]。许多数学符号有不同的变体。你可以通过对符号应用#link("https://typst.app/docs/reference/symbols/symbol/")[#emph[修饰符]]来选择不同的变体。Typst 还识别许多像 $=>$ 这样的 “速记序列”,这些序列可以近似表示一个符号。 #table(columns: (1fr, 1fr), [ #set align(center) #strong[代码] ], [ #set align(center) #strong[渲染结果] ], ```typ $ x < y => x gt.eq.not y $ ```, [ $ x < y => x gt.eq.not y $ ]) 按照国标 GB/T 3102.11—1993《物理科学和技术中使用的数学符号》,微分符号 $dif$ 应使用直立体。除此之外,数学常数也应使用直立体,如圆周率 $pi$、自然对数的底 $ee$、虚数单位 $ii$、$jj$ 等。 == 换行 公式也可以包含换行。每行可以包含一个或多个对齐点(`&`),然后进行对齐。 #table(columns: (1fr, 1fr), [ #set align(center) #strong[代码] ], [ #set align(center) #strong[渲染结果] ], ```typ $ sum_(k=0)^n k &= 1 + ... + n \ &= (n(n+1)) / 2 $ ```, [ $ sum_(k=0)^n k &= 1 + ... + n \ &= (n(n+1)) / 2 $ ]) == 函数调用 数学模式支持特殊的函数调用,无需使用 `#` 号前缀。在这些 “数学调用” 中,参数列表的工作方式与代码中略有不同: - 在其中,Typst 仍然处于 “数学模式”。因此,你可以直接在其中编写数学公式,但需要使用 `#` 语法来传递代码表达式(字符串除外,字符串在数学语法中可用)。 - Typst支持位置参数和命名参数,但不支持尾随内容块和参数扩展。 - Typst还提供了二维参数列表的额外语法。分号(`;`)用于分隔行,逗号(`,`)用于分隔列。 #table(columns: (1fr, 1fr), [ #set align(center) #strong[代码] ], [ #set align(center) #strong[渲染结果] ], ```typ $ frac(a^2, 2) $ $ vec(1, 2, delim: "[") $ $ mat(1, 2; 3, 4) $ $ lim_x = op("lim", limits: #true)_x $ ```, [ $ frac(a^2, 2) $ $ vec(1, 2, delim: "[") $ $ mat(1, 2;3, 4) $ $ lim_x = op("lim", limits: #true)_x $ ]) 要在数学调用中逐字书写逗号或分号,可以用反斜线将其转义。另一方面,冒号只有在前面直接出现标识符时才会被特殊识别,因此在这种情况下要逐字显示冒号,只需在冒号前插入空格即可。 == 对齐 当方程式包含多个对齐点(`&`)时,这将创建交替右对齐和左对齐的列块。在下面的示例中,表达式 `(3x + y) / 7` 是右对齐的,而 `= 9` 是左对齐的。单词 `given` 也是左对齐的,因为 `&&` 在一行中创建了两个对齐点,使对齐方式交替两次。`& &` 和 `&&` 的行为方式完全相同。与此同时,`multiply by 7` 是左对齐的,因为只有一个 `&` 在它之前。每个对齐点简单地交替右对齐/左对齐。 #table(columns: (1fr, 1fr), [ #set align(center) #strong[代码] ], [ #set align(center) #strong[渲染结果] ], ```typ $ (3x + y) / 7 &= 9 && "given" \ 3x + y &= 63 & "multiply by 7" \ 3x &= 63 - y && "subtract y" $ ```, [ $ (3x + y) / 7 &= 9 && "given" \ 3x + y &= 63 & "multiply by 7" \ 3x &= 63 - y && "subtract y" $ ])
https://github.com/fcastillob/4typst
https://raw.githubusercontent.com/fcastillob/4typst/main/README.md
markdown
# 4typst Este es un programita para convertir archivos `.tex` a formato `.typ`. Es posible que ocurran errores de formato, el objetivo del programa es tener un atajo para no escribir de cero un archivo `.tex` en formato `.typ`. ![](compilar.png) ![](transformar.png) El programa hace una conversión usando [pandoc](https://pandoc.org). Se usa el filtro `filtro.lua` para que los ambientes de teoremas queden en formato `#thm[...]`. ## Código externo El archivo `theorems.typ` es código de [sahasatvik](https://github.com/sahasatvik/typst-theorems). # Dependencias - `python` - Tener `pyqt5` instalado - Basta con escribir el comando `pip install pyqt5` en una consola - Tener la [última versión de pandoc](https://pandoc.org/installing.html) instalada. - En Windows basta con usar el instalador que aparece en la página - En Linux basta con descargar [la última versión de la página de github](https://github.com/jgm/pandoc/releases) y dejar el binario `pandoc` en la carpeta `$HOME/.local/bin` - Opcional. Tener `typst` instalado para usar la pestaña `Compilar typst`. Se espera que el archivo generado se suba a [typst.app](https://typst.app) o bien se use un editor de texto local. - En Linux se puede descargar desde la [página de github](https://github.com/typst/typst/releases) y mover el binario `typst` a la carpeta `$HOME/.local/bin`. - En Windows no sé. De todas formas, se puede instalar [typst para VSCode(ium)](https://marketplace.visualstudio.com/items?itemName=nvarner.typst-lsp) y tener un editor local integrado. # Uso 0. Descargar el repositorio - Si se tiene `git` instalado, escribir en alguna terminal `git clone https://github.com/fcastillob/4typst` - Si no, basta con ir a ese botoncito verde arriba que dice *Code* y descargar un `.zip`. 1. Ejecutar el archivo `main.py`. 2. Elegir la pestaña que se quiera usar - Compilar typst requiere tener typst instalado 3. Elegir el archivo - **Van a ocurrir errores si alguna carpeta en la dirección tiene espacios** 4. Compilar o transformar el archivo 5. *Comprobar posibles errores* 6. [Personalizar los teoremas generados en `theorems.typ`](https://github.com/sahasatvik/typst-theorems) Los teoremas se van a exportar correctamente si en LaTeX se definen como `\newtheorem{*}{*}[*]`.
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/math/spacing_02.typ
typst
Apache License 2.0
#import "/contrib/templates/std-tests/preset.typ": * #show: test-page // Test predefined spacings. $a thin b, a med b, a thick b, a quad b$ \ $a = thin b$ \ $a - b equiv c quad (mod 2)$
https://github.com/EGmux/PCOM-2023.2
https://raw.githubusercontent.com/EGmux/PCOM-2023.2/main/lista2/lista2q4.typ
typst
=== Aplica-se ao sinal *$x(t) = 10cos(1000 t + pi/3) + 20(cos(2000 pi t + pi/6)$* uma amostragem uniforme para transmissão digital. ==== a) _Qual é o máximo intervalo de tempo permitido entre os valores de amostras que garantirão a reprodução perfeita do sinal?_ \ 💡 o que muda nessa questão é a adição de fase ao sinal, mas isso não altera a frequência máxima do mesmo. O máximo intervalo de tempo é o intervalo de Nyquist, e a frequência de Nyquist é dada por: #math.equation(block: true, $ f_N = 636.619 "Hz" $) _visto que a maior frequência é de $2000 "rad/s"$_ logo o intervalo máximo permitido é de $ 1.57 dot 10^(-3) "s"$ ==== b) Se quisermos reproduzir 1h deste sinal, quantas amostras precisam ser armazenadas? \ Ora o sinal tem o intervalo de Nyquist de $1.57 dot 10^(-3) "s" $ então para obtermos "1h deste sinal" é dividir 3600 por este número, 3600 é o equivalente de 1h em segundos. #math.equation(block: true, $ "nAmostras" tilde.eq.rev 2292993 $)
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/031%20-%20Hour%20of%20Devastation/001_The%20Hour%20of%20Revelation.typ
typst
#import "@local/mtgstory:0.2.0": conf #show: doc => conf( "The Hour of Revelation", set_name: "Hour of Devastation", story_date: datetime(day: 07, month: 06, year: 2017), author: "<NAME>", doc ) #emph[Sands idly wafted over dunes, the Luxa River flowed from one end of Naktamun to the other, families lived and worked in happy peace, and through a ripple of air, a dragon tore through the sky from a faraway world.] #emph[He had days. Only days until he wouldn't have the magic left to execute this plan. There was just enough time left to put into place the possible means to regain his godhood.] #emph[The dragon's plans spanned millennia and his perception straddled centuries, a winding maze of possibility and circumstance and statistics and likelihood. Usually the dragon played the odds when shaping his decisions—but now, to manifest his needs, the dragon would need to be violent in his choices.] #emph[Violence is an act that cannot be taken back or amended halfway through. It is begun, then ended. The dragon's choices must be the same. No doubt. No hesitation or uncertainty. Merely violence.] #emph[The gods of Amonkhet saw the dragon hovering outside the protection of the Hekma. They climbed to the tops of their highest vantage points and armed themselves for battle. They were determined not to fail this time. No monster could defeat the eight gods of Amonkhet. Not when Naktamun was all that remained.] #emph[Oketra raised her bow high, and the light of twin suns glinted off its curve. She loosed an arrow into the sky, and it passed through the Hekma with ease. The arrow hit the dragon's side, and he ] #emph[laughed. The great dragon flew down toward the shimmering dome of the Hekma and tested it with a tentative claw. Oketra loosed another arrow, this time aimed directly at the dragon's eye. The beast glanced at the incoming projectile; it splintered and dissolved mid-flight.] #emph[The gods were stunned. This dragon possessed enough power to defy the laws of nature.] #emph[Hazoret called for the children and elderly to retreat to the mausoleums for safety, and t] #emph[he attendants spread the word. She took up her spear and urged the gods to attack.] #emph[The gods' distraction to protect the mortals amused the dragon. These gods cared far more about their plane than he ever did about the worlds he created.] #emph[Kefnet, caretaker of the Hekma, was straining to keep the magical barrier together. The dragon tipped his chin and fractured Kefnet's mind in two.] #emph[Kefnet's body and wings went limp and he plummeted to the ground, crumpled and still.] #emph[The hearts of the mortals in Naktamun recoiled in immediate pain. Even those who did not witness Kefnet's fall felt panic. The gods in turn cried out for their brother, and for the loss that swept through the people of Amonkhet.] #emph[The dragon smiled. He extended a claw, and a pinprick of light broke through the blue of the barrier.] #emph[The gods brandished their weapons and snarled with defiance. No beast would harm an immortal without facing retribution.] #emph[The Hekma wavered. Its film waved as water in a river, and the hole widened enough for the dragon to burst through.] #emph[The dragon protected himself from the attacks of the other gods by separating himself a half-step from reality. The vision of his form remained, but his body was safe from their blows.] #emph[The gods of Amonkhet roared and cursed, but no blow from their weapons would land. The trespasser's power was at least equal to their own. The dragon landed atop the tallest tower, closed his eyes, and began to channel a spell.] #emph[The time for violent choices had come.] #emph[The gods felt a surge of mana weave around the dragon as a tangle of malevolence. They grasped desperately for spells to protect and defend.] #emph[But they were too slow.] #emph[The dragon opened his eyes and every mortal old enough to walk dissipated into the sky.] #emph[A brilliant white light engulfed Naktamun, and the seven gods fell to their knees in agony as countless souls vanished from existence.] #emph[The light retreated. Silence fell, only to be broken by the faraway cries of thousands of motherless, fatherless infants.] #emph[The gods cried out in horror. The infant prayers were without form in their minds. Endless pleas washed over them, waves of wordless fear and confusion, half-finished visions of mothers and fathers breaking apart, particle by particle. The sudden loss of life rendered the gods inert, paralyzed in shock, like losing a limb.] #emph[But two of the gods did not stay still. Hazoret pulled Oketra up from the ground with a quiet assertion. The two fled from the great dragon as he laid claim to their brethren. The dragon, bemused, followed at leisure, silent and unhurried.] #emph[Oketra ran alongside her sister and down into their most sacred mausoleum. As they ducked and entered the holy tomb, passing through row after row of enchanted dead mortals, the shrill sobs of orphans reached the gods' ears. Oketra sealed the door behind them, golden light binding the stone portal shut, and Hazoret began gently picking up as many children as she could.] #emph[Oketra assisted, gathering the children and soothing them with her presence.] #emph[The dragon's laugh suddenly resounded through the mausoleum. Hazoret looked to Oketra as they heard and felt the dragon on the other side of the entrance, testing the barrier's strength. The dragon sensed the heartbeats of the surviving children behind the door, as well as thousands and thousands of enchanted dead, and he chuckled at the perfection of his plan. Slowly he unwound the god's magical seal, taking his time to revel in the despair on the other side of the stone.] #emph[The two gods set the babes in a small alcove within the chamber and stood side by side at the entrance to the sacred mausoleum. Hazoret readied her spear. Oketra drew her bow.] #emph["The children of Naktamun will not die at the hands of a beast!" ] #emph[Hazoret cried.] #emph["The children of Naktamun will die at the end of your spear," replied the dragon.] #emph[The dragon burst through the mausoleum door. Oketra and Hazoret charged. With a wave of a claw, the dragon sent forward a pulse of magic, and the minds of the two gods went utterly blank.] #emph[They fell where they stood.] #emph[The dragon, satisfied, continued his work.] #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) #emph[The next step in the dragon's plan required self-sufficiency. A people who were willing to do the work themselves without the dragon's presence.] #emph[There were many options with many outcomes, but time was growing short—already a day was gone in the subsuming of the gods. The dragon chose the quick path.] #emph[Violent choices.] #emph[First, he returned to the surface and took three of the gods for his own. He stowed them away as one would tools in a cupboard. Their time would come soon enough. With his remaining power, the dragon corrupted and manipulated the leylines of mana that coursed through the remaining gods, willing them to forget their origins, tying their existence to himself, and forcing them to erase all else.] #emph[Second, he opened the tombs under the city and led the enchanted bodies of the dead out of their mausoleums and into the light. There were so many orphaned infants now, and the children would need caretakers.] #emph[Third, he drew on the histories of the plane. There existed an elite religious ceremony—trials of merit, with the result being a single sacrificial champion every revolution of the second sun. A rare cultural cornerstone revered by both man and god. Perfectly suited to repurpose for his designs. The dragon rejoiced at the convenience. What had occurred once every few decades would now demand a constant supply of champions. He spelled the second sun to move as he was ready, to count down until whenever he decided to return. This would be the cornerstone of his machinations on this world.] #emph[Fourth, the dragon built a throne inside the perimeter of the city. On the other side of the barrier, he erected a monument in his own visage, an homage to his magnificent horns, and enchanted it to appear stationary from every angle. He built the monument to frame the smaller sun on the horizon at the moment of his choosing. The dragon was proud. Vanity is survival when one is rapidly losing omnipotence.] #emph[Finally, he made a promise to return, delighting in the writing of his own prophecies, and planting his promise in the gods and the minds and mythos of the denizens below. Mortals adored promises. They saw them as unmovable as mountains, when in truth they were mercurial as rivers.] #emph[As the dragon departed, the small sun continued its slow journey across the sky.] #emph[From afar the dragon maintained, monitored, and moved his machinations on other worlds as the years fell away, urging the second sun slowly around its track] #emph[until this particular moment] #emph[in this particular place] #emph[on this particular plane] #emph[when that sun had rounded its circuit] #emph[and came to settle between the great horns as foretold.] #emph[As promised.] #emph[At last.] #emph[The time had come for the dragon to return to collect his hoard.] #figure(image("001_The Hour of Revelation/01.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none) #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) #emph["And thus the sun reached its zenith behind the horns of the God-Pharaoh, and the promised Hours began. And the last of the people of Amonkhet fell to their knees, and there was much gnashing of teeth for fear of what was coming in the world, and wailing from babes and children, and the gods did mark the moment with solemnity, all as foretold."] #v(0.35em) #line(length: 100%, stroke: rgb(90%, 90%, 90%)) #v(0.35em) Djeru ran as fast as his feet would carry him, eyes fixed on the second sun peeking from behind either side of the leftmost horn in the distance. It left the city in a lingering dusk, and the strangeness of the atmosphere only heightened the excitement and revelry of the citizens of Naktamun. Samut ran alongside Djeru, gripping his shoulder tightly with one hand. As the two exited the arena, they were met with a stampede of citizens, all racing toward the banks of the Luxa River. It was a chaos Djeru had never seen before. Any semblance of commitment to one's own crop had been forgotten, queues and decorum abandoned in the passing from one age of existence to the next. So few were left. In the months leading up to the end of the second sun's cycle, more and more citizens arranged to take the Trials early and prove their worth. Schedules were rearranged. Crops became double the normal size. The result was a city even more empty than usual, populated mostly by the anointed and the youth too young to partake. Djeru and Samut waded through the throngs of children too young to begin the Trials, bumping into their hips, tripping over their legs. The children's arms outstretched and faces warped with desperate, fervent tears. Their small feet moved fast. The anointed caretaker couldn't keep up, and most of their kind had resigned themselves to standing aside to let the stampede through. A shadow passed over them—the legs of Hazoret—and the god stepped high over their heads as she made her way to the river. Throngs of children and those unable to take the Trials tugged at her sandals and leapt for her spear—Take me! Please, Giver of Gifts! Let me die before he comes so I may go along!—but the god ignored them, her eyes trained on the Luxa River and the Gate at the end. The God-Pharaoh's approach was nigh. His homecoming would certainly take place at the Gate to the Afterlife, the massive stone barrier where the Luxa River met the shimmery blue of the Hekma. The Gate used to only open for the lucky few who passed the Trial of Zeal. But now, with the coming of the God-Pharaoh, his promise would be fulfilled. The promise of the Hours. New hope cascaded over Djeru. He was meant to be the final one to pass through the Gate, his glory was to be bestowed unto him by Hazoret, Giver of Gifts. Until Samut ruined everything. Until the traitor, Gideon, intervened. Yet Samut now stood at his side, a hand gripping Djeru's arm, her stance one of protection and shielding. Djeru's heart felt at ease with her familiar presence by his side once again, even as his mind still reeled at her betrayal. #emph[She robbed me of my destiny for her selfish doubts] , he thought. But perhaps the God-Pharaoh would still grant them a place at his side nonetheless. Perhaps he could plead their case, and both prove their worth and show Samut the error of her ways. Djeru whispered a prayer of hope, a little plea drowned out by the cries and yells of the crowd around them in the unfamiliar twilight. "The Hours have begun!" "Where is he?!" "Deliver us, God-Pharaoh! Show us your grace!" "Ow!" Samut cried out as a naga smashed past her in his rush toward the river. "He force-fed us complacency for years and we greet him with #emph[this] ," she seethed under her breath. "It is lies and chaos." Djeru didn't respond to Samut's continued heresy. A growing sound in the distance had drawn his attention. Ambient noise. Endless creaking. Something dark and old, caused by something without form. The khenra nearby all clamped their ears and whined as they ran, the naga jumped as though the earth moved beneath them, and every being instinctively looked to the far end of the river. Samut's grip on his arm tightened. "The Gate." The two picked up their pace and approached the massive crowd that had gathered at the banks of the Luxa. The mass of citizens wailed in fear and boundless joy. A minotaur sobbed, two khenra twins had fallen to their knees in praise, and several children were attempting to ford the river and cross to the Gate. It was a collective madness unlike any Djeru had ever witnessed. For a moment, fear gripped his heart. But the chaos was contagious, and the frenzy of the moment swept Djeru away. Although he was meant to be in the Afterlife by now, Samut's betrayal had given him the privilege of witnessing the God-Pharaoh's return. Perhaps all would work out after all! Suddenly, as abruptly as it began, the noise stopped. Djeru craned for a view, his sandals sinking into the soft mud of the riverbank. Warm water lapped at his toes as bodies pressed all around him, all stretching for a better look. "Djeru, you need to promise me something." Samut's whisper was soft on Djeru's ear. He didn't want to listen to her. But he also didn't want to let her go. "No matter what happens, we protect our gods. We protect each other." Djeru didn't know what she implied, but he silently nodded. A collective gasp of surprise washed through the crowd. In the distance, the light of the second sun spilled past the horn. It had finally passed behind the monument, and a line of brilliant light crossed from one side of Naktamun to the other. A cheer rang out from the crowd as the sun reached its final point, nestled between the faraway horns. At that exact moment, with no warning, the Gate cracked open ever so slightly, the rough grit of its stone parting the current of the river. No living person had ever seen what rested behind the Gate to the Afterlife. Only the dead crossed beyond the Gate, which opened to allow a funerary barge to pass once a day. Even from where they stood, Samut and Djeru felt a hot wind blow through the crack in the Gate. From behind him, Djeru felt a god approach. He watched as Hazoret waded into the river, carefully stepping over the heads of her people, avoiding them as she walked. "#strong[He arrives!] " she cried. Djeru felt the glow of the god's joy seep into him, her exaltation reinforcing his own optimism. A child next to them began crying as others shoved to get closer to the bank of the river. Some aven flew up toward the Gate and tried to pry it open further. Other people waded into the water and swam toward the opening, though none seemed to reach it. It was still impossible to see through the crack. Only a sliver of light betrayed the fact that it was open at all. Samut gripped Djeru's shoulder and shook her head. "We shouldn't stay here. We should go—" The hiss of wind coming from the Gate grew stronger, and in one swift motion, the doors opened wider. Samut's hand fell from Djeru's shoulder as they both stood transfixed, staring at the opening Gate. The entire crowd went silent in awe. The heat of the wind blasting through grew in intensity, peppering the crowd with grit and sand. They held their hands to their eyes to block the sting. The Gate swung all the way open, and the massive crowd gasped. They had been promised paradise. #figure(image("001_The Hour of Revelation/02.jpg", width: 100%), caption: [Art by Raymond Swanland], supplement: none, numbering: none) What lay beyond the Gate were endless, empty wastes. Djeru's mouth hung open. There was supposed to be fields of green meadows! Natural springs and a bountiful ocean! And in its place . . . nothing. Desert. Beasts. Wurms and crocodiles and cursed bodies of heretics. The same thing that was on the Hekma on #emph[all ] its sides. Endless, eternal, all-encompassing and unforgiving #emph[nothing] . Djeru couldn't comprehend it. Around him, the crowd erupted in confusion. Some cheered. Some yelled out words of praise. Others looked to their neighbors for answers. Was #emph[this ] paradise? The concern passed in a wave from person to person, getting louder and louder by the moment. Something massive crashed in the water. Hazoret moved her legs sharply through the current. She began to quiver, ears tightly held back flat against her head, but her arms outstretched in a display of welcoming. Djeru pushed his way to the front, wading into the water behind Hazoret, trying to get a better look. The only thing he could see beyond the Gate was a building that could only be the Necropolis—the fabled place where the worthy dead were laid to rest, awaiting the return of the God-Pharaoh. Djeru turned to Samut, but Samut's attention rested on the god before them. "Hazoret!" Samut yelled. The god whipped her golden head down, her gaze directly on Samut. "Is #emph[that ] paradise?" Hazoret did not answer. Djeru watched her chest heave up and down with concerned breath, her face unreadable. "Please, Hazoret, cast away my doubts and tell me #emph[that ] is paradise." The god lifted her head ever so slightly, and still refused to answer. The rest of the crowd began to argue. There was still no sign of the God-Pharaoh. Was this a test? Was the absence of paradise supposed to mean something? Perhaps paradise will not become manifest until he arrives. Perhaps the place beyond the Gate isn't the endless waste it appears to be—perhaps this was paradise all along! The cacophony of voices fell as a #emph[massive, ] dark, and winged figure flew through the open Gate and past them on the banks of the river. Denizens ducked, then looked up, trying to catch a glimpse of the fleeting shadow. Excited cries and hails calling to the God-Pharaoh rang out. But Djeru knew that thing was no God-Pharaoh. He watched its path as the thing landed resolutely on an obelisk, gazing down on the people below him. He heard Samut draw her khopeshes behind him, heard her hiss a word that tasted like a curse, spat vile and angry from her lips. "#emph[Demon.] " A shiver of dread danced down Djeru's back. Demons were rare on Amonkhet. Djeru had only seen them in texts and in his studies, and as fleeting, dark shapes far outside the Hekma. Such creatures had no place in Paradise—but Djeru knew the legends of this demon. The final test; the last inglorious death before the God-Pharaoh's return. The demon stood high atop the obelisk and spread its wings to catch the warmth of the second sun. Djeru could make out a crocodilian form and a mad smile. Endless scales ending in a thick tail. Sharp wings leading toward a sharper grin. #figure(image("001_The Hour of Revelation/03.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none) The demon surveyed the assembled denizens. Its lips curled into a sneer, then it spread its wings and launched itself back into the sky, circling casually above the river and crowd before hovering just in front of the Gate. There, suspended in midair, the demon held out its right arm and #emph[raked ] its claws into the meat of its forearm. Rivulets of blood caught the light of the sun. The demon showed no reactions of pain, instead muttering an incantation, a low and abrasive rumble that echoed over the water. Djeru recoiled at the sight of blood magic, stepping back out of the river as demon blood fell #emph[drip, drip, drip ] into the water. #figure(image("001_The Hour of Revelation/04.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none) With each drop, the river slowed#emph[.] Then its current halted. Broken reeds sliding downstream came to a sudden and utter stop#emph[.] And as the blood began to spread, leak, stain the brown-green-blue of the Luxa River, the brilliant wash of red began to eek upriver#emph[.] Shrill screams rang out from the people near the water, growing as many turned to flee, wading out of the river. Djeru watched as the now-stagnant water coalesced into a deep crimson. He felt a strange power #emph[pulse] from the Luxa in waves. The demon had turned the river into blood. #figure(image("001_The Hour of Revelation/05.jpg", width: 100%), caption: [Art by <NAME>], supplement: none, numbering: none) The blood spread, choking reeds and suffocating everything swimming in its depths. Fish began to bob to the surface, mouths gasping and eyes wide. Upriver, dozens of hippopotamuses tried to crawl their way out of the sludge of blood and mud only to drown in the thick mire. An enormous crocodile breached the surface, coughing out red and audibly gasping through the thick liquid. It rolled and gnashed on the bank, its dying body squishing dead fish and eels further into the wine-colored mud beneath it. Everything in the river desperately wanted #emph[out] . They hastened their deaths as they frantically writhed in the coagulating morass. Samut grabbed Djeru's arm, a grim expression on her face. "Do you still believe this is the act of a benevolent God-Pharaoh?" Djeru shook his head, doubt flooding his mind. As he opened his mouth to answer, an abyssal voice reverberated in the air, booming deep, barbed with malice and filled with horror. On reflex, Djeru clasped his hands over his ears, but it did nothing to shut out the voice of the demon. "Liliana," it rumbled. Samut's eyes widened. "Why would the demon know the name of one of the interlopers?" She asked Djeru. He only shook his head in response. Djeru peered up at the demon and felt the blood in his veins run cold. The demon #emph[smiled] , razor teeth and fathomless eyes a portrait of power and despair. Its voice boomed out again across the river of blood. "I know you are here, <NAME>. You cannot hide from me."
https://github.com/OriginCode/typst-homework-template
https://raw.githubusercontent.com/OriginCode/typst-homework-template/master/README.md
markdown
# OriginCode's Typst Homework Template A homework template for [Typst](https://typst.app/), inspired by [<NAME>'s Homework Template](https://www.countablethoughts.com/documents/homework-anon.tex) in $\LaTeX$ (sorry GitHub only allows me to display LaTeX in math mode). ## Usage There are two main functions: `question` and `part`, which marks the corresponding sections. There is also a helper function `indented` to create indented texts. You can turn on question counter (e.g., "1. Question One") by set `disp_question_counter` variable in `template.typ` to `true`. ## Example Source: [example.typ](./example.typ) Rendered Result: [example.pdf](./example.pdf)
https://github.com/maxlambertini/troika-srd-typst
https://raw.githubusercontent.com/maxlambertini/troika-srd-typst/main/chap01.typ
typst
#let chap01_title= [= Terms] #let chap01=[ <terms> Anyone may publish free or commercial material based upon and/or declaring compatibility with "Troika!" without express written permission from the publisher, the Melsonian Arts Council, as long as they adhere to the following terms: If your product declares compatibility with Troika! you must state the following in your legal text and on any websites from which a commercial product is sold: "\[product name\] is an independent production by \[publisher name\] and is not affiliated with the Melsonian Arts Council." The Melsonian Arts Council takes no responsibility for any legal claims against your product. The mechanics and concepts of "Troika!" may be reused freely. The text of "Troika!" may not be used verbatim. All artists maintain copyright of their work. == About this version This is a conversion in `typst` format of the main SRD. The following fonts have been used in the typesetting process of this PDF file: === Averia Libre Licensed under SIL Font License. - AveriaSerifLibre-Light.ttf: Copyright (c) 2011, <NAME> (<EMAIL>), with Reserved Font Name 'Averia' and 'Averia Libre'. - AveriaSerifLibre-LightItalic.ttf: Copyright (c) 2011, <NAME> (<EMAIL>), with Reserved Font Name 'Averia' and 'Averia Libre'. - AveriaSerifLibre-Regular.ttf: Copyright (c) 2011, <NAME> (<EMAIL>), with Reserved Font Name 'Averia' and 'Averia Libre'. - AveriaSerifLibre-Italic.ttf: Copyright (c) 2011, <NAME> (<EMAIL>), with Reserved Font Name 'Averia' and 'Averia Libre'. - AveriaSerifLibre-Bold.ttf: Copyright (c) 2011, <NAME> (<EMAIL>), with Reserved Font Name 'Averia' and 'Averia Libre'. - AveriaSerifLibre-BoldItalic.ttf: Copyright (c) 2011, <NAME> (<EMAIL>), with Reserved Font Name 'Averia' and 'Averia Libre'. === Bokor Licensed under SIL Font License. - Bokor-Regular.ttf: Copyright 2020 The Bokor Project Authors (https://github.com/danhhong/Bokor) ]
https://github.com/soul667/typst_template
https://raw.githubusercontent.com/soul667/typst_template/main/基本模板/test.typ
typst
#let data=yaml("./data.yml") #import"template.typ": * #show: doc => conf( // linespacing: setting.行间距*1pt, outlinedepth: 3, blind: false, listofimage: true, listoftable: true, listofcode: true, alwaysstartodd: true, doc ) #let setting=data.模板设置; // // 首先是论文标题 #if setting.模板选择=="论文" { align(center, [ // #v(24pt) #text([#data.文章信息.标题 ], size:字号.三号,weight: "bold",font:字体.黑体) #if data.文章信息.副标题!="#data.文章信息.标题"{ v(-0.2em) let len_=data.文章信息.副标题.len(); if len_!=0{ for j in data.文章信息.副标题{ text([#j ], size:字号.小四) h(1em) } } } ]) ////////// [ #v(1em) #h(-2em) #heiti("摘要") 吱吱吱吱 #v(0em) #h(-2em) #heiti("关键词") 吱吱吱吱 #v(1em) ] } // 对于论文模式要做修改 = 一级标题 == 二级标题 === 三级标题 ==== 四级标题
https://github.com/0x1B05/algorithm-journey
https://raw.githubusercontent.com/0x1B05/algorithm-journey/main/practice/note/content/排序.typ
typst
#import "../template.typ": * #pagebreak() == 简单排序算法 === 选择排序 ```java public static void selectSort(int[] arr) { int len = arr.length; if (arr == null || len < 2) { return; } for (int i = 0; i < len - 1; i++) { int minIndex = i; for (int j = i + 1; j < len; j++) { if (arr[j] < arr[minIndex]) { minIndex = j; } } swap(arr, i, minIndex); } } ``` === 冒泡排序 ```java public static void bubleSort(int[] arr) { int len = arr.length; if (arr == null || len < 2) { return; } for (int i = len - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (arr[j] > arr[j + 1]) { swap(arr, j, j + 1); } } } } ``` === 插入排序 ```java public static void insertSort(int[] arr) { int len = arr.length; if (arr == null || len < 2) { return; } for (int i = 0; i < len - 1; i++) {//假设前i已经有序 for (int j = i + 1; j > 0 && arr[j - 1] > arr[j]; j--) {//对i+1向前插入 swap(arr, j, j - 1); } } } ``` == nlogn 排序 === 归并排序 ```java public static void mergeSort(int[] arr) { int len = arr.length; if (arr == null || len < 2) { return; } process(arr, 0, len-1); } public static void process(int[] arr, int L, int R) { if (L == R) { return; } int mid = L + ((R - L) >> 1); process(arr, L, mid); process(arr, mid + 1, R); merge(arr, L, mid, R); } public static void merge(int[] arr, int L, int M, int R) { int[] container = new int[R - L + 1]; int i = 0; int p1 = L, p2 = M + 1; while (p1 <= M && p2 <= R) { container[i++] = arr[p1] <= arr[p2] ? arr[p1++] : arr[p2++]; } while (p1 <= M) { container[i++] = arr[p1++]; } while (p2 <= R) { container[i++] = arr[p2++]; } for(i = 0;i<container.length;i++) { arr[L+i] = container[i]; } } ``` ==== 小和问题 数组小和定义如下: $sum_(i=1)^(n)f_(i)$(其中$f_(i)$的定义是第$i$个数的左侧小于等于$s_(i)$的个数) 例如,数组 `s = [1, 3, 5, 2, 4, 6]` ,在 `s[0]` 的左边小于或等于 `s[0]` 的数的和为 0 ; 在 `s[1]` 的左边小于或等于 `s[1]` 的数的和为 1 ;在 `s[2]` 的左边小于或等于 `s[2]` 的数的和为 1+3=4 ;在 `s[3]` 的左边小于或等于 `s[3]` 的数的和为 1 ;在 `s[4]` 的左边小于或等于 `s[4]` 的数的和为 1+3+2=6 ;在 `s[5]` 的左边小于或等于 `s[5]` 的数的和为 1+3+5+2+4=15 .所以 s 的小和为 0+1+4+1+6+15=27 给定一个数组 s ,实现函数返回 s 的小和. #tip("Tip")[ 变换参考系,从每个数右侧有几个数比自己大的角度入手. ] ```java public static long smallSum(int[] nums) { int len = nums.length; if (len < 2) { return 0; } return process(nums, 0, len - 1); } public static long process(int[] nums, int left, int right) { if (left == right) { return 0; } int mid = left + ((right - left) >> 1); return process(nums, left, mid) + process(nums, mid + 1, right) + merge(nums, left, right); } public static long merge(int[] nums, int left, int right) { int mid = left + ((right - left) >> 1); int p1 = left; int p2 = mid + 1; int[] container = new int[right - left + 1]; int i = 0; long sum = 0; while (p1 <= mid && p2 <= right) { sum += nums[p1] <= nums[p2] ? (nums[p1] * (right - p2 + 1)) : 0; container[i++] = nums[p1] <= nums[p2] ? nums[p1++] : nums[p2++]; // ++为各自运算 } while (p1 <= mid) { container[i++] = nums[p1++]; } while (p2 <= right) { container[i++] = nums[p2++]; } for (i = 0; i < (right - left + 1); i++) { nums[left + i] = container[i]; } return sum; } ``` #tip("Tip")[ 为什么想到用归并排序:归并排序的子序列有序,根据有序的子序列可以将时间复杂度降低. ] ==== 逆序对问题 在一个数组中,左边的数如果比右边的数大,则这两个数构成一个逆序对,找到逆序对的数量. ```java public static int reversePairs(int[] arr) { int len = arr.length; if (arr == null || len < 2) { return 0; } return process(arr, 0, len-1); } public static int process(int[] arr, int L, int R) { if (L == R) { return 0; } int mid = L + ((R - L) >> 1); return process(arr, L, mid)+process(arr, mid + 1, R)+mergeAndCount(arr, L, mid, R); } public static int mergeAndCount(int[] arr, int L, int M, int R) { int[] container = new int[R - L + 1]; int i = 0; int p1 = L, p2 = M + 1; int res = 0; while (p1 <= M && p2 <= R) { res += arr[p1] > arr[p2] ? (M-p1+1) : 0;//降低时间复杂度所在 container[i++] = arr[p1] > arr[p2] ? arr[p2++] : arr[p1++]; } while (p1 <= M) { container[i++] = arr[p1++]; } while (p2 <= R) { container[i++] = arr[p2++]; } for(i = 0;i<container.length;i++) { arr[L+i] = container[i]; } return res; } ``` === 快速排序 ==== 快速排序 1.0 ===== 问题引入 给定一个数组`arr`和一个数 `num`,请把小于等于 `num`的数放在数组的左边,大于 `num`的数放在数组的右边.要求额外空间复杂度 `O(1)`,时间复杂度 `O(N)`. ```java public static void swap(int[]arr,int i,int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } public static void qs1(int[]arr,int num) { int i = -1; //小于等于区域 for(int j = 0;j<arr.length;j++) { if(arr[j]<=num) { swap(arr, ++i, j); } } } ``` ===== 快排 1.0 以最右边的数为基准分开数组,分开后将最右边的数与比起刚大一点的数交换,再将左右两侧递归使用上述方法(取最右侧为基准) ```java public static void process(int[] arr, int l, int r) { if (l >= r) { //仅仅是=是不够的,举例l=0,r=-1(即上一轮less=0) return; } int num = arr[r]; int less = l - 1; // 小于等于区域 for (int p = l; p <= r; p++) { if (arr[p] <= num) { swap(arr, ++less, p); } } process(arr, l, less-1);//注意r=less-1,而不是less,若为less,当less为子序列最大值时会造成死循环 process(arr, less + 1, r); } public static void swap(int[] arr,int i,int j) { if(arr[i]==arr[j]) { return; } arr[i] = arr[i]^arr[j]; arr[j] = arr[i]^arr[j]; arr[i] = arr[i]^arr[j]; } public static void quickSort(int[] arr) { process(arr, 0, arr.length - 1); } ``` ==== 快速排序 2.0 ===== 荷兰国旗问题 给定一个数组`arr`和一个数 `num`,请把小于`num`的数放在数组的左边,等于`num`的数放在数组的中间,大于 `num`的数放在数组的右边.要求额外空间复杂度 `O(1)`,时间复杂度 `O(N)`. ```java public static void netherlandsFlag(int[] arr,int num) { int less = -1,more = arr.length; int p= 0; for(p = 0;p < more;p++) { if(arr[p]<num) { swap(arr, ++less, p); }else if(arr[p]>num){ swap(arr, --more, p--); } } } public static void swap(int[] arr,int i,int j) { if(arr[i]==arr[j]) { return; } arr[i] = arr[i]^arr[j]; arr[j] = arr[i]^arr[j]; arr[i] = arr[i]^arr[j]; } ``` ===== 快排 2.0 在 1.0 的基础上将最右侧数的一组放在中间,左侧都比其小,右侧都比其大. ```java public static void quickSort(int[] arr) { process(arr, 0, arr.length - 1); } public static void process(int[] arr, int l, int r) { if (l >= r) { return; } int less = l-1,more = r+1; int num = arr[r]; int p= l; for(p = l;p<more;p++) { if(arr[p]<num) { swap(arr, ++less, p); }else if(arr[p]>num){ swap(arr, --more, p--); // 大于区的交换之后未比较过,所以下标不能跳到下一位 } } process(arr, l, less); process(arr, more, r); } public static void swap(int[] arr,int i,int j) { if(arr[i]==arr[j]) { return; } arr[i] = arr[i]^arr[j]; arr[j] = arr[i]^arr[j]; arr[i] = arr[i]^arr[j]; } ``` 数组有序的时候时间复杂度最高为 O(n^2) ==== 快速排序 3.0 ```java public static void quickSort(int[] arr) { process(arr, 0, arr.length - 1); } public static void process(int[] arr, int l, int r) { if (l >= r) { return; } swap(arr, l + (int) (Math.random() * (r - l + 1)), r);//利用随机数避免了人为构造复杂度高的数组 int less = l-1,more = r+1; int num = arr[r]; int p= l; for(p = l;p<more;p++) { if(arr[p]<num) { swap(arr, ++less, p); }else if(arr[p]>num){ swap(arr, --more, p--); } } process(arr, l, less); process(arr, more, r); } public static void swap(int[] arr,int i,int j) { if(arr[i]==arr[j]) { return; } arr[i] = arr[i]^arr[j]; arr[j] = arr[i]^arr[j]; arr[i] = arr[i]^arr[j]; } ``` == 堆排序 === 完全二叉树子树和父树节点之间关系 ==== 前提条件 二叉树一个节点有 2 个子节点,左节点和右节点。 ==== 推导过程 假设根节点下标从 0 开始,则第 k 层的最后一个节点下标为:$2^{k}-1-1$,第一个节点为$2^{k-1}-1$。 假设父节点为第 k 层第 m 个节点,则其下标为:$F=2^{k-1}+m-1-1=2^{k-1}+m-2 $ 其左子节点的下标 $C = F+(2^{k-1}-m)+(m-1) dot.op 2+1 $ $ = 2^{k-1}-m-2+(2^{k-1}-m)+(m-1) dot.op 2+1$ $ =2^{k}+2 m-4+1 =2F+1 $ 即 *左子节点=2\*父节点+1* 同理 *右子节点=2\*父节点+2* 同样可知 *父节点=(子节点-1)/2*(这里计算机中的除以 2,省略掉小数) === 大根堆实现堆排序 大根堆就是根节点是整棵树的最大值(根节点大于等于左右子树的最大值),对于他的任意子树,根节点也是最大值。 ```java public static void heapSort(int[] nums) { if (nums == null || nums.length < 2) { return; } // // 首先对整体进行堆化 // int heapSize = 0; // for (heapSize = 0; heapSize < nums.length; heapSize++) { // heapInsert(nums, heapSize); // o(logn) // } // 一种更快的堆化方式:利用heapify,所有数字是一次性给出,而不是一个个 int heapSize = nums.length; for (int i = heapSize - 1; i >= 0; i--) { // 注意取等0 heapify(nums, i, heapSize); } heapSize = nums.length; // 假设是完全二叉树,则复杂度:T(n) = n/2+(n/4)*2+(n/8)*3.... 为o(n) // heapSize表示长度而不是下标 for (int i = 0; i < nums.length; i++) { swap(nums, 0, --heapSize); // o(1) heapify(nums, 0, heapSize); // o(logn) 事实上heapInsert也能完成堆化操作,但是复杂度高 } } // 当前处于index位置,继续向上移动 public static void heapInsert(int[] nums, int index) { int parent = (index - 1) / 2; while (nums[index] > nums[parent]) {// 循环停止条件:1.已经是根节点的时候 2.父节点更大时 swap(nums, index, parent); index = (index - 1) / 2; parent = (index - 1) / 2; } } // 某个数在index位置,能否往下移动(子树都是大根堆) public static void heapify(int[] nums, int index, int heapSize) { int parent = index; int left = 2 * parent + 1; int right = 2 * parent + 2; while (left < heapSize) { // left是下标,heapSize是具体长度,故用<;这句话里表示如果还有孩子的话 int largerChild = right < heapSize && nums[right] > nums[left] ? right : left;// 找到孩子中较大的一个 int max = nums[largerChild] > nums[parent] ? largerChild : parent; // 找出父亲和较大的孩子里较大的那一个 if (max != parent) { // 最大值不是父节点,交换父节点和最大值(即较大孩子) swap(nums, parent, max); parent = max; left = 2 * parent + 1; right = 2 * parent + 2; } else { // 最大值就是父节点,堆化完成 break; } } } ``` #tip("Tip")[ - 降序可以使用小根堆。 - 若是已知某个大根堆中 `i` 位置的数改成了`x` ,继续调整为大根堆要么 `heapInsert` 要么 `heapify` ] ==== 堆排序扩展题目 已知一个几乎有序的数组, 几乎有序是指, 如果把数组排好顺序的话, 每个元素移动的距离可以不超过 k, 并且 k 相对于数组来说比较小。请选择一个合适的排序算法针对这个数据进行排序。 ```java // 复杂度o(nlogk) public static void sortedArrDistanceLessK(int[] arr, int k) { PriorityQueue<Integer> heap = new PriorityQueue<>(); // p1是入堆的指针,p2是排序数组的指针 int p1 = 0; int p2 = 0; // 首先前 k+1 入堆 for (; p1 <= Math.min(arr.length-1, k); p1++) { heap.add(arr[p1]); } // 接着往后依次维护 k+1 大小的范围 依次弹出最小值 for (; p1 < arr.length; p1++, p2++) { arr[p2] = heap.poll(); heap.add(arr[p1]); } while (!heap.isEmpty()) { arr[p2++] = heap.poll(); } } ``` > 这里使用了系统提供的优先队列结构(即小根堆) > 扩容:每次成倍扩容,每扩容一次拷贝一下 o(n),扩容次数为 o(logn),但是平均每个数字只有 o(logn) == 基数排序(不基于比较的排序) 不基于比较的排序一定要根据具体数据状况来做出一些操作 ```java public static void radixSort(int[] nums) { if (nums == null || nums.length < 2) { return; } radixSort(nums, 0, nums.length-1, getDigit(nums)); } // 获得num倒数第digit位的数字 public static int getNum(int num, int digit) { // 先求10的d-1次方 // x除以10的d-1次方后 // 得到的数再与10求余 return (num / (int) Math.pow(10, digit - 1)) % 10; } // 获得nums数组中的最大数的最大进制位 public static int getDigit(int[] nums) { int max = Integer.MIN_VALUE; int digit = 0; // 遍历得到数组最大值 for (int i = 0; i < nums.length; i++) { max = Math.max(max, nums[i]); } // 获取最大值的位数 while (max > 0) { max /= 10; digit++; } return digit; } // digit代表nums数组中最大数的最大进制位 public static void radixSort(int[] nums, int left, int right, int digit) { // radix表示10进制 // container为辅助数组,临时存储nums final int radix = 10; int[] container = new int[right-left+1]; // 依次对最低位到最高位进行排序 for (int d = 1; d <= digit; d++) { // 申请0-9的基数数组 int[] cnt = new int[radix]; // 进行nums数组倒数第d位的词频统计 for (int i = left; i <= right; i++) { int num = getNum(nums[i], d); cnt[num]++; } // 将基数数组改为前缀和数组 // cnt[i]代表当前位上≤i的数字有几个 for (int i = 1; i < cnt.length; i++) { cnt[i] = cnt[i] + cnt[i-1]; } // 把nums[i]按cnt数组的顺序放在辅助数组中 // 从右向左进行遍历,保证后进桶的后出桶,因为后进桶的倒数d-1位更大,排在更后面 for (int i = container.length-1; i >= 0; i--) { // num表示当前数倒数第d位的数 int num = getNum(nums[left+i], d); // --cnt[num]当前数应该放的顺序,--是因为cnt数组代表的是个数而不是下标,且放置后需要-1操作 container[--cnt[num]] = nums[left+i]; } // 将排好序的辅助数组copy回原数组 for (int i = 0; i < container.length; i++) { nums[left+i] = container[i]; } } } ``` == 总结 #image("./images/2022-03-16-11-12-44.png") === 排序稳定性: 同样值的个体之间。如果不因为排序而改变相对次序,这个排序就是具有稳定性的,否则就是没有。 ==== 不具备稳定性的排序: 选择排序、快速排序、堆排序 ==== 可具备稳定性的排序: 冒泡排序、插入排序、归并排序、一切桶排序思想下的排序 === 基于比较的排序: 1. 一般都是用快排,因为快排的常数项指标最低 1. O(NlogN)是最快的了 1. 当时间复杂度 O(NlogN),空间复杂度 O(N)的条件下,还可以保持稳定,目前没有这样的算法 === 一些坑: 1. 归并排序的额外空间复杂度可以变成 O(1),但实现很难(实现可用归并内部缓存法),还会丧失稳定性,不如直接用堆排序。 2. 原地归并排序没有意义,空间复杂度变成 O(1),但时间复杂度 O(N²),不如直接用插入排序。 3. 快排可以做到稳定性,但会使快排的空间复杂度变成 O(N),不如直接用归并排序。 4. 所以没必要改进,要得到一些性质就必要损失一些性质。 5. 如果面试官问你:奇数放数组左边,偶数放在数组右边,还要求原始的相对次序不变,时间复杂度 O(N),空间复杂度 O(1)。你可以回答这类似于经典快排的 0 1 问题,但没办法做到上面的要求,所以我不会,希望面试官可以教教我。 === 工程上对排序的改进 1. 充分利用 O(nlogn)和 O(n^2)排序各自的优势 > 例如小样本插入排序(此时 O(n^2)较快,常数项小),样本大的时候快排 2. 稳定性的考虑
https://github.com/Robotechnic/alchemist
https://raw.githubusercontent.com/Robotechnic/alchemist/master/doc/manual.typ
typst
MIT License
#import "@preview/mantys:0.1.4": * #import "@preview/alchemist:0.1.1" #import "@preview/cetz:0.2.2" #let infos = toml("../typst.toml") #show: mantys.with( ..infos, abstract: [ Alchemist is a package used to draw chemical structures with skeletal formulas using Cetz. It is heavily inspired by the Chemfig package for LaTeX. This package is meant to be easy to use and customizable. It can also be used alongside the cetz package to draw more complex structures. ], examples-scope: (dictionary(alchemist)), ) #let example = example.with(side-by-side: true) #import alchemist: * // Some fancy logos // credits go to discord user @adriandelgado #let TeX = style(styles => { set text(font: "New Computer Modern") let e = measure("E", styles) let T = "T" let E = text(1em, baseline: e.height * 0.31, "E") let X = "X" box(T + h(-0.15em) + E + h(-0.125em) + X) }) #let LaTeX = style(styles => { set text(font: "New Computer Modern") let a-size = 0.66em let l = measure("L", styles) let a = measure(text(a-size, "A"), styles) let L = "L" let A = box(scale(x: 110%, text(a-size, baseline: a.height - l.height, "A"))) box(L + h(-a.width * 0.67) + A + h(-a.width * 0.25) + TeX) }) #show "LaTeX": LaTeX #show "@version": infos.package.version #let info(body) = mty.alert( color: rgb("#0074d9"), body, ) #add-type("drawable", color: lime) = Usage To start using Alchemist, just import the package in your document: ```typ #import "@preview/alchemist:@version": * ``` == Initializing drawing environment To start drawing molecules, you first need to initialise the drawing environment. This is done by calling the #cmd[skeletize] function. ```typ #skeletize({ ... }) ``` The main argument is a block of code that contains the drawing instructions. The block can also contain any cetz code to draw more complex structures, see @exemple-cez. #command("skeletize", arg(debug: false), arg(background: none), arg(config: (:)), arg("body"))[ #argument("debug", types: (true))[ Display bounding boxes of the objects in the drawing environment. ] #argument("background", types: (red, none))[ Background color of the drawing environment ] #argument("config", types: ((:)))[ Configuration of the drawing environment. See @config. ] #argument("body", types: ("drawable"))[ The module to draw or any cetz drawable object. ] ] == Drawing a molecule directly in Cetz Sometimes, you may want to draw a molecule directly in cetz. To do so, you can use the #cmd[draw-skeleton] function. This function is what is used internally by the #cmd[skeletize] function. #command("draw-skeleton", arg(config: (:)), arg("body"))[ #argument("config", types: ((:)))[ Configuration of the drawing environment. See @config. ] #argument("body", types: ("drawable"))[ The module to draw or any cetz drawable object. ] #argument("name", types: (""), default: none)[ If a name is provided, the molecule will be placed in a cetz group with this name. ] #argument("mol-anchor", types: (""), default: none)[ Anchor of the group. It is working the same way as the `anchor` argument of the cetz `group` function. The `default` anchor of the molecule is the east anchor of the first atom or the starting point of the first link. ] ] The usefulness of this function comes when you want to draw multiples molecules in the same cetz environment. See @exemple-cez. == Configuration <config> Th configuration dictionary that you can pass to skeletize defines a set of default values for a lot of parameters in alchemist. #import "../src/default.typ": default #argument("atom-sep", default: default.atom-sep, types: default.atom-sep)[ It defines the distance between each atom center. It is overridden by the `atom-sep` argument of link ] #argument("angle-increment", default: default.angle-increment, types: default.angle-increment)[ It defines the angle added by each increment of the `angle` argument of link ] #argument("base-angle", default: default.base-angle, types: default.base-angle)[ Default angle at which the link with no angle defined will be. ] == Available commands #tidy-module( read("../lib.typ"), name: infos.package.name, show-outline: false, include-examples-scope: true, extract-headings: 3, ) === Link functions <links> ==== Common arguments Links functions are used to draw links between molecules. They all have the same base arguments but can be customized with additional arguments. #argument("angle", types: (1), default: 0)[ Multiplier of the `angle-increment` argument of the drawing environment. The final angle is relative to the abscissa axis. ] #argument("relative", types: (0deg), default: none)[ Relative angle to the previous link. This argument override all other angle arguments. ] #argument("absolute", types: (0deg), default: none)[ Absolute angle of the link. This argument override `angle` argument. ] #argument("antom-sep", types: (1em), default: default.atom-sep)[ Distance between the two connected atom of the link. Default to the `atom-sep` entry of the configuration dictionary. ] #argument("from", types: (0))[ Index of the molecule in the group to start the link from. By default, it is computed depending on the angle of the link. ] #argument("to", types: (0))[ Index of the molecule in the group to end the link to. By default, it is computed depending on the angle of the link. ] #argument("links", types: ((:)))[ Dictionary of links to other molecules or hooks. The key is the name of the molecule or the hook and the value is the link function. ] ==== Links #tidy-module( read("../src/links.typ"), name: infos.package.name, show-outline: false, include-examples-scope: true, extract-headings: 3, ) = Drawing molecules == Atoms In alchemist, the name of the function #cmd("molecule") is used to create a group of atom but here it is a little bit abusive as it do not necessarily represent real molecules. An atom is in our case something of the form: optional number + capital letter + optional lowercase letter followed by indices or exponent. #info[ For instance, $H_2O$ is a molecule of the atoms $H_2$ and $O$. If we look at the bounding boxes of the molecules, we can see that separation. #align( center, grid( columns: 2, column-gutter: 1em, row-gutter: .65em, $H_2O$, skeletize(debug: true, molecule($H_2O$)), $C H_4$, skeletize(debug: true, molecule($C H_4$)), $C_2 H_6$, skeletize(debug: true, molecule($C_2H_6$)), ), ) ] This separation does not have any impact on the drawing of the molecules but it will be useful when we will draw more complex structures. == Links There are already som links available with the package (see @links) and you can create your own links with the #cmd[build-link] function but they all share the same base arguments used to control their behaviors. === Atom separation Each atom is separated by a distance defined by the `atom-sep` argument of the drawing environment. This distance can be overridden by the `atom-sep` argument of the link. It defines the distance between the center of the two connected atoms. The behavior is not well defined yet. === Angle There are three ways to define the angle of a link: using the `angle` argument, the `relative` argument, or the `absolute` argument. The argument `angle` is a multiplier of the `angle-increment` argument. #example(``` #skeletize({ single() single(angle:1) single(angle:3) single() single(angle:7) single(angle:6) }) ```) Changing the `angle-increment` argument of the drawing environment will change the angle of the links. #example(``` #skeletize(config:(angle-increment:20deg),{ single() single(angle:1) single(angle:3) single() single(angle:7) single(angle:6) }) ```) The argument `relative` allows you to define the angle of the link relative to the previous link. #example(``` #skeletize({ single() single(relative:20deg) single(relative:20deg) single(relative:20deg) single(relative:20deg) }) ```) The argument `absolute` allows you to define the angle of the link relative to the abscissa axis. #example(``` #skeletize({ single() single(absolute:-20deg) single(absolute:10deg) single(absolute:40deg) single(absolute:-90deg) }) ```) === Starting and ending points By default, the starting and ending points of the links are computed depending on the angle of the link. You can override this behavior by using the `from` and `to` arguments. If the angle is in $]-90deg;90deg]$, the starting point is the last atom of the previous molecule and the ending point is the first atom of the next molecule. If the angle is in $]90deg;270deg]$, the starting point is the first atom of the previous molecule and the ending point is the last atom of the next molecule. #grid(columns: (1fr, 1fr, 1fr, 1fr), align: center + horizon, row-gutter: 1em, ..for i in range(0, 8) { ( skeletize({ molecule("ABCD") single(angle: i) molecule("EFGH") }), ) }) If you choose to override the starting and ending points, you can use the `from` and `to` arguments. The only constraint is that the index must be in the range $[0, n-1]$ where $n$ is the number of atoms in the molecule. #grid(columns: (1fr, 1fr, 1fr, 1fr), align: center, row-gutter: 1em, ..for i in range(0, 4) { ( skeletize({ molecule("ABCD") single(from: i, to: 3 - i, absolute: 70deg) molecule("EFGH") }), ) }) #info[ The fact that you can chose any index for the `from` and `to` arguments can lead to some weird results. Alchemist can't check if he result is beautiful or not. ] == Branches Drawing linear molecules is nice but being able to draw molecule with branches is even better. To do so, you can use the #cmd[branch] function. The principle is simple. When you draw normal molecules, each time an element is added, the attachement point is moved accordingly to the added object. Drawing a branch is a way to tell alchemist that you want the attachement point to say the same for the others elements outside the branch. The only constraint is that the branch must start with a link. #example(``` #skeletize({ molecule("A") single() molecule("B") branch({ single(angle:1) molecule("W") single() molecule("X") }) single() molecule("C") }) ```) It is of course possible to have nested branches or branches with the same starting point. #example(``` #skeletize({ molecule("A") branch({ single(angle:1) molecule("B") branch({ single(angle:1) molecule("W") single() molecule("X") }) single() molecule("C") }) branch({ single(angle:-2) molecule("Y") single(angle:-1) molecule("Z") }) single() molecule("D") }) ```) You can also specify an angle argument like for links. This angle will be then used as the `base-angle` for the branch. It means that all the links with no angle defined will be drawn with this angle. #example(``` #skeletize({ molecule("A") single() molecule("B") branch(relative:60deg,{ single() molecule("D") single() molecule("E") }) branch(relative:-30deg,{ single() molecule("F") single() molecule("G") }) single() molecule("C") }) ```) == Link distant atoms === Basic usage From then, the only way to link atoms is to use links functions and putting them one after the other. This doesn't allow to do cycles or to link atoms that are not next to each other in the code. The way alchemist handle this is with the `links` and `name` arguments of the #cmd[molecule] function. #example(``` #skeletize({ molecule(name: "A", "A") single() molecule("B") branch({ single(angle: 1) molecule( "W", links: ( "A": single(), ), ) single() molecule(name: "X", "X") }) branch({ single(angle: -1) molecule("Y") single() molecule( name: "Z", "Z", links: ( "X": single(), ), ) }) single() molecule( "C", links: ( "X": single(), "Z": single(), ), ) }) ```) In this example, we can see that the molecules are linked to the molecules defined before with the `name` argument. Note that you can't link to a molecule that is defined after the current one because the name is not defined yet. It's a limitation of the current implementation. === Customizing links If you look at the previous example, you can see that the links used in the `links` argument are functions. This is because you can still customize the links as you want. The only thing that is not taken into account are the `length` and `angle` arguments. It means that you can change color, `from` and `to` arguments, etc. #example(``` #skeletize({ molecule(name: "A", "A") single() molecule("B") branch({ single(angle: 1) molecule( "W", links: ( "A": double(stroke: red), ), ) single() molecule(name: "X", "X") }) branch({ single(angle: -1) molecule("Y") single() molecule( name: "Z", "Z", links: ( "X": single(stroke: black + 3pt), ), ) }) single() molecule( "C", links: ( "X": cram-filled-left(fill: blue), "Z": single(), ), ) }) ```) == Cycles === Basic usage Using branches and `links` arguments, you can draw cycles. However, depending on the number of faces, the angle calculation is fastidious. To help you with that, you can use the #cmd[cycle] function. The default behavior if the angle is $0deg$ is to be placed in a way that the last link is vertical. #example(``` #skeletize({ molecule("A") cycle(5, { single() molecule("B") double() molecule("C") single() molecule("D") single() molecule("E") double() }) }) ```) If the angle is not $0deg$ or if the `align` argument is set, the cycle will be drawn in relation with the relative angle of the last link. #example(``` #skeletize({ single() molecule("A") cycle(5, align: true, { single() molecule("B") double() molecule("C") single() molecule("D") single() molecule("E") double() }) }) ```) A cycle must start by a link and if there is more links than the number of faces, the excess links will be ignored. Nevertheless, it is possible to have less links than the number of faces. #example(``` #skeletize({ cycle(4,{ single() molecule("A") single() molecule("B") single() molecule("C") single() molecule("D") }) }) ```) === Branches in cycles It is possible to add branches in cycles. You can add a branch at any point of the cycle. The default angle of the branch will be set in a way that it is the bisector of the two links that are next to the branch. #example(``` #skeletize({ cycle(5,{ branch({ single() molecule("A") double() molecule("B") single() molecule("C") }) single() branch({ single() molecule("D") single() molecule("E") }) single() branch({ double() }) single() branch({ single() molecule("F") }) single() branch({ single() molecule("G") double() }) single() single() single() single() }) }) ```) === Cycles imbrication Like branches, you can add cycles in cycles. By default the cycle will be placed in a way that the two cycles share a common link. #example(``` #skeletize({ molecule("A") cycle(7,{ single() molecule("B") cycle(5,{ single() single() single() single() }) double() single() double() cycle(4,{ single() single() single() }) single() double() single() }) }) ```) === Issues with atom groups Cycles by default have an issue with atom groups with multiples atoms. The links are not well placed for the cycle to be drawn correctly. #example(``` #skeletize({ molecule("AB") cycle(5,{ single() molecule("CDE") single() molecule("F") single() molecule("GH") single() molecule("I") single() }) }) ```) To fix that, you have to use the `from` and `to` arguments of the links to specify the starting and ending points of the links. #example(``` #skeletize({ molecule("AB") cycle(5,{ single(from: 1, to: 0) molecule("CDE") single(from: 0) molecule("F") single(to: 0) molecule("GH") single(from: 0) molecule("I") single(to: 1) }) }) ```) === Arcs It is possible to draw arcs in cycles. The `arc` argument is a dictionary with the following entries: #argument("start", types: (0deg), default: 0deg)[ Angle at which the arc starts. ] #argument("end", types: (0deg), default: 360deg)[ Angle at which the arc ends. ] #argument("delta", types: (0deg), default: none)[ Angle of the arc in degrees. ] #argument("radius", types: (0.1), default: none)[ Radius of the arc in percentage of the smallest distance between two opposite atoms in the cycle. By default, it is set to $0.7$ for cycle with more than $4$ faces and $0.5$ for cycle with $4$ or $3$ faces. ] Any styling argument of the cetz `arc` function can be used. #example(``` #skeletize({ cycle(6, arc:(:), { single() single() single() single() single() single() }) }) ```) #example(``` #skeletize({ cycle(5, arc:(start: 30deg, end: 330deg), { single() single() single() single() single() }) }) ```) #example(``` #skeletize({ cycle(4, arc:(start: 0deg, delta: 270deg, stroke: (paint: black, dash: "dashed")), { single() single() single() single() }) }) ```) == Custom links Using the #cmd[build-link] function, you can create your own links. The function passed as argument to #cmd[build-link] must takes three arguments: - The length of the link - The cetz context of the drawing environment - A dictionary of named arguments that can be used to configure the links You can then draw anything you want using the cetz functions. For instance, here is the code for the `single` link: ```typ #let single = build-link((length, _, args) => { import cetz.draw: * line((0, 0), (length, 0), stroke: args.at("stroke", default: black)) }) ``` == Integration with cetz <exemple-cez> === Molecules If you name your molecules with the `name` argument, you can use them in cetz code. The name of the molecule is the name of the cetz object. Accessing to atoms is done by using the anchors numbered by the index of the atom in the molecule. #example( side-by-side: false, ``` #skeletize({ import cetz.draw: * molecule("ABCD", name: "A") single() molecule("EFGH", name: "B") line( "A.0.south", (rel: (0, -0.5)), (to: "B.0.south", rel: (0, -0.5)), "B.0.south", stroke: red, mark: (end: ">"), ) for i in range(0, 4) { content((-2 + i, 2), $#i$, name: "label-" + str(i)) line( (name: "label-" + str(i), anchor: "south"), (name: "A", anchor: (str(i), "north")), mark: (end: "<>"), ) } }) ```, ) === Links If you name your links with the `name` argument, you can use them in cetz code. The name of the link is the name of the cetz object. It exposes the same anchors as the `line` function of cetz. #example( side-by-side: false, ``` #skeletize({ import cetz.draw: * double(absolute: 30deg, name: "l1") single(absolute: -30deg, name: "l2") molecule("X", name: "X") hobby( "l1.50%", ("l1.start", 0.5, 90deg, "l1.end"), "l1.start", stroke: (paint: red, dash: "dashed"), mark: (end: ">"), ) hobby( (to: "X.north", rel: (0, 1pt)), ("l2.end", 0.4, -90deg, "l2.start"), "l2.50%", mark: (end: ">"), ) }) ```, ) Here, all the used coordinates for the arrows are computed using relative coordinates. It means that if you change the position of the links, the arrows will be placed accordingly without any modification. #grid( columns: (1fr, 1fr, 1fr), align: horizon + center, skeletize({ import cetz.draw: * double(absolute: 45deg, name: "l1") single(absolute: -80deg, name: "l2") molecule("X", name: "X") hobby( "l1.50%", ("l1.start", 0.5, 90deg, "l1.end"), "l1.start", stroke: (paint: red, dash: "dashed"), mark: (end: ">"), ) hobby( (to: "X.north", rel: (0, 1pt)), ("l2.end", 0.4, -90deg, "l2.start"), "l2.50%", mark: (end: ">"), ) }), skeletize({ import cetz.draw: * double(absolute: 30deg, name: "l1") single(absolute: 30deg, name: "l2") molecule("X", name: "X") hobby( "l1.50%", ("l1.start", 0.5, 90deg, "l1.end"), "l1.start", stroke: (paint: red, dash: "dashed"), mark: (end: ">"), ) hobby( (to: "X.north", rel: (0, 1pt)), ("l2.end", 0.4, -90deg, "l2.start"), "l2.50%", mark: (end: ">"), ) }), skeletize({ import cetz.draw: * double(absolute: 90deg, name: "l1") single(absolute: 0deg, name: "l2") molecule("X", name: "X") hobby( "l1.50%", ("l1.start", 0.5, 90deg, "l1.end"), "l1.start", stroke: (paint: red, dash: "dashed"), mark: (end: ">"), ) hobby( (to: "X.north", rel: (0, 1pt)), ("l2.end", 0.4, -90deg, "l2.start"), "l2.50%", mark: (end: ">"), ) }), ) === Cycles centers The cycles centers can be accessed using the name of the cycle. If you name a cycle, an anchor will be placed at the center of the cycle. If the cycle is incomplete, the missing vertex will be approximated based on the last link and the `atom-sep` value. This will in most cases place the center correctly. #example(side-by-side: false, ``` #skeletize({ import cetz.draw: * molecule("A") cycle( 5, name: "cycle", { single() molecule("B") single() molecule("C") single() molecule("D") single() molecule("E") single() }, ) content( (to: "cycle", rel: (angle: 30deg, radius: 2)), "Center", name: "label", ) line( "cycle", (to: "label.west", rel: (-1pt, -.5em)), (to: "label.east", rel: (1pt, -.5em)), stroke: red, ) circle( "cycle", radius: .1em, fill: red, stroke: red, ) }) ```) #example(``` #skeletize({ import cetz.draw: * cycle(5, name: "c1", { single() single() single() branch({ single() cycle(3, name: "c2", { single() single() single() }) }) single() single() }) hobby( "c1", ("c1", 0.5, -60deg, "c2"), "c2", stroke: red, mark: (end: ">"), ) }) ```) #pagebreak() === Multiple molecules Alchemist allows you to draw multiple molecules in the same cetz environment. This is useful when you want to draw things like reactions. #example(side-by-side: false, ``` #cetz.canvas({ import cetz.draw: * draw-skeleton(name: "mol1", { cycle(6, { single() double() single() double() single() double() }) }) line((to: "mol1.east", rel: (1em, 0)), (rel: (1, 0)), mark: (end: ">")) set-origin((rel: (1em, 0))) draw-skeleton(name: "mol2", mol-anchor: "west", { molecule("X") double(angle: 1) molecule("Y") }) line((to: "mol2.east", rel: (1em, 0)), (rel: (1, 0)), mark: (end: ">")) set-origin((rel: (1em, 0))) draw-skeleton(name: "mol3", { molecule("S") cram-filled-right() molecule("T") }) }) ```) == Examples The following examples are the same ones as in the Chemfig documentation. They are here for two purposes: To show you how to draw the same structures with Alchemist and to show you how to use the package. === Ethanol #example(``` #skeletize({ molecule("H") single() molecule("C") branch({ single(angle:2) molecule("H") }) branch({ single(angle:-2) molecule("H") }) single() molecule("C") branch({ single(angle:-1) molecule("H") }) branch({ double(angle:1) molecule("O") }) }) ```) #pagebreak() === 2-Amino-4-oxohexanoic acid #example(``` #skeletize( config: (angle-increment: 30deg), { single(angle:1) single(angle:-1) branch({ double(angle:-3) molecule("O") }) single(angle:1) single(angle:-1) branch({ single(angle:-3) molecule("NH_2") }) single(angle:1) branch({ double(angle:3) molecule("O") }) single(angle:-1) molecule("OH") }) ```) #pagebreak() === Glucose #example(side-by-side: false,``` #skeletize( config: (angle-increment: 30deg), { molecule("HO") single(angle:-1) single(angle:1) branch({ cram-filled-left(angle: 3) molecule("OH") }) single(angle:-1) branch({ cram-dashed-left(angle: -3) molecule("OH") }) single(angle:1) branch({ cram-dashed-left(angle: 3) molecule("OH") }) single(angle:-1) branch({ cram-dashed-left(angle: -3) molecule("OH") }) single(angle:1) branch({ double(angle: 3) molecule("O") }) single(angle:-1) molecule("H") }) ```) #pagebreak() === Fisher projection #example(``` #let fish-left = { single() branch({ single(angle:4) molecule("H") }) branch({ single(angle:0) molecule("OH") }) } #let fish-right = { single() branch({ single(angle:4) molecule("OH") }) branch({ single(angle:0) molecule("H") }) } #skeletize( config: (base-angle: 90deg), { molecule("OH") single(angle:3) fish-right fish-right fish-left fish-right single() double(angle: 1) molecule("O") }) ```) #pagebreak() === $alpha$-D-glucose #example(``` #skeletize({ hook("start") branch({ single(absolute: 190deg) molecule("OH") }) single(absolute: -50deg) branch({ single(absolute: 170deg) molecule("OH") }) single(absolute: 10deg) branch({ single( absolute: -55deg, atom-sep: 0.7 ) molecule("OH") }) single(absolute: -10deg) branch({ single(angle: -2, atom-sep: 0.7) molecule("OH") }) single(absolute: 130deg) molecule("O") single(absolute: 190deg, links: ("start": single())) branch({ single( absolute: 150deg, atom-sep: 0.7 ) single(angle: 2, atom-sep: 0.7) molecule("OH") }) }) ```) #pagebreak() === Adrenaline #example(``` #skeletize({ cycle(6, { branch({ single() molecule("HO") }) single() double() cycle(6,{ single(stroke:transparent) single( stroke:transparent, to: 1 ) molecule("HN") branch({ single(angle:-1) molecule("CH_3") }) single(from:1) single() branch({ cram-filled-left(angle: 2) molecule("OH") }) single() }) single() double() single() branch({ single() molecule("HO") }) double() }) }) ```) #pagebreak() === Guanine #example(``` #skeletize({ cycle(6, { branch({ single() molecule("H_2N") }) double() molecule("N") single() cycle(6, { single() molecule("NH", vertical: true) single() double() molecule("N", links: ( "N-horizon": single() )) }) single() hook("N-horizon") single() single() molecule("NH") single(from: 1) }) }) ```)
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-A900.typ
typst
Apache License 2.0
#let data = ( ("KAYAH LI DIGIT ZERO", "Nd", 0), ("KAYAH LI DIGIT ONE", "Nd", 0), ("KAYAH LI DIGIT TWO", "Nd", 0), ("KAYAH LI DIGIT THREE", "Nd", 0), ("KAYAH LI DIGIT FOUR", "Nd", 0), ("KAYAH LI DIGIT FIVE", "Nd", 0), ("KAYAH LI DIGIT SIX", "Nd", 0), ("KAYAH LI DIGIT SEVEN", "Nd", 0), ("KAYAH LI DIGIT EIGHT", "Nd", 0), ("KAYAH LI DIGIT NINE", "Nd", 0), ("KAYAH LI LETTER KA", "Lo", 0), ("KAYAH LI LETTER KHA", "Lo", 0), ("KAYAH LI LETTER GA", "Lo", 0), ("KAYAH LI LETTER NGA", "Lo", 0), ("KAYAH LI LETTER SA", "Lo", 0), ("KAYAH LI LETTER SHA", "Lo", 0), ("KAYAH LI LETTER ZA", "Lo", 0), ("KAYAH LI LETTER NYA", "Lo", 0), ("KAYAH LI LETTER TA", "Lo", 0), ("KAYAH LI LETTER HTA", "Lo", 0), ("KAYAH LI LETTER NA", "Lo", 0), ("KAYAH LI LETTER PA", "Lo", 0), ("KAYAH LI LETTER PHA", "Lo", 0), ("KAYAH LI LETTER MA", "Lo", 0), ("KAYAH LI LETTER DA", "Lo", 0), ("KAYAH LI LETTER BA", "Lo", 0), ("KAYAH LI LETTER RA", "Lo", 0), ("KAYAH LI LETTER YA", "Lo", 0), ("KAYAH LI LETTER LA", "Lo", 0), ("KAYAH LI LETTER WA", "Lo", 0), ("KAYAH LI LETTER THA", "Lo", 0), ("KAYAH LI LETTER HA", "Lo", 0), ("KAYAH LI LETTER VA", "Lo", 0), ("KAYAH LI LETTER CA", "Lo", 0), ("KAYAH LI LETTER A", "Lo", 0), ("KAYAH LI LETTER OE", "Lo", 0), ("KAYAH LI LETTER I", "Lo", 0), ("KAYAH LI LETTER OO", "Lo", 0), ("KAYAH LI VOWEL UE", "Mn", 0), ("KAYAH LI VOWEL E", "Mn", 0), ("KAYAH LI VOWEL U", "Mn", 0), ("KAYAH LI VOWEL EE", "Mn", 0), ("KAYAH LI VOWEL O", "Mn", 0), ("KAYAH LI TONE PLOPHU", "Mn", 220), ("KAYAH LI TONE CALYA", "Mn", 220), ("KAYAH LI TONE CALYA PLOPHU", "Mn", 220), ("KAYAH LI SIGN CWI", "Po", 0), ("KAYAH LI SIGN SHYA", "Po", 0), )
https://github.com/Servostar/dhbw-abb-typst-template
https://raw.githubusercontent.com/Servostar/dhbw-abb-typst-template/main/src/pages/preface.typ
typst
MIT License
// .--------------------------------------------------------------------------. // | Preface | // '--------------------------------------------------------------------------' // Author: <NAME> // Edited: 28.06.2024 // License: MIT #let new-preface(config) = { if config.thesis.preface != none { pagebreak(weak: true) config.thesis.preface } }
https://github.com/jgm/typst-hs
https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compute/foundations-19.typ
typst
Other
// Error: 7-30 cannot access file system from here #eval("image(\"/tiger.jpg\")")
https://github.com/SWATEngineering/Docs
https://raw.githubusercontent.com/SWATEngineering/Docs/main/src/3_PB/PianoDiProgetto/sections/ConsuntivoSprint/DodicesimoSprint.typ
typst
MIT License
#import "../../const.typ": Re_cost, Am_cost, An_cost, Ve_cost, Pr_cost, Pt_cost #import "../../functions.typ": rendicontazioneOreAPosteriori, rendicontazioneCostiAPosteriori, glossary ==== Dodicesimo consuntivo *Inizio*: Venerdì 08/03/2024 *Fine*: Giovedì 14/03/2024 #rendicontazioneOreAPosteriori(sprintNumber: "12") #rendicontazioneCostiAPosteriori(sprintNumber: "12") ===== Analisi a posteriori Nella retrospettiva è stato evidenziato il rispetto del totale delle ore preventivate per questo #glossary[sprint], con una differenza di soli 30 minuti tra il preventivo e il consuntivo, il che costituisce un tasso di errore dell'1% circa. È notevole come il team sia riuscito a gestire senza particolari intoppi un regime sostenuto di circa 60 ore produttive settimanali, dimostrando così impegno e coerenza nel rispettare le scadenze prefissate per arrivare il prima possibile alla seconda revisione #glossary[PB]. Nel consuntivo emerge che sono state consumate più ore da Amministratore rispetto a quanto preventivato, principalmente a causa della necessità di creare alcuni script per automatizzare l'ambiente di lavoro in merito al calcolo delle metriche della qualità del prodotto, richiedendo uno sforzo aggiuntivo. Per quanto riguarda l'attività di codifica, si può affermare che, con l'ultima implementazione dei sensori urbanistici rimanenti, la parte del prodotto software relativa alla simulazione dei dati potrebbe essere considerata conclusa. Questo traguardo è stato raggiunto in breve tempo grazie ad una buona distribuzione del lavoro a carico dei Programmatori; infatti, ciascun membro del team si è dedicato allo sviluppo di uno o due simulatori diversi nel corso degli ultimi due #glossary[sprint] e, in tal modo, il team è riuscito a realizzare gli 11 sensori previsti dall'_Analisi dei Requisiti_ e a coniugarli con la nuova #glossary[architettura]. Per quanto riguarda le ore impiegate dai Verificatori, queste sono state inferiori a quanto preventivato poiché il team si è concentrato prevalentemente sull'attività di codifica, dedicando relativamente meno tempo alla #glossary[documentazione]\; infatti, il team ha ritenuto opportuno attendere che il prodotto software fosse sviluppato quasi nella sua interezza per applicare eventuali modifiche migliorative alla _Specifica Tecnica_ e proseguire con la stesura del _Manuale Utente_. ===== Aggiornamento della pianificazione e gestione dei rischi Durante lo #glossary[sprint] attuale, l'unico rischio che si è manifestato è stato il rischio RT1 - Conoscenze tecnologiche limitate. Il team ha incontrato delle difficoltà nel definire il metodo ottimale per condurre i test del prodotto e selezionare i software pertinenti. Nonostante il rischio sia stato parzialmente mitigato attraverso un incontro con la Proponente, dove si è discusso anche delle strategie da attuare per la parte di testing, non tutte le domande hanno ricevuto una risposta esaustiva e ciò ha contribuito a rallentare il processo decisionale. I componenti del team tenteranno di implementare i primi test di unità e di integrazione con le conoscenze attualmente in loro possesso e chiederanno un altro riscontro da parte della Proponente nell'arco di una settimana.
https://github.com/ayoubelmhamdi/typst-phd-AI-Medical
https://raw.githubusercontent.com/ayoubelmhamdi/typst-phd-AI-Medical/master/README.md
markdown
MIT License
# Typst PFE A PFE en FR using [typst.app](https://typst.app). ## Showcases ### PDF [pfe.pdf](https://github.com/ayoubelmhamdi/typst-phd-AI-Medical/raw/master/build/main.pdf) ### COVER ![Preview](images/main.jpg)
https://github.com/sysu/better-thesis
https://raw.githubusercontent.com/sysu/better-thesis/main/README.md
markdown
MIT License
# 基于 Typst 的中山大学学位论文模板 [![GitLab 最新版本](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/badges/release.svg?style=flat-square)](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/releases/permalink/latest) [![GitHub stars](https://img.shields.io/github/stars/sysu/better-thesis.svg?style=social&label=Star&maxAge=2592000)](https://github.com/sysu/better-thesis) **[点击此处注册 typst.app 并创建你的论文工程](https://typst.app/app?template=modern-sysu-thesis&version=0.1.1)** 本科生模板已经符合学位论文格式要求([#6](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues/6)),欢迎同学/校友们[贡献代码](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/merge_requests)/反馈问题([GitLab issue](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues)/[邮件](mailto:<EMAIL>))! 模板交流 QQ 群:[797942860](https://jq.qq.com/?_wv=1027&k=m58va1kd) ## 参考规范 - 本科生论文模板参考 [中山大学本科生毕业论文(设计)写作与印制规范 2020年发](https://spa.sysu.edu.cn/zh-hans/article/1744) - 研究生论文模板参考 [中山大学研究生学位论文格式要求](https://graduate.sysu.edu.cn/sites/graduate.prod.dpcms4.sysu.edu.cn/files/2019-04/%E4%B8%AD%E5%B1%B1%E5%A4%A7%E5%AD%A6%E7%A0%94%E7%A9%B6%E7%94%9F%E5%AD%A6%E4%BD%8D%E8%AE%BA%E6%96%87%E6%A0%BC%E5%BC%8F%E8%A6%81%E6%B1%82.pdf) ## 使用方法 ### typst.app 经过近一月紧张的迭代重构,本模板已经[发布在typst-app.universe](https://typst.app/universe/package/modern-sysu-thesis)上,[点击此处直接创建你的论文工程](https://typst.app/app?template=modern-sysu-thesis&version=0.2.0),并直接开始编写你的论文! <!-- TODO(#1): 在 typst.universe 版本上线后分离模板项目 --> ### Windows 用户 1. [下载本仓库](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/archive/main/better-thesis-main.zip),或者使用 `git clone https://gitlab.com/sysu-gitlab/thesis-template/better-thesis` 命令克隆本仓库。 2. 右键 `install_typst.ps1` 文件,选择“用 Powershell 运行”,等待 Typst 安装完成。 3. 根据 [Typst 文档](https://typst.app/docs/),参考 [项目结构](#项目结构) 中的说明,按照你的需要修改论文的各个部分。 4. 双击运行 `compile.bat`,即可生成 `thesis.pdf` 文件。 ### Linux/macOS 用户 1. [下载本仓库](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/archive/main/better-thesis-main.zip),或者使用 `git clone https://gitlab.com/sysu-gitlab/thesis-template/better-thesis` 命令克隆本仓库。 2. 使用命令行安装 Rust 工具链以及 Typst: ```bash # 安装 Rust 环境并激活,之前安装过则不需要执行下面这两行 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source $HOME/.cargo/env # 安装 Typst CLI cargo install typst-cli # 访问缓慢的话,执行以下命令设置清华镜像源,并从镜像站安装 cat << EOF > $HOME/.cargo/config [source.crates-io] replace-with = "tuna" [source.tuna] registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git" EOF cargo install typst-cli ``` 3. 根据 [Typst 文档](https://typst.app/docs/),参考 [项目结构](#项目结构) 中的说明,按照你的需要修改论文的各个部分。 4. 执行 `make` 命令,即可生成 `thesis.pdf` 文件。 ## 项目结构 详见 `template\thesis.typ` ## FAQ ### 为什么 XXX 的功能不能用/不符合预期? 1. 先参考 [Typst 中文支持相关问题](https://typst-doc-cn.github.io/docs/chinese/),以及 [Typst 官方文档](https://typst.app/docs/) 与 [tpyst.app/universe 仓库](https://typst.app/universe),了解相关问题进展或解决方案 2. 如果在以上资料中找不到关联资料,可以参考是否在的 [issue 列表](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues) 中能找到相关问题与进展。 3. 如果依然没有线索,欢迎反馈问题([GitLab issue](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues)/[邮件](mailto:contact-project+sysu-gitlab-thesis-template-better-thesis-5782<EMAIL>)) ### 为什么学校学位论文已经有了 [LaTeX 模板](https://github.com/SYSU-SCC/sysu-thesis),还有 Typst 模板? - 前述 LaTeX 模板目前仅有计算机学院官方指定使用,其他学院并没有统一指定 - 考虑到 LaTeX 对于大部分非计算机/理工科的学生入门成本比较高,因此有必要提供一种更加简洁清晰并且方便的论文模板,包括: - 开箱即用: - 如[前文所述](#typstapp),本模板提供了在线直接编辑/保存/备份方案 - 本地使用模板时,模板组件可以简单地通过 `typst` 命令自动管理安装 - 语法简洁:typst 是与 markdown 类似的标记性语言,可以通过标记的方式来轻松控制语法(如`= 标题`、`*粗体*`、`_斜体_` `@引用`、 数学公式`$E = m c^2$`) ### 为什么有两份 Typst 模板([sysu-thesis-typst] 和 modern-sysu-thesis)? 后者是在前者的基础上,同时参考 [modern-nju-thesis] ,改造后适配了 [typst.app/universe](https://typst.app/universe)。以及,放到 [@sysu](https://github.com/sysu) 组织下提高了曝光度。 ## 致谢 - 感谢 [sysu-thesis-typst] 提供了中山大学的页面样式与初版源码 - 感谢 [modern-nju-thesis] 提供了一个更好的代码组织架构 - 感谢中山大学 Typst 模板交流群([797942860](https://jq.qq.com/?_wv=1027&k=m58va1kd))、Typst 中文交流群(793548390)群友的帮助交流。 [sysu-thesis-typst]: https://github.com/howardlau1999/sysu-thesis-typst [modern-nju-thesis]: https://typst.app/universe/package/modern-nju-thesis
https://github.com/polarkac/MTG-Stories
https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/001%20-%20Magic%202013/008_The%20Stonekiller%2C%20Part%202.typ
typst
#import "@local/mtgstory:0.2.0": conf #show: doc => conf( "The Stonekiller, Part 2", set_name: "Magic 2013", story_date: datetime(day: 15, month: 08, year: 2012), author: "<NAME>", doc ) Lia bit the hand that pulled the bag off her head. Something yelped, but didn't strike her. Instead it set her gently on the ground and backed away. "I'm Nira," it said softly. "And I'm sorry we had to meet this way." #figure(image("008_The Stonekiller, Part 2/01.jpg", width: 100%), caption: [], supplement: none, numbering: none) Lia stared up at a cat-like person and decided it was a girl. Three more of cat-people stood warily by, as if they felt threatened by the tiny girl glowering at them. Boys, she decided. They had manes. "I want to go home!" Lia shouted, startling all of them. "Have you ever seen the ruins on the mountainside?" Nira asked. Her golden fur was decorated with black spots. Blue-stone jewelry dangled from her pointed ears. And the whiskers around her pink nose quivered even when she wasn't talking. "What are you?" Lia demanded, looking around. They appeared to be inside a cave. Torches hung on the wall, and blankets had been laid out over the red-dirt floor. "Haven't you seen a nacatl before?" Nira seemed surprised. "We're Sunstrikers. Our pride is loyal to the great teacher, Ajani. It's our sworn duty to keep his lands safe." #figure(image("008_The Stonekiller, Part 2/02.jpg", width: 100%), caption: [], supplement: none, numbering: none) "These aren't his lands," Lia said petulantly. "The demon that lives in the ruins is a threat to us all, no matter where we call home," Nira replied. "Please?" Lia said. "#emph[I ] want to go home." The Sunstriker looked over her shoulder, as if hoping her companions could make this easier. They said nothing. "The demon is harvesting the bones of creatures for a ritual. . ." "Ritual?" Lia asked in confusion. "He's killing countless creatures just to give himself more power," Nira explained. "We've been hunting him for a long time. Many of our pride have died, including most of our mages. He's taken your village, which I didn't expect to happen so quickly." "Taken them where?" Lia wondered if the demon had the green-eyed girl, and then felt guilty for thinking it. "To the ruins here in the mountains," Nira told her. "If you don't help us, they will die. I wish you didn't have to hear that, but it's the truth." #figure(image("008_The Stonekiller, Part 2/03.jpg", width: 100%), caption: [], supplement: none, numbering: none) Lia thought of her father and how tall he was. She couldn't imagine anything that could hurt him. "Let's go see my father. And my mother is a mage. She helps people all the time." The Sunstriker looked sad. "You must help #emph[her] . Your family is at the ruins, too." Lia hugged her knees and wondered why she didn't feel anything. This all seemed like part of a bedtime story. A cat that could talk. A demon in the mountains. Surely Nira was wrong. Her family was safe in the cottage, waiting for her. "We must attack before the demon completes the ritual," Nira said. "For my plan to work, we need a stonekiller, and ours have all been killed." "What's a stonekiller?" Lia asked. "You are," she replied. "I watched you by the river. You'll be a powerful mage one day." "Breaking pebbles isn't very useful," Lia said doubtfully. "Today, you break pebbles. Tomorrow, you will smash walls. Someday, castles might crumble in your passing." Lia stared at her with awe. #emph[Lia galloped by on her white horse, and Eos Castle tumbled to the ground.] Nira unsheathed her sword. With the tip of the blade, she hurriedly drew in the red dirt. Lia watched her curiously. #figure(image("008_The Stonekiller, Part 2/04.jpg", width: 100%), caption: [], supplement: none, numbering: none) "Like you, a dragon has a spine," Nira told her. "But unlike you, some dragons have a large plate that connects to every rib. It's also where the wings attach. We call it the keystone." "Keystone?" Lia asked. "Keystone means something important," Nira said. "If you destroy this plate, the skeleton will fall. And then the ritual can't be finished." "You want me to kill a dragon?" Lia whispered. She didn't want Nira to think she was weak, but she didn't want to disappoint her either. Instead of answering, Nira sheathed her sword and took Lia's tiny hands in her own. "Can you climb?" she asked gently, inspecting Lia's curled fingers. "Better than the other children," she promised. "What is your name?" Nira asked. "Lia," she said. "Among my people, a warrior receives a new name before her first battle," Nira said. "May I give you yours?" Lia nodded. She couldn't believe what she was hearing. Her, a warrior? "In my language, #emph[kaa] means 'power,' Nira said. "You are now the warrior, Kaa-lia. You will kill the keystone. And you will bring your family home." #figure(image("008_The Stonekiller, Part 2/05.jpg", width: 100%), caption: [], supplement: none, numbering: none) #figure(image("008_The Stonekiller, Part 2/06.png", height: 40%), caption: [], supplement: none, numbering: none) Just before sunset, Kaalia lay beneath a dead tree on the ridge overlooking the arena. Except for Nira, the ragged band of Sunstrikers had already disappeared into the trees. They would circle around and launch their assault from a different direction. Kaalia stared down at the frenzied scene in the valley. She tried to rehearse Nira's instructions, but her thoughts felt like they were moving too fast. #emph[The pointless slaughter of innocents must stop.] The hellkite's skeleton was like a horrible house. #emph[Kill the keystone, destroy the skeleton.] The dangling bones swayed in the breeze and made hollow, rattling music. #emph[Destroy the skeleton, stop the demon.] Kaalia whimpered, but Nira didn't move. She was watching the scene below intently. #emph[Stop the demon, bring your family home.] As the sun disappeared behind the dark mountaintops, a line of black-clad people shuffled silently into the arena. Strips of black cloth crisscrossed around their throats. Kaalia didn't see her family, or anyone from the village either. #figure(image("008_The Stonekiller, Part 2/07.jpg", width: 100%), caption: [], supplement: none, numbering: none) "Those are his servants," Nira whispered. "They want to be here?" Kaalia was horrified. She could smell a horrible stench coming from the ruins. How could anyone #emph[want] to be there? "They might be controlled somehow," Nira said, as a flash of red light blinked from the ridge across the valley. "That's our signal," Nira whispered. She grasped Kaalia's hand, and the two scurried down the overgrown slope, through a gap in the crumbling wall, and crouched behind one of the massive ribs. They were only a few feet from the main floor, and Kaalia realized her teeth were chattering with fear. She clenched her jaw as the servants formed a circle around the hanging bones. Kneeling, they held out their hands with palms open to the night sky. An emaciated bald man wrapped in tattered furs strode to a platform on the northern end. He was grinning, but it was a toothless, wicked smile that made Kaalia shudder. During an earlier reconnaissance mission, Nira had discovered pockmarks along the outside curve of the rib that would allow them to climb it and stay out of view of the floor. But just as Kaalia put her foot on the first notch, the ground bucked violently. The servants shrieked with glee, and the sound of their laughter made Kaalia feel sick with fear. "Let's go," Nira urged. "We have to hurry." As Kaalia climbed, the rough surface scratched her hands. The servant's chants grew louder and more demanding. A thunderous boom shook the earth, and the servants shrieked in pain. Their palms had simultaneously split open. Droplets of blood began to cascade upward into the sky. Kaalia looked down at Nira in horror. #emph[Skin couldn't rip open on its own. Blood didn't rain up] . #figure(image("008_The Stonekiller, Part 2/08.jpg", width: 100%), caption: [], supplement: none, numbering: none) "If you destroy the keystone, the bones will fall," Nira encouraged her. "All this madness will end." At top of the rib, Nira leaped onto the spine first and helped Kaalia up. A strong wind seemed to rush in from all sides, and the bones swayed precariously under their feet. At Nira's direction, they flattened themselves on the walkway as sickly fumes began to rise from below. The bones were sharp against Kaalia'a belly as she inched toward the keystone. Out of the corner of her eye, she saw the other Sunstrikers fighting through a mob of armed men to attack the bald man on the platform. In his haste to escape the Sunstrikers, the bald man scampered up a ladder up to the walkway. At the top, he caught sight of them and howled with rage. Nira leapt to her feet. Nira drew her sword. "Do it now!"" she ordered Kaalia. Kaalia crouched in front of the keystone. Her feet kept slipping between the gaps in the spine. #emph[I'm going to fall.] Just inches below her, the hanging bones undulated with magic she couldn't comprehend, fusing together and then falling apart. It was hypnotizing. Kaalia didn't want to look away. #emph[If I look away, I'll fall.] #figure(image("008_The Stonekiller, Part 2/09.jpg", width: 100%), caption: [], supplement: none, numbering: none) "Kaalia!" Nira shouted. She pounced at the bald man, but he dodged her strike and countered. Nira raised her sword to block, but the force of his blow almost knocked her off the walkway. For a leathery scrap of a man, he was unnaturally strong. Kaalia tore her eyes away from the mass of bones below her. But she felt jittery, terrified. How could she make her mind calm, like it needed to be when she broke pebbles? "Shut out the world!" Nira screamed. "Pretend you're somewhere else!" Kaalia pressed her hand against the smooth keystone, closed her eyes, and wished she were by the river again. #emph[Bant had been a vast realm. A beautiful land of floating castles, seas of grass, and the bluest skies you can imagine. ] Under her fingers, the keystone grew warm. #emph[It was a crisp autumn day when Eos Castle was besieged by horrible creatures.] Kaalia imagined the sparkling river rushing by her bare toes. #emph[They broke through the wall!] There was rippling sound, and then her fingers felt only emptiness. #emph[Lia galloped by on her white horse, and Eos Castle tumbled to the ground.] When Kaalia opened her eyes, the keystone was gone and a gaping hole nearly bisected the spine. Triumphantly, she called out to Nira, but rough hands yanked her off the walkway. The bald man was shaking her and screaming in her face. Behind him, Nira was struggling to her feet. Blood matted the fur on the Sunstriker's head. "You rat!" the man screamed. "You're the final number! Your blood will light the fuse!" And he threw her off the side. With cat-like grace, Nira leapt after her. In mid-air, she encircled Kaalia in her arms and they fell together. Just before they landed, Nira twisted her body so she cushioned Kaalia's fall. Above, there was a loud crack as the spine snapped. The bald man hung on for a moment before the hellkite's ribcage split in half and crashed down. His body slammed against the floor with a sickening thud. Bones clattered to the ground, raining down on Kaalia as she desperately tried to tend to Nira. Kaalia's vision spun dangerously. "Nira!" Kaalia sobbed. "We stopped it! The skeleton fell to pieces." "Well done, little warrior," Nira whispered. "Now flee from here. The rest of us are lost." A blast of energy radiated out of the ground, which split open and left a jagged scar across the arena. Bones and bodies flew like feathers in the wind. Kaalia slammed against the arena wall, frantically shielding her face from the debris that tumbled around her. #emph[He ] arose from the rift that now cut across the floor. His wings cracked and snapped as he ascended slowly into the night sky. #figure(image("008_The Stonekiller, Part 2/10.jpg", width: 100%), caption: [], supplement: none, numbering: none) It was as if the entire world has narrowed to a single point—him. He whipped his blade through the air, and the screams of the dying echoed through the valley. Fighting for consciousness, Kaalia glimpsed an image of the Sunstriker's face swirling in the smoke above her, and then the world went black. When Kaalia awoke, a weak sun was rising in the east, casting a white pall over the devastation around her. Nothing moved amid the wreckage. There were no sounds except the distant hum of locusts. The bodies scattered among the wreckage were charred beyond recognition. Across the valley, half of the ridge was gone, with just a smoking crater in its place. The demon had escaped. She knelt beside the last place Nira had laid. Kaalia felt empty. Like her insides had been ripped out, and there was just shadows left instead. #emph[I'll kill the demon. I don't know how yet, but I'll find a way to make him suffer. ] Out in the vast wilderness, that is where she would find her revenge. #figure(image("008_The Stonekiller, Part 2/11.jpg", width: 100%), caption: [], supplement: none, numbering: none)
https://github.com/loqusion/typix
https://raw.githubusercontent.com/loqusion/typix/main/docs/api/derivations.md
markdown
MIT License
# Derivations As paraphrased from [the Nix Reference Manual][nix-ref-derivations]: > A derivation is a specification for running an executable on precisely defined > input files to repeatably produce output files at uniquely determined file > system paths. The derivation constructors defined in Typix extend this behavior by running `typst compile`/`typst watch` in a context where all the dependencies of your Typst project (fonts, images, etc.) will be made available to the Typst compiler, regardless of if they're already present on the system it runs on. - [`buildTypstProjectLocal`](derivations/build-typst-project-local.md) — Returns a derivation for compiling a Typst project and copying the output to the current directory. - [`buildTypstProject`](derivations/build-typst-project.md) — Returns a derivation for compiling a Typst project. - [`devShell`](derivations/dev-shell.md) — Sets up a shell environment that activates with [`nix develop`][nix-ref-develop] or [`direnv`][direnv]. - [`mkTypstDerivation`](derivations/mk-typst-derivation.md) — A generic derivation constructor for running Typst commands. - [`watchTypstDerivation`](derivations/watch-typst-project.md) — Returns a derivation for a script that watches an input file and recompiles on changes. [direnv]: https://direnv.net/ [nix-ref-derivations]: https://nixos.org/manual/nix/stable/language/derivations.html [nix-ref-develop]: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop
https://github.com/Myriad-Dreamin/typst.ts
https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/math/spacing_00.typ
typst
Apache License 2.0
#import "/contrib/templates/std-tests/preset.typ": * #show: test-page // Test spacing cases. $ä, +, c, (, )$ \ $=), (+), {times}$ \ $⟧<⟦, abs(-), [=$ \ $a=b, a==b$ \ $-a, +a$ \ $a not b$ \ $a+b, a*b$ \ $sum x, sum(x)$ \ $sum product x$ \ $f(x), zeta(x), "frac"(x)$ \ $a+dots.c+b$ $f(x) sin(y)$
https://github.com/Bit-Part-Young/report-template-MMMS-typst
https://raw.githubusercontent.com/Bit-Part-Young/report-template-MMMS-typst/main/main.typ
typst
#import "template.typ": * #show: ReportTemplate.with( ClassName: "多尺度材料模拟与计算", ReportName: "一维周期性原子链", Name: "张三", StudentID: "<KEY>", School: "材料科学与工程学院", ) // 正文内容 = 实验目的 这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。 这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。这里是实验目的。 = 实验原理 这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。 这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。这里是实验方法。 无编号公式: 有编号公式,如公式 参考文献引用@ZHU2023119062 = 实验内容 == 实验内容1 这里是实验内容1。这里是实验内容1。这里是实验内容1。这里是实验内容1。这里是实验内容1。 这里是实验内容1。这里是实验内容1。这里是实验内容1。这里是实验内容1。这里是实验内容1。 == 实验内容2 这里是实验内容2。这里是实验内容2。这里是实验内容2。这里是实验内容2。这里是实验内容2。 这里是实验内容2。这里是实验内容2。这里是实验内容2。这里是实验内容2。这里是实验内容2。 = 结果与讨论 == 结果 这里是结果。这里是结果。这里是结果。这里是结果。这里是结果。 这里是结果。这里是结果。这里是结果。这里是结果。这里是结果。 == 讨论 这里是讨论。这里是讨论。这里是讨论。这里是讨论。这里是讨论。 这里是讨论。这里是讨论。这里是讨论。这里是讨论。这里是讨论。 = 结论 这里是结论。这里是结论。这里是结论。这里是结论。这里是结论。 这里是结论。这里是结论。这里是结论。这里是结论。这里是结论。 // 参考文献 #{ pagebreak() bibliography( "refs.bib", title: "参考文献", style: "american-physics-society", // style: "gb-7714-2015-numeric", // style: "nature", ) } #pagebreak(weak: true) #set heading(numbering: none) #counter(heading).update(0) // #set heading(level: 2, numbering: "A") = 附录A #show: codly-init.with() #codly( languages: ( python: (name: "Python", icon: icon("assets/brand-python.svg"), color: rgb("#CE412B")), rust: (name: "Rust", icon: icon("assets/brand-rust.svg"), color: rgb("#3572A5")), cpp: (name: "C++", icon: icon("assets/brand-cpp.svg"), color: rgb("#3572A5")), ) ) == Python代码 Python源代码: ```python def main(): pass if __name__ == "__main__": main() ``` == C++ 代码 ```cpp #include <iostream> using namespace std; float add(float a, float b) { return a + b; } ``` == Rust 代码 Rust源代码: ```rust pub fn main() { println!("Hello, world!"); } ``` #pagebreak(weak: true) = 附录B 这里是附录B。这里是附录B。这里是附录B。这里是附录B。这里是附录B。 这里是附录B。这里是附录B。这里是附录B。这里是附录B。这里是附录B。
https://github.com/kdog3682/mathematical
https://raw.githubusercontent.com/kdog3682/mathematical/main/0.1.0/src/dialogues/layouts/singleton-meta-layout.typ
typst
#import "@local/typkit:0.1.0": * #let singleton-meta-layout(meta) = { let left = context { let size = 1.5em let a = bold(meta.topic, size: size) let h = measure(a).height * 2 let b = ink.blue(bold(meta.title, size: size)) let separator = line(length: h, angle: 90deg) base-flex(spacing: 10pt, a, separator, b) } let b = pill({ let size = 0.9em align(h3(meta.class), right) v(-10pt) align(bold(meta.assignmentType, size: size), right) v(-7pt) align(ink.blue(meta.season, size: size), right) v(3pt) }, inset: 8pt) css-flex(left, b, align: "apart", columns: (auto, 1fr)) lines.soft v(15pt) }
https://github.com/vimkat/typst-ohm
https://raw.githubusercontent.com/vimkat/typst-ohm/main/src/lib/vars.typ
typst
MIT License
#let font = "Public Sans" #let red = rgb("#e52329") // cmyk(0%,95%,85%,0%) #let blue = cmyk(100%, 70%, 10%, 60%) #let yellow = cmyk(0%, 5%, 75%, 0%) #let light-blue = cmyk(25%, 0%, 5%, 0%) #let green = cmyk(60%, 10%, 80%, 0%) #let violet = cmyk(70%, 85%, 10%, 0%) #let dark-green = cmyk(80%, 10%, 80%, 25%) #let frac = 0.73465 #let frac-half = 0.49716 // The dark times #let ancient-font = "ITC Officina Sans Std" // font not included -- need to get it somewhere else #let ancient-blue = rgb("#0046a0")
https://github.com/thudep/typst-talk
https://raw.githubusercontent.com/thudep/typst-talk/master/main.typ
typst
#import "@preview/touying:0.5.2": * #import themes.university: * #import "@preview/physica:0.9.3": * #let typst-color = rgb("#239DAD") #let tsinghua-color = rgb(106,8,116) #set text(font: ("Linux Libertine", "Source Han Serif"), lang: "zh", region: "cn") #show heading.where(level: 1): set heading(numbering: "1.") #show: university-theme.with( aspect-ratio: "16-9", config-info( title: [typst: Compose reports faster], subtitle: [快速上手的报告排版教程], authors: "杨哲涵", date: datetime(year: 2024, month: 10, day: 7), institution: [清华大学工物科协], logo: none, ), config-common( handout: false ), config-colors( primary: tsinghua-color, secondary: rgb("#6908749c"), tertiary: typst-color, neutral-lightest: rgb("#ffffff"), neutral-darkest: rgb("#434343"), ), config-methods(cover: utils.semi-transparent-cover), footer-a: self => self.info.subtitle, ) #set text(weight: "medium") #show link: it => underline(text(fill: typst-color, it)) #title-slide() #set raw(lang: "typ") #show raw.where(block: true): set text(size: 0.75em) #show raw.where(block: false): set text(fill: tsinghua-color) #show raw.where(block: false): box.with( fill: luma(94.37%), inset: (x: .2em, y: 0em), outset: (x: 0em, y: .2em), radius: .2em, ) #set underline(offset: .26em) #set par(leading: 1em) #set text(size: 22pt) #let Typst = text(fill: typst-color, weight: "bold", "Typst") #let TeX = { set text(font: "New Computer Modern", weight: "regular") box(width: 1.7em, { [T] place(top, dx: 0.56em, dy: 0.22em)[E] place(top, dx: 1.1em)[X] }) } #let LaTeX = { set text(font: "New Computer Modern", weight: "regular") box(width: 2.55em, { [L] place(top, dx: 0.3em, text(size: 0.7em)[A]) place(top, dx: 0.7em)[#TeX] }) } == 目录 <touying:hidden> #align(horizon, components.adaptive-columns(outline(title: none, indent: 1em, depth: 1))) = 为什么是Typst == 排版软件应当具有的要求 #slide()[ / 可复现: - 在安装了相同软件的不同设备上,可以复现相同的排版效果。 - 可以用源代码管理工具(如Git)进行版本控制。 / 反面例子: Microsoft Word,WPS #pause / 擅长排版公式: 撰写科技文档,数学公式是必不可少的。 $ braket(x, n)=1/sqrt(n!)braket(x, (a^dagger)^n, 0)=1/sqrt(2^n n!) ((m omega)/(pi hbar))^(1/4) (sqrt((m omega)/hbar)x+sqrt(hbar/(m omega))dv(, x))^n e^(-(m omega)/(2hbar)x^2) $ / 反面例子: Microsoft Word, Microsoft PowerPoint ] #slide()[ / 标记与输出结构化: - 自动为标题,列表,图表编号,并且方便地进行索引。 - 输出结构化的目录,可以在阅读器中快速跳转。 #pause / 表现力强: 满足各种各样的排版需求: #grid(columns: 3, column-gutter: 5em, [ - 论文 - 报告 - 书籍 ], [ - 海报 - 幻灯片 - 简历 ], [ - 代码 - #link("https://github.com/thudep/award-cert-printer")[奖状] ]) / 反面例子: Microsoft Word, Microsoft PowerPoint ] #slide()[ / 格式分离: 同样的内容,通过不同的格式设置,可以呈现不同的效果。 ``` // 格式 #let typst-color = rgb("#239DAD") #let tsinghua-color = rgb(106,8,116) #show link: it => underline(text(fill: typst-color, it)) #show raw.where(block: false): set text(fill: tsinghua-color) // 内容 点击#link("https://typst.app/docs/reference/model/link/")[typst link reference]以了解`link`函数 ``` 点击#link("https://typst.app/docs/reference/model/link/")[typst link reference]以了解`link`函数。 #pause / 易于学习: 无需花费大量时间学习,即可上手。 / 正面例子: #Typst ] == Typst对比LaTeX #slide()[ / 工具链轻量: #Typst 在Arch Linux系统下打包大小为`33.35 MiB`,而texlive-basic包附加其他依赖的大小为`2587.68 MiB`。 #pause / 生态蓬勃: 勃勃生机,万物竞发。 #grid(columns: 3, column-gutter: 1em, [2019年,两个德国大学生不满#LaTeX 的迟缓,他们决定从头开始,自己使用Rust编程语言开发一套排版软件。],image("pic/laurenz-2x.jpg", width: 4em), image("pic/martin-2x.jpg", width: 4em)) 作为对比,#TeX 的版本号采用收敛到 "圆周率" 的方式命名,每更新一次,就多取一位小数(例如我的xelatex版本为`3.141592653`)。因为开发者<NAME>认为他的软件已经完美无缺(事实上确实没有多少bug),不会再有功能更新。 ] #slide()[ / 语法简洁: #Typst 的语法简洁易懂,可读性高。此外,#Typst 是图灵完备的,而#LaTeX 则是基于宏替换。 #pause / 不完善: #Typst 并非可以完全替代#LaTeX,也存在一些不便,例如我遇到过以下问题。 - 不能直接插入`pdf`格式的图片,需要手动转为`svg`格式,参见#link("https://github.com/typst/typst/issues/145")[Issue \#145] - 首行缩进存在问题,参见#link("https://github.com/typst/typst/issues/311")[Issue \#311] ] #slide()[ / 不完善: #Typst 并非可以完全替代#LaTeX,也存在一些不便,例如我遇到过以下问题。 - #strike[生成文档更大(一般是2倍以上),参见#link("https://github.com/typst/typst/discussions/404")[Why does typst generate much larger pdf than TeX? · typst/typst · Discussion #404]] 已在#link("https://typst.app/docs/changelog/0.12.0/")[0.12.0]修复 - 缺乏好用的格式化工具,参见#link("https://github.com/typst/typst/issues/1772")[Issue \#1772] - 还未实现文字环绕图片,参见#link("https://github.com/typst/typst/discussions/1069")[How to wrap text around an image? · typst/typst · Discussion #1069] ] = 快速上手 == 安装 #slide()[ / VS Code方案: 安装VS Code编辑器后,搜索并安装插件`Tinymist Typst`,这之后,就可以在编辑器内愉快写作了,不需要安装其他工具。 #pause / 本地CLI方案: 如果想配合其他编辑器,通过命令行使用#Typst,可以安装其CLI工具,例如Windows下。 ```sh winget install --id Typst.Typst ``` #Typst 编译指令为 ```sh typst compile --root <DIR> <INPUT_FILE> ``` #pause / 在线编辑方案: 使用#Typst 提供的#link("https://typst.app/")[Web App],类似于#LaTeX 当中的 Overleaf。 ] == 语法概览 以下所有语法详见#link("https://typst.app/docs/reference/syntax/")[Syntax – Typst Documentation]。 #pause / 标记模式(Markup ): 这是一篇#Typst 文档的默认格式,又称内容块,在标记模式下输入的文字会被视为要排版的内容,可使用语法糖。 ``` Hello, world! *Typst* is simple to write! ``` #pause / 注释(Comments): 类似C/C++风格 - `// 单行注释。` - `/* 多行注释。 */` #pause / 公式模式(Math Mode): 用`$ $`包裹 ``` $a^2+b^2=c^2$ ``` #pause / 脚本模式: 以`#`标记,代表函数,变量,关键字等 ``` #let typst-color = rgb("#239DAD") ``` == 字体 #slide()[ - #Typst 本身不分发字体,而是使用本地计算机上已有的字体。 例如在VS Code中打开终端,输入以下命令,可以得到系统中已安装的字体列表,这些字体都可被#Typst 使用。 ```sh typst fonts ``` 如果显示未找到命令等情况,可能是因为没有安装CLI工具。 #pause - 字体参数#link("https://typst.app/docs/reference/text/text/#parameters-font")[font]接受`str|array`,按优先级传入若干字体。 ``` #set text(font: ("Linux Libertine", "Source Han Serif")) ``` #pause - 除此之外,语言和区域代码也会影响字体的选择以及图表编号的显示。 ``` #set text(font: ("Linux Libertine", "Source Han Serif"), lang: "zh", region: "cn") ``` ] == 设置元素大小 在#Typst 中,可以通过`size`参数设置元素的大小,例如 #align(center)[ #grid(columns: 2, column-gutter: 1em, [ ``` #set text(size: 28pt) very #text(1.5em)[big] text and #text(size: .5em)[small] text ``` ], [ #set text(size: 28pt) very #text(1.5em)[big] text and #text(size: .5em)[small] text ]) ] / 注意: `em`是相对单位,`pt`是绝对单位。 #pause 此外,还可以使用的绝对单位有 - `mm` - `cm` - `in` == 语法糖标记 #text(size: 0.9em)[ #columns(2)[ / 标题: ``` = 这是一级标题 == 标题可以含有数学公式 === $beta^-$衰变 ``` #pause / 无序列表(Bullet List): ``` - 清华大学 - 北京大学 ``` #pause / 有序列表(Numbered List): ``` + Preparations + Analysis + Conclusions ``` #pause / 术语列表(Term List): ``` / Ligature: A merged glyph. / Kerning: A spacing adjustment between two adjacent letters. ``` #pause / 斜体(Emphasis): ``` This is _emphasized._ and this is #emph[too.] ``` #pause / 粗体(Strong): ``` This is **strong.** and this is #strong[too.] ``` #pause / 智能引号(Smart Quotes): 用英文引号包裹内容,根据国家和区域代码决定显示方式。 ``` #set text(lang: "en") "Hello, world!" #set text(lang: "de") "Wir schaffen das!" ``` #pause / 纯文本(Raw Text / Code): #raw("`")或#raw("```"),与Markdown相同。 ] ] == 插图 #grid(columns: (1fr,1fr), column-gutter: 1em, [ 插入单张图片很简单 ``` #figure(image("4.svg", height: 60%), caption: "中微子的三种味") <a-label> @a-label 展示了基本粒子。 ``` ], [ #image("pic/1.png",height: 40%) ]) #grid(columns: (1fr,1fr), column-gutter: 1em, [ 多张图片的排版借助于`grid`函数 ``` #grid(columns: 2, column-gutter: 1em, figure(image("9.jpg",height: 70%), caption: "Super-K剖面"), figure(image("10.jpg", height: 80%), caption: "Super-K广角摄影")) ``` ], [ #image("pic/2.png",height: 40%) ]) == 表格 #figure( table(columns: 3, table.header( [Substance], [Subcritical °C], [Supercritical °C], ), [Hydrochloric Acid], [12.0], [92.1], [Sodium Myreth Sulfate], [16.6], [104], [Potassium Hydroxide], table.cell(colspan: 2)[24.7], ), caption: "表格示例") ``` #figure( table(columns: 3, table.header( [Substance], [Subcritical °C], [Supercritical °C], ), [Hydrochloric Acid], [12.0], [92.1], [Sodium Myreth Sulfate], [16.6], [104], [Potassium Hydroxide], table.cell(colspan: 2)[24.7], ), caption: "表格示例") ``` 关于`figure`是否应该包含`table`以及`image`,参考#link("https://github.com/typst/typst/issues/1058")[Issue \#1058] == 包管理 包是模板或库,通过精确指定名称及版本号引入,会被本地的#Typst 工具自动管理,按需下载。访问#link("https://typst.app/universe/")[Typst Universe]了解#Typst 社区生态。 ``` #import "@preview/physica:0.9.3": * ``` #pause - #link("https://typst.app/universe/package/physica")[physica – Typst Universe] 对标#LaTeX 中的physics,语法相近。 - #link("https://typst.app/universe/package/ctheorems")[ctheorems – Typst Universe] 定义定理证明环境。 - #link("https://github.com/OrangeX4/typst-cheq")[OrangeX4/typst-cheq] 漂亮的Markdown风格复选框 - #link("https://typst.app/universe/package/mitex")[mitex – Typst Universe] #LaTeX 公式转为#Typst 格式。 - #link("https://typst.app/universe/package/touying")[touying – Typst Universe] 本幻灯片用其制作,对标#LaTeX 中的beamer。 - #link("https://typst.app/universe/package/modern-cv")[modern-cv – Typst Universe] 简历模板 #pause 以上仅是一小部分,更多包有待自由探索! == 参考文献 ``` Super-K确定了太阳中微子振荡参数@fukuda_determination_2002 // 引用示例 #bibliography("main.bib", style: "american-physics-society", title: "参考文献") // 导入,设置引文格式与标题 #pause ``` / 什么是bib文件: bib文件是一种通过格式化文本描述参考文献的文件规范,多种文献管理软件,例如Zotero都可以导出bib文件。 ```bib @article{fukuda_determination_2002, title = {Determination of solar neutrino oscillation parameters using 1496 days of Super-Kamiokande I data}, volume = {539}, doi = {10.1016/S0370-2693(02)02090-7}, pages = {179--187}, journaltitle = {Phys. Lett. B}, author = {<NAME>. and {others}}, date = {2002} } ``` == 更精细的布局 / 对齐(align): #link("https://typst.app/docs/reference/layout/align/")[Align Function – Typst Documentation] / 垂直间距: #link("https://typst.app/docs/reference/layout/v/")[Spacing (V) Function – Typst Documentation],适合制作封面等需要惊喜布局的地方 / 水平间距: #link("https://typst.app/docs/reference/layout/h/")[Spacing (H) Function – Typst Documentation],与前者类似 / 多栏排版: #link("https://typst.app/docs/reference/layout/columns/")[Columns Function – Typst Documentation],与`grid`不同,`grid`制定哪些内容填充到哪块区域,而`columns`根据剩余版面自动调整 == 排版例子 无论开始学#LaTeX 还是 #Typst,都是从抄别人的排版开始的 #pause / 考试小抄: #link("https://github.com/adamanteye/note/blob/master/%E9%87%8F%E5%AD%90%E5%8A%9B%E5%AD%A6/%E6%9C%9F%E6%9C%AB%E5%B0%8F%E6%8A%84/main.typ")[note/量子力学/期末小抄/main.typ at master · adamanteye/note] - 使用了`physica`包,展示了如何使用#Typst 书写复杂公式 - 页面微雕技术 #pause / 幻灯片: #link("https://github.com/adamanteye/note/blob/master/%E4%B8%AD%E5%AD%90%E7%89%A9%E7%90%86%E5%AF%BC%E8%AE%BA/%E7%AC%AC%E4%BA%8C%E6%AC%A1%E5%A4%A7%E4%BD%9C%E4%B8%9A/main.typ")[note/中子物理导论/第二次大作业/main.typ at master · adamanteye/note] - 使用了`touying`包,展示了如何使用#Typst 制作简单幻灯片 - 更多的动画需要`pinit`包,大家可自行探索 #pause / 另一个幻灯片: #link("https://github.com/thudep/typst-talk")[thudep/typst-talk: 2024年春typst讲座] 本幻灯片的代码 = 总结 == 相关资料 #slide()[ / 阅读Typst博客: #link("https://typst.app/blog/")[Typst: Blog] 社区Roadmap发布与技术讨论 / 查找文档: #link("https://typst.app/docs/reference/")[Reference – Typst Documentation] 附有详尽用例,善用页内搜索功能 / 中文Typst文档(可能过时): #link("https://typst-doc-cn.github.io/docs/")[概览 – Typst 中文文档] / 查找数学符号: #link("https://typst.app/docs/reference/symbols/sym/")[General Symbols – Typst Documentation] / 探索社区包: #link("https://typst.app/universe/")[Typst Universe] / 遇到问题怎么办: 使用Google搜索,关注StackExchange等高质量社区回答 / 打字慢怎么办: 尝试Copilot等自动补全工具,发现灌水新途径 / 想压缩插图: #link("https://github.com/funbox/optimizt")[funbox/optimizt: CLI image optimization tool] `nodejs` 图像压缩工具 ] == 参考与鸣谢 - #Typst 官方文档等,在此不再详细列举 - #link("https://stu.cs.tsinghua.edu.cn/~harry/latex-talk.pdf")[如何使用LaTeX排版论文] - #link("https://github.com/OrangeX4/typst-talk")[OrangeX4/typst-talk: 并不复杂的 Typst 讲座 - Typst is Simple]
https://github.com/katamyra/Notes
https://raw.githubusercontent.com/katamyra/Notes/main/Compiled%20School%20Notes/CS1332/Modules/LinkedLists.typ
typst
#import "../../../template.typ": * = LinkedList == Singly Linked List === SLL Big O/Methods #theorem[ #text(fill: rgb("#1a5fd6"))[*Adding*] *Adding to Front*: O(1) - Create new node, point next to head, and set the new node to be the new head - If list is empty, the head is null which actually works out anyways without edge case (?) *Adding to Back* O(n) - Need to traverse to last node by iterating until curr.next is null (since we need access to last node). Set last mode w/data's next value to the new node. - If head is null, point head to new node ] #theorem[ #text(fill: rgb("#1a5fd6"))[*Removing*] *Removing from Front*: O(1) - Save data from head node, then set head = head.next *Removing from Back*: O(n) - Need to traverse until curr.next.next is null, then set curr.next to null - If size is zero, throw exception - If size is 1, set head to null ] == Tail Pointer Having a *tail pointer* makes _adding to back easier_, since you can just set the tails next reference to the new node and update tail. So adding to back is now *O(1)* == Doubly Linked List Generally doubly linked lists always have both a head and tail pointer, and contain a reference to previous node. #note[ For a DLL of size 0, both the head and tail point to null. For a DLL of size 1, both the head and tail point to the same node. ] === DLL Big O/Methods #theorem[ #text(fill: rgb("#1a5fd6"))[*Adding*] *Adding to the Front*: O(1) - Set the new nodes next to head, and set the head's previous to new node. Then set head to the new node. - When size = 0, set head and tail to new node *Adding to the Back*: O(1) - Set the tail's next to the new node, and the new nodes previous to the tail. Then set tail to new node. - When size = 0, set head and tail to new nodes ] #theorem[ #text(fill: rgb("#1a5fd6"))[*Removing*] *Removing from the Back*: O(1) - Set tail to tail's previous, then set tail next to null. - When size = 0, set head and tail to null *Removing from the Front*: O(1) - Set head to head's next, then set head.previous to null. - Size = 0 -> exception - When size = 1, set head and tail to null. ] Having *doubly linked lists* makes _removing from back easier_, since to remove you need to go to the node before the last one, and you need to reset tail. So you can set the second to last node.next to null and reset the tail to the second to last node. So it becomes *O(1)* == Circularly Singly Linked List The last node in the list points back to the head #note[ For CSLL, we can't use curr == null to check if we've reached the end of the list. Instead, we must use curr == head to terminate the loop ] === CSLL Big O/Methods #theorem[ #text(fill: rgb("#1a5fd6"))[*Adding*] *Adding to the Front*: O(1) - Create a new, empty node. Connect the new node's next to head's next. Set head's next to the new node. Put the data from head into the new node. Put the data we want to add into the head node. *Adding to the Back*: O(1) - Same steps as add to front, but now set head = head.next #text(fill: rgb("#1a5fd6"))[*Removing*] In general, removing cannot be optimized to be O(1) unless removing from front/edge cases *Removing from Front*: O(1) - Save data from head to return - Copy data from head's next into head - Set head's next to head.next.next - If size = 1, just set to null *Removing from Back*: O(n) - Need to iterate to the end of the array and set the 2nd to last node to point to head (?) ]
https://github.com/AliasQli/Chants-of-Sennaar.typst
https://raw.githubusercontent.com/AliasQli/Chants-of-Sennaar.typst/master/index.typ
typst
#let baseDir = "Runes/" #let makeLangGlyphs(lang) = { let glyphs = json(baseDir + lang + "/index.json") let ret = (:) for glyph in glyphs { ret.insert(glyph, image(baseDir + lang + "/" + glyph + ".png")) } ret } #let glyphs = ( Devots: makeLangGlyphs("Devots"), Guerriers: makeLangGlyphs("Guerriers"), Bardes: makeLangGlyphs("Bardes"), Alchimistes: makeLangGlyphs("Alchimistes"), Reclus: makeLangGlyphs("Reclus"), ) /// The game _Chants of Sennaar_ has 5 in-game languages and a number of glyphs. They are identified by *internal names*, and a `translation` is a mapping from their names to these internal names. /// /// In general, internal names start with capital letters and names should start with lower case letters. /// /// This function is used for making custom translations. A default translation @@english is provided and should cover most usecases. See #raw(baseDir + "translations/english.json") for the translation file format. /// /// - filename (string): The translation file to be loaded. /// -> translation #let makeTranslation(filename) = { let trans = json(filename) let reverse(dict) = { let ret = (:) for (k, v) in dict { ret.insert(v, k) } ret } ( meta: reverse(trans.meta), Devots: reverse(trans.Devots), Guerriers: reverse(trans.Guerriers), Bardes: reverse(trans.Bardes), Alchimistes: reverse(trans.Alchimistes), Reclus: reverse(trans.Reclus), ) } /// The default translation. It contains the following: ///#let dispLang(lang) = (english.meta.at(lang), lang) /// #let dispAlphabet(lang) = english.at(english.meta.at(lang)).pairs().map(((en, fr)) => (say(lang)(fr), fr, en)).join() /// /// *Languages:* /// /// #table( /// columns: 2, /// align: horizon, /// [*Internal Language Name*], /// [*English Language Name*], /// ..dispLang("devotees"), /// ..dispLang("warriors"), /// ..dispLang("bards"), /// ..dispLang("alchemists"), /// ..dispLang("anchorites"), /// ) /// /// #for lang in english.meta.keys() { /// /// [*The #(lang)' language:*] /// /// block(breakable: true, height: 70%, columns(2, table( /// columns: (1fr, 1fr, 1fr), /// align: horizon, /// [*Glyph*], /// [*Internal Name*], /// [*English Name*], /// ..dispAlphabet(lang), /// ))) /// } /// /// The following unused or hidden glyphs and the glyphs for numbers are *not* in the translation. You can refer to them by their internal name directly. /// /// #block(breakable: true, height: 70%, columns(2, table( /// columns: (1fr, 1fr, 1fr), /// align: horizon, /// [*Glyph*], [*English Language Name*], [*Internal Name*], /// ..("Question", "Guerre", "Plusieurs", "Boutique", "Maison", "Opticien", "Arme").map(c => (say("devotees")(c), [devotees], c)).join(), /// ..range(0, 10).map(i => (say("alchemists")(str(i)), [alchemists], str(i))).join(), /// ..("boutGauche", "boutDroite").map(c => (box(baseline: 25%, height: 1em, inset: (y: - (1.5em - 1em) / 2), glyphs.Bardes.at(c)), [bards], c)).join() /// ))) #let english = makeTranslation(baseDir + "translations/english.json") /// This function returns another function receiving any number of glyph names in the given language and outputs the glyphs. /// /// If an language name or glyph name is not present in the given translation, it's perceived as an internal name instead. /// /// Example: /// #example(`#say("bards")("not", "go", "warrior", "plural", "not") Warriors shall not pass.`, mode: "markup") /// /// - height (auto, relative): The height of the glyphs. /// Whatever the height is set to, the glyphs always fit into text lines. /// - baseline (relative): An amount to shift the glyphs' baseline by. /// - ..args (any): These additional arguments are passed to the `box` containing the glyph images. /// - translation (translation, none): Translation from in-game language names and glyph names to their internal names. /// - lang (string): The language name of the glyphs. /// -> (..string) -> content #let say(height: 1.25em, baseline: 25%, ..args, translation: english, lang) = (..words) => style(styles => { let Lang = if translation != none { translation.meta.at(default: lang, lang) } else { lang } let translate(word) = if translation != none { translation.at(Lang).at(default: word, word) } else { word } let boxHeight = measure("A", styles).height let bottom = baseline * height let top = height - boxHeight - bottom box(height: boxHeight, inset: (top: -top , bottom: -bottom), ..args, if Lang == "Bardes" { box(glyphs.Bardes.boutGauche) words.pos().map(word => box(glyphs.Bardes.at(translate(word)))).join() box(glyphs.Bardes.boutDroite) } else { words.pos().map(word => box(glyphs.at(Lang).at(translate(word)))).join(h(height / 10)) } ) })
https://github.com/noahjutz/AD
https://raw.githubusercontent.com/noahjutz/AD/main/main.typ
typst
#import "components/title.typ": title #import "config.typ" #show: config.config #set page(numbering: "1") #title #heading(numbering: none)[ #text(weight: 100, size: 40pt)[Notizen] ] <notizen> #outline( target: selector(heading) .before(<uebungen>, inclusive: false) .after(<notizen>, inclusive: false), ) #{ pagebreak() set page(columns: 2) include "notizen/mathe/main.typ" include "notizen/komplexitaet/main.typ" include "notizen/algorithmen/main.typ" include "notizen/sortieralgorithmen/main.typ" } #pagebreak() #title #heading(numbering: none)[ #text(weight: 100, size: 40pt)[Übungen] ] <uebungen> #outline( target: selector(heading) .before(<appendix>, inclusive: false) .after(<uebungen>, inclusive: false) ) #{ counter(heading).update(0) pagebreak() set page(columns: 2) include "uebungen/1/main.typ" include "uebungen/2/main.typ" include "uebungen/3/main.typ" include "uebungen/4/main.typ" include "uebungen/5/main.typ" } #pagebreak() #title #heading(numbering: none)[ #text(weight: 100, size: 40pt)[Appendix] ] <appendix> #outline( target: selector(heading) .after(<appendix>, inclusive: false) .before(<literatur>, inclusive: false) ) #{ counter(heading).update(0) pagebreak() set page(columns: 2) include "appendix/proof/main.typ" include "appendix/examples/main.typ" set page(columns: 1) include "appendix/code/main.typ" } #pagebreak() #title #heading(numbering: none)[ #text(weight: 100, size: 40pt)[Bibliographie] ] <literatur> #outline( target: selector(heading) .after(<literatur>, inclusive: false) ) #bibliography( "sources.yml", title: none, )
https://github.com/booleto/internship_report
https://raw.githubusercontent.com/booleto/internship_report/main/main.typ
typst
#import "template.typ": * #import "@preview/plotst:0.1.0": * // Take a look at the file `template.typ` in the file panel // to customize this template and discover how it works. #show: project.with( institutions: ( text("Đại học Quốc gia Hà nội", weight: 800), text("Trường Đại học Khoa học Tự nhiên", weight: 800), "", "", "", "", "", "", text("Khoa Toán - Cơ - Tin học", weight: 800) ), title: "Báo cáo thực tập", subtitle: "Xây dựng API nhận diện\n chữ bằng Tesseract OCR", authors: ( "<NAME>", ), logo: "VNU-HUS.jpg" ) #set text(11pt) // We generated the example code below so you can see how // your document will look. Go ahead and replace it with // your own content! #align( center, text(24pt, bottom-edge: "baseline")[Lời cảm ơn] ) Em xin cảm ơn các thầy cô khoa Toán - Cơ - Tin học đã tạo điều kiện cho em hoàn thành kỳ thực tập năm nay. Kỳ thực tập đã đem lại nhiều kinh nghiệm làm việc quý báu cho em, và sẽ là hành trang giúp em tiếp tục phát triển kỹ năng sau này. Em xin cảm ơn anh Lê Huy Toàn, người hướng dẫn tại công ty FIS, đã chỉ dẫn em tận tình từ những bước đầu tiên, từ đó em mới có thể có đủ kiến thức để hoàn thành bài báo cáo này. Em xin chân thành cảm ơn. #pagebreak() = Giới thiệu công ty FIS FPT Information System, hay FIS, là doanh nghiệp tích hợp hệ thống, cung cấp các giải pháp hàng đầu Việt Nam trong suốt quá trình hình thành và phát triển. Thành lập từ năm 1994, tính đến năm 2023 FIS đã có 3200 cán bộ, nhân viên có trình độ cao, sở hữu năng lực và trình độ công nghệ được công nhận bởi cả những đối tác trong và ngoài nước. FIS là một công ty thành viên của Tập đoàn FPT - một tên tuổi dẫn đầu về Công nghệ thông tin - Viễn thông. Tập đoàn FPT có đội ngũ 40.000 nhân viên, với 290 trụ sở, văn phòng, chi nhánh tại 29 quốc gia và vùng lãnh thổ trên toàn cầu. FPT hoạt động chủ yếu trong công nghệ, viễn thông và giáo dục. Hợp thành bởi 8 công ty thành viên và 4 công ty liên kết, sự lớn mạnh của FPT chính là nền tảng vững chắc cho sự phát triển bền vững của FIS. *Thông tin về đơn vị thực tập - FIS:* #table( columns: (auto, auto), inset: 7pt, stroke: none, column-gutter: 20pt, [Tên đăng ký], [CÔNG TY TNHH HỆ THỐNG THÔNG TIN FPT], [Địa chỉ đăng ký], [Tầng 22 tòa nhà Keangnam Landmark 72 Tower, E6 Phạm Hùng, Hà Nội], [Điện thoại], [84 - 24 3562 6000 hoặc 84 - 24 7300 7373], [Tên người đại diện và chức vụ], [Ông Trần Đăng Hòa – Chủ tịch công ty #linebreak() Ông Nguyễn Hoàng Minh – Tổng Giám đốc], [Địa chỉ (Trụ sở chính)], [Tầng 22 tòa nhà Keangnam Landmark 72 Tower, E6 Phạm Hùng, Hà Nội], [FAX (Trụ sở chính)], [84 - 24 356 24 850], [Quy mô nhân sự], [3.200 (theo tháng 04/2023)], [Trang chủ URL], [#link("www.fpt-is.com")], [Năm thành lập], [1994], [Loại hình công ty], [Công ty trách nhiệm hữu hạn] ) = Phân tích yêu cầu đề tài == Lý do chọn đề tài OCR (Optical Character Recognition) - tức nhận dạng ký tự quang học - là một ứng dụng tuy không mới, nhưng vẫn chứa đựng nhiều thách thức, ngay cả với trình độ phát triển của công nghệ AI hiện nay. Cụ thể, tuy các công cụ nhận dạng các văn bản in đã đạt đến độ chính xác rất cao, nhưng vẫn còn một số hạn chế, chẳng hạn về bộ nhớ, về yêu cầu phần cứng, về tốc độ, giá thành, cũng như khả năng cung cấp các thông tin bổ sung, như vị trí chữ, phân đoạn, phân khoảng... Từ đó, nảy sinh nhu cầu xây dựng một API - tức một giao diện lập trình ứng dụng - làm trung gian giữa công cụ OCR với các ứng dụng khác, từ đó giúp cho việc phát triển các ứng dụng thực tế liên quan tới OCR được dễ tiếp cận hơn. == Mục tiêu đề tài Xây dựng một REST API có khả năng nhận diện chữ từ văn bản in, sao cho thỏa mãn các tiêu chí: - Máy chủ: được cài đặt trên các máy tính trong một mạng máy tính, các máy tính giao tiếp thông qua giao thức HTTP. - Xử lý song song: phải có khả năng xử lý song song để đạt tốc độ cao hơn so với xử lý tuần tự thông thường, tận dụng triệt để khả năng của cụm máy tính. - Dễ triển khai và mở rộng: làm sao để có thể thêm/bớt máy chủ mà chỉ cần chỉnh file cấu hình. = Giới thiệu về OCR == Tổng quan OCR (Optical Character Recognition) - hay Nhận diện ký tự quang học, là một lĩnh vực nghiên cứu trong nhận dạng mẫu và thị giác máy tính. Một phần mềm OCR có đầu vào là một ảnh, và đầu ra là các chữ xuất hiện trong ảnh dưới dạng xâu ký tự (`String`). OCR được ứng dụng rộng rãi trong nhiều lĩnh vực, phổ biến nhất là nhập liệu tự động (hóa đơn, danh thiếp, hộ chiếu, biển số xe...) và chuyển các văn bản giấy được scan về dạng xâu ký tự. Ở trong bài báo cáo này, chúng ta sẽ chủ yếu tập trung vào ứng dụng nhận diện chữ trên văn bản giấy đã được scan. == Kiến trúc Các phần mềm OCR nhìn chung đều có 3 bước chính: - *Bước 1:* Nhận diện kiểu chữ, hướng chữ; Phát hiện chữ - *Bước 2:* Nhận diện chữ - *Bước 3:* _(không bắt buộc)_ Kiểm tra chính tả === Phát hiện chữ, tìm kiểu chữ và hướng chữ Đầu tiên, phần mềm OCR thử phát hiện vị trí của từng ký tự (hoặc từng từ), vẽ hình chữ nhật nhỏ nhất bao quanh ký tự, rồi cắt từng hình chữ nhật ra khỏi ảnh để thu được một ảnh con chỉ bao gồm ký tự đó. #figure( image( "figures/Capture.PNG", fit: "contain", height: 40% ), caption: "Chữ được phát hiện" ) <chu_phat_hien> Phần mềm sau đó sẽ chạy mô hình phát hiện kiểu chữ đối với các ký tự (chẳng hạn chữ Latin, chữ Hán, chữ Hàn,...), từ đó chọn mô hình nhận diện chữ và bảng chữ cái sử dụng trong bước tiếp theo. Một số phần mềm OCR có thể phát hiện ra độ xoay của văn bản, và sẽ xoay lại văn bản cho thẳng hàng. === Nhận diện chữ Hàm nhận diện chữ lấy đầu vào là ảnh ký tự (hoặc từ) đã được cắt, và đầu ra là ký tự mà mô hình đọc được. Hàm nhận diện chữ sử dụng các mô hình deep learning, thường là các mạng neuron tích chập (convolutional neural network). #figure( image( "figures/predicted1.jpg", fit: "contain", ), caption: "Chữ được nhận diện" ) Đây là bước quan trọng nhất của quá trình OCR, và chất lượng của ảnh tại bước này sẽ mang tính quyết định tới chất lượng của đầu ra. === Kiểm tra chính tả <chinhta> Đối với một số ứng dụng của OCR, đôi lúc do việc cắt ảnh, chất lượng ảnh, độ sáng/tối,... mà ảnh đầu ra sẽ bị sai lệch ở nhiều điểm nhỏ. Chẳng hạn đối với tiếng Việt, một số phông chữ có dấu sắc, dấu hỏi, dấu huyền rất giống nhau, khó phân biệt nếu ảnh không đủ độ phân giải. #figure( grid( image( "figures/baotangtinh.PNG", ), image( "figures/baotangtinh2.PNG" ) ), caption: "Ảnh thực tế (trên) so với kết quả đọc được (dưới)" ) Như ở trên, dấu huyền trông rất giống dấu hỏi, nên phần mềm OCR đã xảy ra nhầm lẫn. Vì vậy, một số phần mềm OCR tích hợp công cụ kiểm tra chính tả, hoặc các mô hình ngôn ngữ tự nhiên để đem lại độ chính xác cao hơn. = Xây dựng API nhận diện chữ == Các công nghệ chính được sử dụng === Giới thiệu về Spring Boot Spring Boot là một thư viện mã nguồn mở cung cấp các công cụ hỗ trợ để người dùng xây dựng các ứng dụng Java một cách nhanh gọn. Spring Boot là một thành phần của hệ sinh thái Spring framework, và có thể tương tác với các module khác của Spring, chẳng hạn Spring Data, Spring Web, Spring Security,... giúp người lập trình không phải tương tác trực tiếp với các API bậc thấp, làm cho việc phát triển ứng dụng trở nên dễ dàng. Một trong những tính năng nổi bật nhất của Spring Boot là các `@Annotations`, giúp người lập trình cài đặt các cấu hình đa dạng chỉ với vài dòng lệnh cơ bản. *Ưu điểm:* - Có thể xuất ra file `.jar`, chạy được trên mọi máy tính có phiên bản Java phù hợp. - Cấu hình tự động mỗi khi có thể, tiết kiệm thời gian lập trình. - Cung cấp rất nhiều plugin. - Có thể sử dụng các đối tượng Java cơ bản. - Cài đặt cấu hình nhanh chóng với các `@Annotation`. - Có thể cài đặt xử lý đa luồng, giúp tăng tốc độ xử lý - Mã nguồn mở. - Miễn phí. === Giới thiệu về Tesseract Tesseract OCR là một phần mềm OCR mã nguồn mở, được phát hành trên giấy phép Apache 2.0, cho phép người dùng có thể sử dụng, chỉnh sửa, và bán sản phẩm phái sinh từ mã nguồn. Tesseract ban đầu được phát triển bởi Hewlett-Packard, sau đó trở thành phần mềm mã nguồn mở và được tài trợ phát triển bởi Google vào năm 2005. Hiện nay, Tesseract được cho là một trong những công cụ OCR chính xác nhất trên thị trường. Mặc dù là phần mềm mã nguồn mở, Tesseract đạt độ chính xác tương đương những phần mềm trả phí như Azure AI, ABBYY,... Tesseract rất phù hợp với mục tiêu dự án, vì có thể được cài đặt trên Windows, Linux, MacOS, và hỗ trợ hơn 100 ngôn ngữ. #figure( grid( columns: (auto, auto), [#image("figures/tesscli.PNG")], [#image("figures/vpcp_cropped.png", height: 220pt)] ), caption: "Giao diện dòng lệnh Tesseract (bên trái) chứa kết quả đọc từ ảnh (bên phải)" ) *Ưu điểm:* - Hỗ trợ nhiều ngôn ngữ. - Cài đặt được trên nhiều hệ điều hành. - Tốc độ tương đối nhanh. - Là một trong những phần mềm OCR chính xác nhất hiện nay. - Dùng được qua ứng dụng dòng lệnh (Tesseract), hoặc API C/C++ (Libtesseract). - Có các thư viện wrapper cho cả ứng dụng dòng lệnh (pytesseract, tess4j); và cả API C/C++ (tesserocr, module Tesseract thuộc JavaCPP) - Mã nguồn mở - Miễn phí *Nhược điểm:* - Không xử lý được file PDF. - Không có chức năng chạy online. - Cần phải biết trước ngôn ngữ của ảnh cần đọc. - Không có xử lý đa luồng, mọi bước đều tuần tự. - Tài liệu của API không được ghi chi tiết, hầu như phải đọc trực tiếp mã nguồn C/C++. - Nếu muốn cài phiên bản mới nhất thì phải tự biên dịch mã nguồn. - Không có chức năng kiểm tra chính tả. === Giới thiệu về Leptonica Leptonica là một thư viện mã nguồn mở về xử lý và phân tích ảnh trong C/C++, cung cấp các cấu trúc dữ liệu cơ bản nhưng đi cùng rất nhiều phép toán và hàm biến đổi được dùng trong xử lý ảnh. Leptonica là thư viện nền tảng được sử dụng trong cả Tesseract và OpenCV - 2 thư viện nổi bật trong các ứng dụng OCR. *Ưu điểm:* - Cung cấp nhiều phép toán và hàm biến đổi đa dạng. - Các cấu trúc dữ liệu đơn giản. - Các hàm đọc và xuất file sử dụng dễ dàng. - Mã nguồn mở - Miễn phí *Nhược điểm:* - Không sử dụng biến tham chiếu tới đối tượng, mà dùng con trỏ tới địa chỉ bộ nhớ, nên khó kết hợp với ứng dụng Java. Điều này được phần nào giải quyết nếu dùng JavaCPP. === Giới thiệu về JavaCPP Đối với Java, những người phát triển JavaCPP xem thư viện này như là cầu nối tới C++ giống như C++ là cầu nối tới Assembly. Thay vì sáng tạo ra các cú pháp mới, các chức năng của C++ trở thành các lớp, các hàm, các biến trong Java. Tuy nhiên, code JavaCPP vẫn được đưa về code C++, nên cách viết code cũng phải giống như viết C++. Thư viện JavaCPP nắm vai trò rất quan trọng trong dự án. Các thư viện dùng để tương tác với Tesseract hầu hết đều có điểm yếu lớn: Cả Pytesseract và Tess4j đều chỉ là wrapper cho giao diện dòng lệnh (Tesseract CLI), nhưng Tesseract CLI gộp 2 hàm phát hiện chữ và nhận diện chữ về 1 lệnh. Khi đó thì chỉ có thể truyền từng trang một vào xử lý, nên chỉ xử lý song song được theo trang. Với những tài liệu lớn nhưng ít trang thì thường không chia đều công việc được cho các máy chủ. #figure( image( "figures/tesscli_parallel.PNG", height: 200pt ), caption: "Ví dụ: Nếu gộp bước phát hiện và nhận diện", ) Ngược lại, thư viện JavaCPP có thể tương tác với API C/C++ của Tesseract (còn gọi là Libtesseract). Khi đó, quá trình OCR có thể chia thành 2 bước rõ ràng (phát hiện chữ #sym.arrow nhận diện chữ), nên ta có thể phát hiện chữ trước, rồi chia đều thành từng đoạn để gửi song song đến các máy chủ chạy Tesseract, giúp chia đều khối lượng công việc hơn cho các máy chủ. Cách tiếp cận này được áp dụng với hy vọng làm tăng tốc độ xử lý cho API, và giúp API chịu tải tốt hơn. #figure( image( "figures/tessapi_parallel.PNG", height: 250pt ), caption: "Ví dụ: Nếu tách rời bước phát hiện và nhận diện", ) *Ưu điểm:* - Giúp việc tương tác với các API C/C++ trở nên dễ dàng hơn. - Hỗ trợ cả Tesseract và Leptonica, cùng với rất nhiều thư viện C/C++ khác. - Cú pháp như Java, người lập trình Java không phải học cú pháp mới. - Có thể dùng cùng với hệ sinh thái Spring. *Nhược điểm:* - Quản lý bộ nhớ thủ công như trong C/C++, nếu không cẩn thận dễ gây rò bộ nhớ. - Tài liệu API không được ghi chi tiết, hầu như phải đọc mã nguồn Java và cả C/C++. - Một số hàm không tạo ra `exception` khi lỗi, nên không thể xử lý `exception`, gây dừng ứng dụng (đặc biệt là lỗi truy cập bộ nhớ - `segmentation fault`). - Tuy cú pháp như Java, nhưng cách code vẫn phải giống C/C++. #pagebreak() == Kiến trúc phần mềm Phần mềm được chia thành 3 module, mỗi module có 1 REST API. #figure( image("figures/kientrucphanmem.png"), caption: "Kiến trúc phần mềm" ) Trong đó mỗi module có công dụng: - `PDF Image Extract`: Tách file PDF thành một mảng các trang (dưới dạng ảnh), sau đó gửi đến các API tiếp theo bằng 1 trong 3 cách. - `Tesseract Paragraph Extract`: Tách ảnh trang giấy thành một mảng chứa các đoạn văn trong trang (dưới dạng ảnh), mỗi đoạn văn được đưa vào một luồng xử lý và gửi song song đến REST API của `Tesseract Reader` - `Tesseract Reader`: Dùng Tesseract đọc chữ từ ảnh, trả về kết quả API có thể xử lý PDF với theo 3 cách: - Xử lý tuần tự: Gửi tuần tự từng trang đến `Tesseract Reader` - Song song theo đoạn: Gửi song song từng trang đến `Tesseract Paragraph Extract`, `Tesseract Paragraph Extract` sau đó sẽ gửi từng trang đến `Tesseract Reader` - Song song theo trang: Gửi song song từng trang đến `Tesseract Reader` Để xử lý song song, ta cũng có thể chạy nhiều module `Tesseract Paragraph Extract` và `Tesseract Reader` trên nhiều máy tính khác nhau: #figure( image("figures/kientruc2.png"), caption: "Ví dụ: Cách 2 khi chạy nhiều module" ) === Module 1: Pdf Image Extract - Tách ảnh từ PDF Module đọc file PDF và tách ra thành một mảng các file ảnh, mỗi ảnh là một trang giấy trong tài liệu. *Cấu trúc file* - #text(`tess.pdf.image.extract`, fill: orange, weight: "bold") - #text(`PdfImageExtract.java`, fill: eastern, weight: "bold") - #text(`tess.pdf.image.extract.config`, fill: orange, weight: "bold") - #text(`PdfImageExtractConfig.java`, fill: eastern, weight: "bold") - #text(`tess.pdf.image.extract.controller`, fill: orange, weight: "bold") - #text(`PdfImageExtractController.java`, fill: eastern, weight: "bold") - #text(`tess.pdf.image.extract.runner`, fill: orange, weight: "bold") - #text(`ParaExtractThreadRunner.java`, fill: eastern, weight: "bold") - #text(`TessApiThreadRunner.java`, fill: eastern, weight: "bold") - #text(`tess.pdf.image.extract.service`, fill: orange, weight: "bold") - #text(`ImageExtractor.java`, fill: eastern, weight: "bold") - #text(`ParaExtractAsyncRequest.java`, fill: eastern, weight: "bold") - #text(`RequestSender.java`, fill: eastern, weight: "bold") - #text(`TessApiAsyncRequest.java`, fill: eastern, weight: "bold") ==== Bước 1: Tách ảnh khỏi PDF Sử dụng thư viện PDFBox để tìm kiếm đệ quy các ảnh trong PDF. #figure( image("figures/pdfstep1.PNG"), caption: "Quy trình bước 1" ) *Các lớp chính:* - `PdfImageExtractController`: Là dạng `@RestController` để nhận file người dùng tải lên. - `ImageExtractor`: Dùng để tách ảnh khỏi PDF bằng tìm kiếm đệ quy `ImageExtractor` chuyển dữ liệu `byte[]` của file thành kiểu `PDDocument`, rồi lấy các `PDResources` tương ứng với mỗi trang và tìm kiếm đệ quy các ảnh trong `PDResources` ==== Bước 2: Gửi ảnh tới module tiếp theo *Các lớp chính* - `ParaExtractAsyncRequest`: khởi tạo các luồng để gửi ảnh đến `Tesseract Paragraph Extract`. - `TessApiAsyncRequest`: khởi tạo các luồng để gửi ảnh đến `Tesseract Reader` - `ParaExtractThreadRunner` và `TessApiThreadRunner`: kế thừa interface `Runner`, dùng để chạy luồng gửi ảnh. Mỗi luồng trỏ tới một đối tượng `RequestSender` riêng và gửi ảnh bằng hàm của `RequestSender`. - `RequestSender`: `@Service` để gửi ảnh đến module tiếp theo. `RequestSender` sẽ gửi file dưới dạng Multipart Form data. *Cách 1: Gửi tuần tự từng trang:* Các file được lần lượt gửi trang đó cho `Tesseract Reader`. Sau khi kết quả trang trước được trả về thì trang sau mới được gửi. #figure( image("figures/pdfimage_pdf.png", height: 160pt), caption: "Cách 1: Xử lý tuần tự" ) Các ảnh được gửi lần lượt, ảnh trước có kết quả thì ảnh sau mới được gửi. ```java ArrayList<String> responses = new ArrayList<>(); for (File image : images) { responses.add(requestSender.sendImageToTessApi(image)); } return responses.toString(); ``` *Cách 2: Gửi song song từng đoạn đến `Tesseract Paragraph Extract`* Khởi tạo các luồng xử lý (`Thread`) và gửi song song ảnh tới module tiếp theo. #figure( image("figures/pdfstep2.PNG"), caption: "Cách 2: Song song theo đoạn" ) *Cách 3: Gửi song song từng trang đến `Tesseract Reader`* Khởi tạo các luồng xử lý (`Thread`) và gửi song song ảnh tới module tiếp theo. #figure( image("figures/pdfimage_async.png"), caption: "Cách 3: Song song theo trang" ) Hàm gửi file đến API khác sử dụng thư viện OkHttp3, vì cho phép gọi hàm gửi file mà chỉ cần biến tham chiếu đến file, từ đó tránh mâu thuẫn về định dạng ảnh, dễ dàng gửi file dạng Multipart. ```java /** * Gửi ảnh tới Tesseract Paragraph Extract * @param file * @return * @throws FileNotFoundException * @throws IOException */ public String sendImageToParagraphExtractor(File file) throws FileNotFoundException, IOException { OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("text/plain"); RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) .addFormDataPart("params", "asdf") .addFormDataPart("image", "pic_1.png", RequestBody.create(MediaType.parse("application/octet-stream"), file)) .build(); Request request = new Request.Builder() .url(PARA_EXTRACT_SERVER) .method("POST", body) .addHeader("PageSegMode", "3") .addHeader("Language", "vie") .build(); Response response = client.newCall(request).execute(); String result = response.body().string(); LOGGER.info(result); return result; } } ``` #pagebreak() === Module 2: Tesseract Paragraph Extract - Tách đoạn văn từ trang Module đọc ảnh một trang giấy, và tách ra thành một mảng các file ảnh, mỗi ảnh là một đoạn văn được cắt ra khỏi trang giấy. *Cấu trúc file:* - #text(`tess.tesseract.paragraph.extract`, fill: orange, weight: "bold") - #text(`TesseractParagraphExtract.java`, fill: eastern, weight: "bold") - #text(`tess.tesseract.paragraph.extract.controller`, fill: orange, weight: "bold") - #text(`ParagraphExtractController.java`, fill: eastern, weight: "bold") - #text(`tess.tesseract.paragraph.extract.runner`, fill: orange, weight: "bold") - #text(`TessApiThreadRunner.java`, fill: eastern, weight: "bold") - #text(`tess.tesseract.paragraph.extract.service`, fill: orange, weight: "bold") - #text(`ParagraphExtractor.java`, fill: eastern, weight: "bold") - #text(`RequestSender.java`, fill: eastern, weight: "bold") - #text(`TessApiAsyncRequest.java`, fill: eastern, weight: "bold") ==== Bước 1: Tách đoạn văn từ ảnh Dùng Tesseract API thông qua JavaCPP để phát hiện các đoạn văn từ ảnh. Sau đó cắt các ảnh ra và lưu vào file tạm. #figure( image("figures/parastep1.PNG"), caption: "Quy trình bước 1" ) *Các lớp chính:* - `ParagraphExtractController`: dạng `@RestController`, nhận file ảnh 1 trang giấy mà module `Pdf Image Extract` gửi đến, và truyền vào `ParagraphExtractor`. - `ParagraphExtractor`: dạng `@Service`, chạy mô hình phát hiện chữ của Tesseract, phát hiện các đoạn văn, cắt ảnh đoạn văn ra. Hàm tách đoạn văn sử dụng API của Tesseract thông qua lớp `TessBaseAPI` của JavaCPP. #pagebreak() ```java /** * Tách ảnh đoạn văn ra khỏi ảnh gốc * * @param image: ảnh gốc * @return ArrayList<PIX>: các ảnh đoạn văn đã tách */ public ArrayList<PIX> extract(PIX image) { Random rand = new Random(12345); TessBaseAPI tessApi = new TessBaseAPI(); tessApi.Init(null, "vie"); tessApi.SetPageSegMode(tesseract.PSM_AUTO); tessApi.SetImage(image); BOXA boxes = tessApi.GetRegions((PIXA) null); ArrayList<PIX> result = new ArrayList<>(); for (int i = 0; i < leptonica.boxaGetValidCount(boxes); i++) { //L_COPY=1, truyền con trỏ tới bản sao thay vì đến object gốc BOX box = leptonica.boxaGetValidBox(boxes, i, leptonica.L_COPY); PIX pic = leptonica.pixClipRectangle(image, box, (BOX) null); leptonica.pixWritePng("imagedump/test" + Long.toString(rand.nextLong()) + ".png", pic, 0); result.add(pic); } return result; } ``` Sau khi tách ảnh, Tesseract trả về tham chiếu tới ảnh ở dạng `PIX`. Đây ngầm là dạng con trỏ của con trỏ bộ nhớ (`PointerPointer` trong JavaCPP, `long**` trong C++), nên ảnh phải được đọc vào file tạm rồi mới có thể gửi đi. ```java /** * Chuyển ảnh từ dạng PIX về File * @param pix ảnh * @return File ảnh * @throws IOException */ public File pixToFile(PIX pix) throws IOException { UUID uuid = UUID.randomUUID(); String tempName = "temp" + uuid.toString() + ".png"; leptonica.pixWritePng(tempName, pix, 0); File file = new File(tempName); file.deleteOnExit(); return file; } ``` ==== Bước 2: Gửi song song ảnh đến Tesseract Reader Hoàn toàn tương tự bước 2 của module `Pdf Image Extract`, nhưng gửi ảnh đến `Tesseract Reader` #figure( image("figures/parastep2.png"), caption: "Quy trình bước 2" ) *Các lớp chính:* - `TessApiAsyncRequest`: Dạng `@Service`. Nhận một danh sách ảnh đoạn văn, rồi khởi tạo các luồng xử lý cho mỗi ảnh đoạn văn. - `TessApiThreadRunner`: kế thừa interface `Runner`. Dùng để chạy luồng gửi ảnh. Mỗi luồng trỏ tới một đối tượng `RequestSender` riêng và gửi ảnh bằng hàm của `RequestSender`. - `RequestSender`: gửi ảnh đến module tiếp theo. === Module 3: Tesseract Reader - Đọc chữ từ ảnh Module đưa ảnh vào Tesseract để đọc chữ từ ảnh. *Cấu trúc file:* - #text(`tess.tesseractReader`, fill: orange, weight: "bold") - #text(`TesseractApi.java`, fill: eastern, weight: "bold") - #text(`tess.tesseractReader.config`, fill: orange, weight: "bold") - #text(`TessConfiguration.java`, fill: eastern, weight: "bold") - #text(`tess.tesseractReader.controller`, fill: orange, weight: "bold") - #text(`ReaderController.java`, fill: eastern, weight: "bold") - #text(`tess.tesseractReader.service`, fill: orange, weight: "bold") - #text(`TessReaderService.java`, fill: eastern, weight: "bold") Module nhận đầu vào là một ảnh có chữ, và đầu ra là các chữ nhận diện được trên ảnh đó. #figure( image("figures/tessreader.png"), caption: "Quy trình hoạt động của Tesseract Reader" ) *Các lớp chính:* - `ReaderController`: Dạng `@RestController`. Nhận file ảnh, chuyển thành dạng `PIX` của Leptonica, rồi truyền cho `TessReaderService` - `TessReaderService`: Dạng `@Service`. Lấy đầu vào là ảnh đoạn văn và đầu ra là đoạn văn đọc được dưới dạng xâu ký tự (`String`) Hàm đọc chữ sử dụng API Tesseract thông qua lớp `TessBaseAPI` của JavaCPP. ```java public String readPIXImage(PIX image, Map<String, String> params) { TessBaseAPI tessApi = new TessBaseAPI(); String str_result = new String(); setTesseractParameters(tessApi, params); tessApi.SetImage(image); // Đọc chữ từ ảnh, trả về con trỏ BytePointer result = tessApi.GetUTF8Text(); if (result != null) { str_result = result.getString(); } // Phải giải phóng bộ nhớ thủ công tessApi.End(); if (result != null) { result.deallocate(); } return str_result; } ``` == Chạy thử === Cài đặt trên server Linux Để module `Tesseract Paragraph Extract` và `Tesseract Reader` có thể hoạt động, server cần phải cài sẵn Tesseract và Libtesseract. Chi tiết cách cài đặt đã được ghi trên trang web chính thức của Tesseract: #link("https://tesseract-ocr.github.io/tessdoc/#compiling-and-installation") Để cài các module trên server, đầu tiên ta chỉnh mục `<build>` của file #text("pom.txt", fill: fuchsia) của mỗi module sao cho khi biên dịch ra file `.jar`, các thư viện cần dùng cũng sẽ được copy ra một thư mục riêng, để dễ dàng copy qua server Linux: ```xml <build> <plugins> <plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>install</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> <finalName>${project.artifactId}-${project.version}</finalName> <directory>${compile.directory}/${project.artifactId}/target</directory> <resources> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> </resources> </build> ``` #figure( image( "figures/compile.png", height: 150pt ), caption: "Kết quả biên dịch có cả file .jar và thư mục lib" ) Để cài đặt module trên server, ta copy file `.jar` và thư mục `lib` qua một thư mục riêng trên server. #figure( image( "figures/image.png", width: 200pt ), caption: "Sau khi tải file lên server" ) Để chạy module, cần dùng lệnh `java` trên dòng lệnh. Để nhanh và tiện, ta dùng file `.sh` để chạy lệnh. File `.sh` chạy bằng lệnh `./<tên file>.sh`. Nếu không chạy được file `.sh`, dùng lệnh `chmod 755 *.sh` rồi chạy lại. - *run.sh (để khởi động module)* ```shell-unix-generic # Đặt biến môi trường export JAVA_HOME="<thư mục chứa JDK 17>" export PATH=$JAVA_HOME/bin:$PATH # Chạy module, lưu đầu ra vào file nohup.out cd <đường dẫn tới module> rm nohup.out # Lưu PID của tiến trình vào file pid.file, để tiện dừng module khi cần nohup java -Xmx1024m -cp './<tên file jar>.jar:./lib/*' <package chứa main> & echo $! > ./pid.file tail -f nohup.out ``` #v(20pt) - *stop.sh (để dừng module)* ```shell-unix-generic kill $(cat ./pid.file) ``` === Chạy thử bằng Postman Đầu tiên, ta tạo một collection trong Postman: #image("figures/postmancollection.png", height: 120pt) Bấm vào collection vừa tạo, chọn mục variables, nhập địa chỉ IP của các server chứa module `Pdf Image Extract`: #image("figures/postmanvar.png") Sau đó tạo request đến API. #image("figures/addrequest.png", height: 200pt) Khi đã có request, ta có thể nhấn vào request để chỉnh cấu hình. #image("figures/postman.png") REST API của `Pdf Image Extract` cho phép sử dụng 3 endpoints như sau: #image("figures/endpoint1.png", height: 45pt) #image("figures/endpoint2.png", height: 45pt) #image("figures/endpoint3.png", height: 45pt) Trong đó: - `{{pdf_extract_host}}/pdfextract/pdf`: tách ảnh từ PDF, đọc tuần tự. - `{{pdf_extract_host}}/pdfextract/pdf/async`: tách ảnh từ PDF, đọc song song theo trang. - `{{pdf_extract_host}}/pdfextract/pdf/para`: tách ảnh từ PDF, đọc song song theo đoạn văn. Các request đều chỉ chấp nhận body dạng Multipart Form data, với 2 tham số: - `body`: dạng chữ (tạm thời chưa có công dụng, trong tương lai có thể phát triển để truyền các cấu hình vào). - `file`: file PDF. #image("figures/postmanbody.png") Giờ ta có thể bấm nút Send để gửi request đến API. #image("figures/postmansend.png") Kết quả trả về sẽ được hiện thị như hình dưới. #image("figures/postmanres.png") #pagebreak() = Nhận xét và đánh giá == So sánh tốc độ === Phương pháp đánh giá Ta sẽ so sánh tốc độ của API khi chạy trong 3 trường hợp: - Tuần tự: Chờ OCR xong trang trước rồi mới OCR trang mới - Song song theo trang: Tách PDF thành danh sách trang, rồi OCR song song các trang. - Song song theo đoạn: Tách PDF thành danh sách trang, mỗi trang tách thành danh sách đoạn văn, rồi OCR song song các đoạn văn. Văn bản sử dụng: Các văn bản chính phủ với độ dài tăng dần. Các văn bản được lấy từ: #link("https://vanban.chinhphu.vn/") *Các bước thực hiện* Đầu tiên, ta dùng Postman để gửi tài liệu đến API, và Postman sẽ bấm giờ từ lúc gửi đến lúc nhận kết quả trả về. Ta sẽ bỏ qua thời gian thiết lập kết nối HTTP và tải kết quả xuống, mà chỉ tính thời gian từ lúc gửi yêu cầu cho tới lúc yêu cầu hoàn tất, tức chỉ tính mục `Transfer start` dưới đây: #figure( image( "figures/transferstart.PNG", height: 170pt ), caption: "Bảng tính giờ của Postman" ) Mỗi tài liệu được gửi 5 lần và kết quả cuối cùng là thời gian xử lý trung bình. API `Pdf Images Extract` chạy trên máy laptop (do thời gian xử lý không đáng kể so với việc chạy Tesseract), 2 API `Tesseract Paragraph Extract` và `Tesseract Reader` được chạy trên máy chủ đặt tại công ty FIS. #pagebreak() *Cấu hình máy chủ:* #table( columns: (auto, auto, auto), inset: 6pt, stroke: none, column-gutter: 0pt, [Mẫu máy], [ProLiant DL380 Gen10], [], [Hệ điều hành], [GNU/Linux], [], [], [CentOS 7 / RHEL 7], [], [CPU], [Tên], [Intel(R) Xeon(R) Gold 5218 CPU #symbol("@") 2.30GHz], [], [MHz], [2797], [], [Max MHz], [3900], [], [Min MHz], [1000], [], [Số nhân], [16], [], [Số luồng], [32], [RAM], [251GB] ) === Tiến hành đánh giá #let docnumber = 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/6/4771-kgvx.signed.pdf") - Số trang: 1 - Kích cỡ: 134kb #let avg(arr) = { let result = 0 for value in arr { result += value } result /= arr.len() return result } #let time1 = (1.31, 1.26, 1.31, 1.32, 1.30) #let time2 = (1.24, 1.21, 1.24, 1.59, 1.23) #let time3 = (1.42, 1.06, 0.99, 1.06, 1.05) #let avg1_1 = calc.round(avg(time1), digits: 2) #let avg2_1 = calc.round(avg(time2), digits: 2) #let avg3_1 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 1 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_1 giây - Song song theo trang: #avg2_1 giây - Song song theo đoạn: #avg3_1 giây #let docnumber = docnumber + 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/6/4691-cn.signed.pdf") - Số trang: 3 - Kích cỡ: 251kb #let time1 = (5.64, 5.58, 5.46, 5.58, 5.05) #let time2 = (2.04, 2.06, 2.01, 2.08, 2.05) #let time3 = (2.36, 2.72, 2.35, 2.42, 3.61) #let avg1_3 = calc.round(avg(time1), digits: 2) #let avg2_3 = calc.round(avg(time2), digits: 2) #let avg3_3 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 3 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_3 giây - Song song theo trang: #avg2_3 giây - Song song theo đoạn: #avg3_3 giây #let docnumber = docnumber + 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/7/877-ttg.signed.pdf") - Số trang: 6 - Kích cỡ: 317kb #let time1 = (9.10, 8.92, 9.57, 11.56, 9.12) #let time2 = (2.38, 2.22, 2.22, 2.40, 2.55) #let time3 = (2.01, 2.02, 2.10, 2.13, 2.07) #let avg1_6 = calc.round(avg(time1), digits: 2) #let avg2_6 = calc.round(avg(time2), digits: 2) #let avg3_6 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 6 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_6 giây - Song song theo trang: #avg2_6 giây - Song song theo đoạn: #avg3_6 giây #let docnumber = docnumber + 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/7/14-bggdt.signed.pdf") - Số trang: 9 - Kích cỡ: 443kb #let time1 = (16.34, 19.71, 15.62, 14.67, 13.79) #let time2 = (2.07, 2.10, 2.08, 2.08, 2.14) #let time3 = (2.96, 2.73, 2.69, 2.62, 2.73) #let avg1_9 = calc.round(avg(time1), digits: 2) #let avg2_9 = calc.round(avg(time2), digits: 2) #let avg3_9 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 9 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_9 giây - Song song theo trang: #avg2_9 giây - Song song theo đoạn: #avg3_9 giây #let docnumber = docnumber + 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/7/47-hdp.signed.pdf") - Số trang: 12 - Kích cỡ: 554kb #let time1 = (18.55, 16.81, 17.27, 16.72, 16.58) #let time2 = (2.45, 2.51, 2.46, 2.43, 2.38) #let time3 = (2.29, 2.45, 2.37, 2.32, 2.34) #let avg1_12 = calc.round(avg(time1), digits: 2) #let avg2_12 = calc.round(avg(time2), digits: 2) #let avg3_12 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 12 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_12 giây - Song song theo trang: #avg2_12 giây - Song song theo đoạn: #avg3_12 giây #let docnumber = docnumber + 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/7/869-ttg.signed.pdf") - Số trang: 13 - Kích cỡ: 502kb #let time1 = (17.49, 16.37, 15.34, 15.61, 14.97) #let time2 = (2.30, 2.28, 2.31, 2.28, 2.28) #let time3 = (5.24, 5.66, 5.50, 4.84, 5.82) #let avg1_13 = calc.round(avg(time1), digits: 2) #let avg2_13 = calc.round(avg(time2), digits: 2) #let avg3_13 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 13 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_13 giây - Song song theo trang: #avg2_13 giây - Song song theo đoạn: #avg3_13 giây #let docnumber = docnumber + 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/7/105-nq.signed.pdf") - Số trang: 16 - Kích cỡ: 891kb #let time1 = (16.27, 15.17, 15.24, 15.04, 16.04) #let time2 = (3.11, 3.11, 3.12, 3.05, 3.12) #let time3 = (3.75, 3.76, 3.84, 3.77, 3.79) #let avg1_16 = calc.round(avg(time1), digits: 2) #let avg2_16 = calc.round(avg(time2), digits: 2) #let avg3_16 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 16 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_16 giây - Song song theo trang: #avg2_16 giây - Song song theo đoạn: #avg3_16 giây #let docnumber = docnumber + 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/7/50-btc.signed.pdf") - Số trang: 20 - Kích cỡ: 797kb #let time1 = (28.22, 29.09, 28.29, 28.22, 28.27) #let time2 = (3.35, 3.19, 3.26, 3.25, 3.20) #let time3 = (6.75, 7.24, 6.80, 6.83, 6.86) #let avg1_20 = calc.round(avg(time1), digits: 2) #let avg2_20 = calc.round(avg(time2), digits: 2) #let avg3_20 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 20 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_20 giây - Song song theo trang: #avg2_20 giây - Song song theo đoạn: #avg3_20 giây #let docnumber = docnumber + 1 *Tài liệu #docnumber* - Nguồn: #link("https://datafiles.chinhphu.vn/cpp/files/vbpq/2023/7/891-bgtvt.signed.pdf") - Số trang: 23 - Kích cỡ: 850kb #let time1 = (29.91, 30.36, 30.62, 30.17, 29.21) #let time2 = (3.45, 3.27, 3.36, 3.31, 3.29) #let time3 = (9.14, 9.08, 8.43, 8.85, 8.89) #let avg1_23 = calc.round(avg(time1), digits: 2) #let avg2_23 = calc.round(avg(time2), digits: 2) #let avg3_23 = calc.round(avg(time3), digits: 2) #figure( table( columns: (auto, auto, auto, auto), rows: (auto, auto), [], [Tuần tự], [Song song theo trang], [Song song theo đoạn], [Lần 1], [#time1.at(0)], [#time2.at(0)], [#time3.at(0)], [Lần 2], [#time1.at(1)], [#time2.at(1)], [#time3.at(1)], [Lần 3], [#time1.at(2)], [#time2.at(2)], [#time3.at(2)], [Lần 4], [#time1.at(3)], [#time2.at(3)], [#time3.at(3)], [Lần 5], [#time1.at(4)], [#time2.at(4)], [#time3.at(4)], ), caption: "Thời gian xử lý văn bản 23 trang (tính bằng giây)" ) Kết quả trung bình: - Tuần tự: #avg1_23 giây - Song song theo trang: #avg2_23 giây - Song song theo đoạn: #avg3_23 giây === Kết luận Ta vẽ lại tất cả các kết quả ở trên dưới dạng đồ thị. Trục $y$ là thời gian xử lý (giây), trục $x$ là số trang của tài liệu: // #let iterdata = ( // (1, avg1_1), (3, avg1_3), (6, avg1_6), (9, avg1_9), (12, avg1_12), (13, avg1_13), (16, avg1_16), (20, avg1_20), (23, avg1_23) // ) // #let pagedata = ( // (1, avg2_1), (3, avg2_3), (6, avg2_6), (9, avg2_9), (12, avg2_12), (13, avg2_13),(16, avg2_16), (20, avg2_20), (23, avg2_23) // ) // #let paradata = ( // (1, avg3_1), (3, avg3_3), (6, avg3_6), (9, avg3_9), (12, avg3_12), (13, avg3_13),(16, avg3_16), (20, avg3_20), (23, avg3_23), // ) // #let xaxis = axis(min: 0, max: 25, step: 2, location: "bottom") // #let yaxis = axis(min: 0, max: 30, step: 2, location: "left") // #let plot_iter = plot(data: iterdata, axes: (xaxis, yaxis)) // #let iter = graph_plot(plot_iter, (100%, 40%), stroke: red, rounding: 20%, caption: "Xử lý tuần tự (đỏ), song song theo trang (xanh lá cây), song song theo đoạn (xanh da trời)") // #let plot_page = plot(data: pagedata, axes: (xaxis, yaxis)) // #let page = graph_plot(plot_page, (100%, 40%), rounding: 20%, stroke: green) // #let plot_para = plot(data: paradata, axes: (xaxis, yaxis)) // #let para = graph_plot(plot_para, (100%, 40%), rounding: 20%, stroke: blue) // #overlay((iter, para, page), (100%, 40%)) #figure( image("figures/timegraph.svg"), caption: "Thời gian của các cách xử lý" ) Đầu tiên, rõ ràng việc xử lý song song đem lại kết quả vượt trội so với xử lý tuần tự, ngay cả với tài liệu ít trang. Việc xử lý song song theo đoạn không đem lại hiệu quả tốt bằng xử lý song song theo trang. Với tài liệu ít trang, không có khác biệt đáng kể giữa 2 cách xử lý. Từ tài liệu 13 trang trở đi, thời gian chạy bắt đầu tăng dần. Việc xử lý theo trang có tăng trưởng rất nhỏ khi số trang tăng dần. Thời gian chạy trung bình cho tài liệu 1 trang là #avg2_1 giây, tài liệu 23 trang là #avg2_23 giây. Đây là phương pháp phù hợp nhất cho ứng dụng hiện tại. *Kết luận:* Phần mềm có tốc độ đủ tốt khi chạy trên server lớn. Phù hợp với việc tạo ứng dụng web. Phương pháp phù hợp nhất hiện tại là xử lý song song theo trang. #pagebreak() == Kiểm tra độ chính xác === Phương pháp đánh giá Ta kiểm tra độ chính xác bằng cách viết một API tự sinh một tập ảnh có chữ, sau đó gửi ảnh đến API `Tesseract Reader`, chờ kết quả trả về, và so sánh kết quả với chữ trong ảnh gốc. Ở phần này em chọn Python để dễ dàng xử lý ảnh và tạo biểu đồ thống kê. Ta tính độ chính xác bằng khoảng cách Levenshtein. Khoảng cách Levenshtein của 2 xâu ký tự $a$, $b$ (với độ dài $|a|$, $|b|$) được định nghĩa bằng: #figure( $ "lev"(a, b) = cases( |a| #h(110pt) "nếu" |b| = 0, |b| #h(111pt) "nếu" |a| = 0, "lev"("tail"(a), "tail"(b)) #h(35pt) "nếu" a[0] = b[0], 1 + "min" cases( "lev"("tail"(a), b), "lev"(a, "tail"(b)), "lev"("tail"(a), "tail"(b)), ) #h(8pt) "Các trường hợp còn lại" ) $, caption: "Công thức tính khoảng cách Levenshtein." ) <levendist> Trong đó: - $x[i]$ là ký tự thứ $i$ của xâu $x$ ($i in NN$) - $"tail"(x)$ là xâu ký tự bao gồm tất cả các phần tử của $x$ trừ phần tử đầu tiên ($"tail"(x) = x without x[0]$) Khoảng cách Levenshtein giữa $a$ và $b$ bằng số hành động tối thiểu đối với $a$ (bao gồm cả xóa, thêm, đổi 1 ký tự) để cho $a[i] = b[i] quad forall i in [0, space.med"max"(a, b))$. Thuật toán tính nhanh khoảng cách Levenshtein được cung cấp trong thư viện `Diff Match Patch`. Để tính tỉ lệ chính xác, ta lấy khoảng cách Levenshtein chia cho chiều dài xâu ký tự, cụ thể: Với xâu cần kiểm tra $a$ và xâu đáp án $b$, tỉ lệ chính xác của xâu $a$ ta định nghĩa bằng: #figure( $ "acc"(a, b) = "lev"(a, b) / |b| dot 100 percent $, caption: "Công thức tính độ chính xác." ) <levenacc> *Các thư viện chính sử dụng:* - `OpenCV` và `Pillow`: Thư viện xử lý ảnh. Dùng để chuyển định dạng, tạo ảnh, chuyển ảnh về `byte` để truyền qua HTTP. - `Skimage`: Xoay ảnh. - `FastAPI`: Thư viện xây dựng API, giúp dựng các API nhanh chóng và không phải cấu hình nhiều. - `Uvicorn`: Thư viện chạy web server cho API. - `Httpx`: Thư viện gửi yêu cầu HTTP. - `Diff Match Patch`: Thư viện so sánh xâu ký tự của Google, dùng để so sánh kết quả trả về với chữ trong ảnh ban đầu. #pagebreak() *Cấu trúc file:* - #text(`ocr_tester`, fill: orange, weight: "bold") - #text(`backgrounds`, fill: orange, weight: "bold") - #text(`background.png`, fill: fuchsia, weight: "bold") - #text(`custom_font`, fill: orange, weight: "bold") - #text(`arial.ttf`, fill: fuchsia, weight: "bold") - #text(`generated_test`, fill: orange, weight: "bold") - #text(`request_handler.py`, fill: eastern, weight: "bold") - #text(`tesseract_tester.py`, fill: eastern, weight: "bold") - #text(`testgen.py`, fill: eastern, weight: "bold") - #text(`words.txt`, fill: fuchsia, weight: "bold") *Mô tả* - `request_handler.py`: Lớp gửi yêu cầu HTTP - `tesseract_tester.py`: Module chính. Chạy `FastAPI`, truyền file đến `request_handler`, chờ kết quả trả về và kiểm tra kết quả. - `testgen.py`: Tự sinh chữ, và tạo ảnh có chữ đó. === Tiến hành đánh giá ==== Tạo ảnh để kiểm tra ===== Tạo chữ: Ta tạo đoạn văn bằng cách chọn ngẫu nhiên các từ trong từ điển Wiktionary. Từ điển Wiktionary được lấy từ link: #link("https://github.com/undertheseanlp/resources/tree/master/resources/DI_Vietnamese-UVD/corpus") Khi tải từ điển xuống sẽ có dạng: `{"text": "<từ>", "source": "<từ điển>"}` Ta dùng chức năng `Replace All` của Notepad++, bấm `Ctrl + F`, vào mục `Replace`, nhập `{"text": "` vào ô `Find what`, để trống ô `Replace with`, và bấm `Replace All`. Phần chữ đứng trước từ sẽ bị xóa. Sau đó làm tương tự với `", "source": "wiktionary"}`, phần chữ đứng sau từ bị xóa. #figure( table(columns: (auto, auto), [``` {"text": "1", "source": "wiktionary"} {"text": "2G", "source": "wiktionary"} {"text": "a", "source": "wiktionary"} {"text": "A", "source": "wiktionary"} {"text": "à", "source": "wiktionary"} {"text": "ả", "source": "wiktionary"} {"text": "á", "source": "wiktionary"} {"text": "Á", "source": "wiktionary"} {"text": "ạ", "source": "wiktionary"} {"text": "a bá hợi", "source": "wiktionary"} {"text": "á bí tích", "source": "wiktionary"} ```], [``` 1 2G a A à ả á Á ạ a bá hợi á bí tích ```]), caption: "Trước và sau khi dùng Replace All" ) Khi đã có từ điển như trên, có thể đưa vào `list` trong Python: ```py #Mở file từ điển và đưa vào dict_arr dictfile = "ocr_tester/words.txt" dict_arr = [] with open(dictfile, encoding="UTF-8") as df: for line in df: dict_arr.append(line[:-1]) ``` Để sinh văn bản ngẫu nhiên, ta lấy ngẫu nhiên các từ trong `list` ở trên. ```py def get_rand_word(): """ Lấy từ ngẫu nhiên trong từ điển """ return dict_arr[rd.randint(0, len(dict_arr) - 1)] def get_rand_str(max_size=50): """ Lấy string ngẫu nhiên thỏa mãn độ dài """ ret = "" while True: word = get_rand_word() if len(ret) + len(word) + 1 > max_size: return ret[:-1] else: ret = ret + get_rand_word() + " " ``` ===== Tạo ảnh Quy trình tạo ảnh như sau: *Bước 1: Tải ảnh nền.* Đầu tiên, tạo một ảnh trắng ở thư mục `backgrounds`. Ảnh này sẽ được dùng làm nền cho chữ. Vì mục tiêu chính của dự án là nhận diện chữ in, nên ta dùng nền trắng. #figure( image("figures/background.png", height: 140pt), caption: "Ảnh nền" ) *Bước 2: Tạo chữ, chia thành từng dòng.* Ghép ngẫu nhiên các từ trong từ điển thành một xâu ký tự, sao cho độ dài không vượt quá một số cố định. Sau đó cho các xâu đó vào danh sách, để khi xếp mỗi phần tử trên danh sách theo chiều dọc thì sẽ thành đoạn văn. #figure( table( ``` nam thương Sóc Trăng thiên nhiên khống chế tìm thấy phăng pha nhổ giò sa hãm giá dụ giáo thụ đồ nghề ximôkinh mất máu phải mặt nón gò găng phòng ngừa Thanh Tường đường chim phát tang ``` ), caption: "Một số xâu ký tự ngẫu nhiên" ) *Bước 3: Tạo ảnh dòng chữ.* Dùng thư viện `PIL.ImageDraw` để tạo ảnh chứa mỗi dòng chữ. #figure( image("figures/namthuong.png", width: 300pt), caption: "Ảnh tạo từ ImageDraw" ) *Bước 4: Ghép ảnh chữ vào ảnh nền.* Ghép các ảnh dòng chữ vào ảnh nền, sao cho các ảnh tạm được sắp xếp thẳng hàng theo chiều dọc để thành đoạn văn, và chữ không bị tràn ra khỏi ảnh. #figure( table( image( "figures/odf.png", height: 215pt, ), ), caption: "Ảnh nền sau khi được dán thêm các ảnh tạm" ) *Bước 5: Xoay nhẹ ảnh.* Xoay $plus.minus 0.01 "radian"$ cho giống với sai lệch của văn bản scan thông thường. #figure( table( image( "figures/rotate.png", height: 215pt )), caption: "Ảnh sau khi được xoay nhẹ" ) Việc xoay ảnh sử dụng ma trận xoay trong hệ tọa độ thuần nhất, thông qua module `transform` của thư viện `skimage`. #pagebreak() ==== OCR và kiểm tra kết quả Ta gửi liên tiếp 50 ảnh được tạo tự động cho `Tesseract Reader`, lấy kết quả trả về của mỗi ảnh, so sánh với xâu gốc, và tính độ chính xác trung bình. #let acc_result = csv("csv/result.csv") #let acc_1st = acc_result.slice(0, 25) #let acc_2nd = acc_result.slice(25, 50) #figure( grid( columns: (auto, auto), table( columns: (auto, auto, auto, auto), [Stt], [$"lev"(a, b)$], [$|b|$], [acc$(a)$], ..acc_1st.flatten() ), table( columns: (auto, auto, auto, auto), [Stt], [$"lev"(a, b)$], [$|b|$], [acc$(a)$], ..acc_2nd.flatten() ), column-gutter: 20pt ), caption: "Kết quả chạy OCR trên 50 ảnh ngẫu nhiên" ) Trong đó: - a: Xâu kết quả trả về của Tesseract - b: Xâu gốc trong ảnh - lev(a, b): Khoảng cách Levenshtein giữa 2 xâu a và b, tính theo công thức ở @levendist - |b|: Độ dài xâu b - acc(a, b): Độ chính xác của xâu a (dạng %), tính theo công thức ở @levenacc #let tess_accuracy = 95.38017574591704 *Độ chính xác trung bình:* #calc.round(tess_accuracy, digits: 2)% - Số lần nhầm chữ: 588 - Số lần thừa chữ: 1258 - Số lần thiếu chữ: 47 *Phân bố độ chính xác:* #figure( image("figures/tess_accuracy.png", height: 270pt), caption: "Phân bố độ chính xác của Tesseract", ) *Các lỗi phổ biến:* #figure( image("figures/error_histogram.png", height: 270pt), caption: "Các chữ nhiều lỗi trong 50 lần chạy" ) <err_histogram> === Kết luận #let newline_count = 683 #let total_errors = 588 + 1258 + 47 #let newline_percentage = calc.round((newline_count * 100 / total_errors), digits: 2) #let total_chars = 0 #for entry in acc_result { total_chars += int(entry.at(2)) } #let adjusted_acc = 100 - (100 * (total_errors - newline_count) / total_chars) Trong 50 lần chạy, Tesseract hầu như đều đạt độ chính xác cao. Trong đó 38/50 lần chạy đạt độ chính xác trên 95%. Lỗi phổ biến nhất là lỗi về dấu xuống dòng (newline trong @err_histogram), chiếm #newline_count trên tổng số #total_errors lỗi (#newline_percentage%), tuy nhiên khi xem kết quả, có thể thấy hầu hết là lỗi xuống dòng 2 lần thay vì 1 lần, nên điều này không ảnh hưởng đến nội dung chính của văn bản. Nếu bỏ qua lỗi về xuống dòng, độ chính xác trung bình từ #calc.round(tess_accuracy, digits: 2)% trở thành #calc.round(adjusted_acc, digits: 2)% #figure( image("figures/newline.png"), caption: "Hầu hết lỗi xuống dòng là xuống dòng 2 lần" ) Các lỗi còn lại hầu hết là các ký tự có dấu trong tiếng Việt, tiêu biểu có: - ắ: 129 lỗi - â: 76 lỗi - ê: 70 lỗi - ỗ: 63 lỗi - ô: 52 lỗi - ầ: 50 lỗi - ề: 50 lỗi Các ký tự này đều có 1 hoặc nhiều dấu thanh. Như đã nói ở @chinhta, các dấu thanh trong tiếng Việt rất dễ gây nhầm lẫn nếu độ phân giải không đủ. *Đề xuất:* Một module kiểm tra chính tả có lẽ sẽ làm tăng độ chính xác của Tesseract. *Kết luận:* Tesseract có độ chính xác cao đối với văn bản thông thường. Trong 50 lần chạy thử, hầu hết các kết quả đều có độ chính xác cao, chỉ cá biệt 2 trường hợp có độ chính xác 77%, 81%. Độ chính xác trung bình là #calc.round(tess_accuracy, digits: 2)%, nếu bỏ qua xuống dòng thừa thì độ chính xác là #calc.round(adjusted_acc, digits: 2)%. Phần lớn lỗi là ở ký tự có dấu, có thể sẽ được cải thiện nếu có kiểm tra chính tả cơ bản. #pagebreak() = Tài liệu tham khảo + Tesseract OCR: https://tesseract-ocr.github.io/tessdoc/ + Tesseract Advanced API: https://tesseract-ocr.github.io/tessapi/3.x/a01281.html + Leptonica: http://www.leptonica.org/ + Leptonica API: https://tpgit.github.io/Leptonica/ + Spring Boot: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/ + JavaCPP: http://bytedeco.org/ + Tesseract benchmark: https://research.aimultiple.com/ocr-accuracy/ + PDFBox: https://pdfbox.apache.org/ + Khoảng cách Levenshtein: - https://www.educative.io/answers/the-levenshtein-distance-algorithm - https://en.wikipedia.org/wiki/Levenshtein_distance + Diff Match Patch: https://github.com/google/diff-match-patch #pagebreak() #align( center, text( "K<NAME> - Cơ - Tin học Trường ĐH Khoa học Tự nhiên - ĐHQGHN", weight: 900, ), ) #v(40pt) #align( center, text( "NHẬN XÉT THỰC TẬP", weight: 900, size: 20pt, ), ) #v(20pt) #align(left, grid( columns: (auto, auto), column-gutter: 70pt, row-gutter: 15pt, [Công ty thực tập:], [CÔNG TY TNHH HỆ THỐNG THÔNG TIN FPT], [Người hướng dẫn:], [Lê Huy Toàn], [Thời gian thực tập:], [15/05/2023 - 04/08/2023], [Họ và tên sinh viên:], [Phạm Hoàng Hải], ) ) #v(30pt) 1. Ý thức làm việc của sinh viên: ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ 2. Khả năng làm việc/học hỏi: ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ 3. Mức độ hoàn thành những nhiệm vụ được giao: ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ #pagebreak() 4. Xác nhận công việc được báo cáo có đúng như công việc được giao? ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ 5. Những vẫn đề cần góp ý với thực tập sinh/ nhà trường để công việc có thể tiến hành tốt hơn: ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ ........................................................................................................................................................................................ 6. Điểm đánh giá (theo thang điểm 10): ........................................................................................................................................................................................ #v(50pt) #align( center, grid( columns: (auto, auto), column-gutter: 100pt, row-gutter: 20pt, [], [_Hà Nội, ngày ...... tháng 08 năm 2023_], [*Xác nhận của người đánh giá*], [*Xác nhận của doanh nghiệp*], [], [(kí và đóng dấu)], ) )
https://github.com/Tobias-Wennberg/typst-gramar-lsp
https://raw.githubusercontent.com/Tobias-Wennberg/typst-gramar-lsp/main/README.md
markdown
Apache License 2.0
This project's goal is to be a comprehensive grammar lsp server for the typst markup language. *THIS PROJECT IS WORK IN PROGRESS. ANY FUNCTIONALITY IS COINCIDENTAL*
https://github.com/SkiFire13/eh-presentation-shellcode
https://raw.githubusercontent.com/SkiFire13/eh-presentation-shellcode/master/task1.c.typ
typst
#import "@preview/polylux:0.3.1": * #import "unipd.typ": * #new-section[ Task 1.c ] #slide[ - Extend Task 1.b to execute: #align(center, `/bin/sh -c "ls -la"`) - Need to add the arguments to the `argv` list: #align(center, ``` argv[3] = 0 argv[2] = "ls -la" argv[1] = "-c" argv[0] = "/bin/sh" ```) ] #new-section[ Task 1.c: Solution ] #slide[ #let left = ```asm ; "/bin/sh" mov eax, "#/sh" shr eax, 8 push eax push "/bin" mov ebx, esp ; "-c" mov eax, "##-c" shr eax, 16 push eax ; "ls -la" mov eax, "##la" shr eax, 16 push eax push "ls -" ``` #let right = ```asm ; Construct the argument array argv mov ecx, esp xor eax, eax push eax ; argv[3] = 0 push ecx ; argv[2] points "ls -la" lea eax, [ecx + 8] push eax ; argv[1] points "-c" lea eax, [ecx + 12] push eax ; argv[0] points "/bin/sh" mov ecx, esp ; For environment variable xor edx, edx ; No env variables ; Invoke execve() xor eax, eax ; eax = 0x00000000 mov al, 0x0b ; eax = 0x0000000b int 0x80 ``` #text(size: 18pt, grid(columns: (1fr, 1.5fr), left, right)) ] // #let chars = (`l`, `s`, ` `, `-`, `l`, `a`, `\0`, `\0`, `-`, `c`, `\0`, `\0`, `/`, `b`, `i`, `n`, `/`, `s`, `h`, `\0`) // #grid(columns: (auto,) * chars.len(), ..chars.map(it => rect(width: 1.5em, height: 1.5em, align(center + horizon, it)))) // TODO: Show stack? #slide[ #align(center, v(-10%) + scale(x: 90%, y: 90%, image("exe1c.png"))) ] #slide[ #place(center + horizon, v(20%) + scale(x: 85%, y: 85%, image("obj1c.png"))) ]
https://github.com/skriptum/diatypst
https://raw.githubusercontent.com/skriptum/diatypst/main/template/main.typ
typst
MIT License
#import "@preview/diatypst:0.2.0": * #show: slides.with( title: "Diatypst", // Required subtitle: "easy slides in typst", date: "01.07.2024", authors: ("<NAME>"), // Optional Styling ratio: 16/9, layout: "medium", title-color: green.darken(60%), footer: true, counter: true, toc: true, ) #outline() = First Section == First Slide #lorem(20) / *Term*: Definition
https://github.com/hitszosa/universal-hit-thesis
https://raw.githubusercontent.com/hitszosa/universal-hit-thesis/main/harbin/bachelor/pages/cover.typ
typst
MIT License
#import "../../../common/theme/type.typ": 字体, 字号 #import "../config/constants.typ": current-date #import "../utils/states.typ": thesis-info-state #let cover-primary( title-cn: "", title-en: "", author: "", student-id: "", supervisor: "", profession: "", collage: "", reply-date: "", institute: "", year: current-date.year(), month: current-date.month(), day: current-date.day(), ) = { align(center)[ #let space-scale-ratio = 1.25 #v(字号.小四 * 6 * space-scale-ratio) #text(size: 字号.小一, font: 字体.宋体, weight: "bold")[*本科毕业论文(设计)*] #v(字号.小四 * 2 * space-scale-ratio) #text(size: 字号.二号, font: 字体.黑体)[#title-cn] #v(字号.小四 * 2 * space-scale-ratio) #par(justify: false)[ #text(size: 字号.小二, font: 字体.宋体, weight: "bold")[#title-en] ] #v(字号.小四 * 1 * space-scale-ratio) #v(字号.二号 * 2 * space-scale-ratio) #align(center)[ #text(size: 字号.小二, font: 字体.宋体, weight: "bold")[ #author ] ] #v(字号.小二 * 2 * space-scale-ratio) #v(字号.小四 * 6 * space-scale-ratio) #align(center)[ #text(size: 字号.小二, font: 字体.楷体, weight: "bold")[#institute] #text(size: 字号.小二, font: 字体.宋体, weight: "bold")[ #[#year]年#[#month]月 ] ] ] } #let cover-secondary( title-cn: "", author: "", student-id: "", supervisor: "", profession: "", collage: "", institute: "", year: current-date.year(), month: current-date.month(), day: current-date.day(), ) = { align(center)[ #let space-scale-ratio = 1.4 #align(right)[ #text(size: 字号.四号, font: 字体.宋体)[密级:公开] ] #v(字号.小四 * 3 * space-scale-ratio) #text(size: 字号.小二, font: 字体.宋体)[*本科毕业论文(设计)*] #v(字号.小四 * 2 * space-scale-ratio) #text(size: 字号.二号, font: 字体.黑体)[#title-cn] #v(字号.小四 * 1 * space-scale-ratio) #v(字号.二号 * 4 * space-scale-ratio) // #v(字号.小四 * space-scale-ratio) #let cover-info-key(content) = { align(right)[ #text(size: 字号.四号, font: 字体.黑体)[#content] ] } #let cover-info-colon(content) = { align(left)[ #text(size: 字号.四号, font: 字体.黑体)[#content] ] } #let cover-info-value(content) = { align(left)[ #text(size: 字号.四号, font: 字体.宋体)[#content] ] } #let base-space = 0.8 #let key-width = 字号.四号 * (4 + base-space * 3) #grid( columns: (auto, 1em, auto), rows: (字号.四号, 字号.四号), row-gutter: 1.5em, cover-info-key(text(spacing: (key-width - 3em) / 2)[本 科 生]), cover-info-colon[:], cover-info-value(author), cover-info-key(text(spacing: (key-width - 2em))[学 号]), cover-info-colon[:], cover-info-value(student-id), cover-info-key(text(spacing: base-space * 1em)[指 导 教 师]), cover-info-colon[:], cover-info-value(supervisor), cover-info-key(text(spacing: (key-width - 2em))[专 业]), cover-info-colon[:], cover-info-value(profession), cover-info-key(text(spacing: (key-width - 2em))[学 院]), cover-info-colon[:], cover-info-value(collage), cover-info-key(text(spacing: base-space * 1em)[答 辩 日 期]), cover-info-colon[:], cover-info-value([#[#year]年#[#month]月]), cover-info-key(text(spacing: (key-width - 2em))[学 校]), cover-info-colon[:], cover-info-value(institute), ) ] } #let cover() = { context { let thesis-info = thesis-info-state.get() cover-primary( title-cn: thesis-info.at("title-cn"), title-en: thesis-info.at("title-en"), author: thesis-info.at("author"), student-id: thesis-info.at("student-id"), supervisor: thesis-info.at("supervisor"), profession: thesis-info.at("profession"), collage: thesis-info.at("collage"), institute: thesis-info.at("institute"), year: thesis-info.at("year"), month: thesis-info.at("month"), day: thesis-info.at("day"), ) pagebreak() cover-secondary( title-cn: thesis-info.at("title-cn"), author: thesis-info.at("author"), student-id: thesis-info.at("student-id"), supervisor: thesis-info.at("supervisor"), profession: thesis-info.at("profession"), collage: thesis-info.at("collage"), institute: thesis-info.at("institute"), year: thesis-info.at("year"), month: thesis-info.at("month"), day: thesis-info.at("day"), ) } }
https://github.com/stuxf/basic-typst-resume-template
https://raw.githubusercontent.com/stuxf/basic-typst-resume-template/main/README.md
markdown
The Unlicense
# Basic Resume <div align="center">Version 0.1.3</div> This is a template for a simple resume. It is intended to be used as a good starting point for quickly crafting a standard resume that will properly be parsed by ATS systems. Inspiration is taken from [Jake's Resume](https://github.com/jakegut/resume) and [guided-resume-starter-cgc](https://typst.app/universe/package/guided-resume-starter-cgc/). I'm currently a college student and was unable to find a Typst resume template that fit my needs, so I wrote my own. I hope this template can be useful to others as well. ## Sample Resume ![example resume](https://raw.githubusercontent.com/stuxf/basic-typst-resume-template/main/example-resume.png) ## Quick Start A barebones resume looks like this, which you can use to get started. ```typst #import "@preview/basic-resume:0.1.3": * // Put your personal information here, replacing mine #let name = "<NAME>" #let location = "San Diego, CA" #let email = "<EMAIL>" #let github = "github.com/stuxf" #let linkedin = "linkedin.com/in/stuxf" #let phone = "+1 (xxx) xxx-xxxx" #let personal-site = "stuxf.dev" #show: resume.with( author: name, // All the lines below are optional. // For example, if you want to to hide your phone number: // feel free to comment those lines out and they will not show. location: location, email: email, github: github, linkedin: linkedin, phone: phone, personal-site: personal-site, accent-color: "#26428b", font: "New Computer Modern", ) /* * Lines that start with == are formatted into section headings * You can use the specific formatting functions if needed * The following formatting functions are listed below * #edu(dates: "", degree: "", gpa: "", institution: "", location: "") * #work(company: "", dates: "", location: "", title: "") * #project(dates: "", name: "", role: "", url: "") * #extracurriculars(activity: "", dates: "") * There are also the following generic functions that don't apply any formatting * #generic-two-by-two(top-left: "", top-right: "", bottom-left: "", bottom-right: "") * #generic-one-by-two(left: "", right: "") */ == Education #edu( institution: "Harvey Mudd College", location: "Claremont, CA", dates: dates-helper(start-date: "Aug 2023", end-date: "May 2027"), degree: "Bachelor's of Science, Computer Science and Mathematics", ) - Cumulative GPA: 4.0\/4.0 | Dean's List, <NAME> Merit Scholarship, National Merit Scholarship - Relevant Coursework: Data Structures, Program Development, Microprocessors, Abstract Algebra I: Groups and Rings, Linear Algebra, Discrete Mathematics, Multivariable & Single Variable Calculus, Principles and Practice of Comp Sci == Work Experience #work( title: "Subatomic Shepherd and Caffeine Connoisseur", location: "Atomville, CA", company: "Microscopic Circus, Schrodinger's University", dates: dates-helper(start-date: "May 2024", end-date: "Present"), ) - more bullet points go here // ... more headers and stuff below ```
https://github.com/cadojo/correspondence
https://raw.githubusercontent.com/cadojo/correspondence/main/src/hermes/src/report.typ
typst
MIT License
// // Article Formats // #import "../../options/options.typ": * #import "../../rolo/rolo.typ": * #let builtin-outline = outline #let report( title: none, author: author(), date: datetime.today().display("[month repr:long] [day], [year]"), theme: black, header: none, footer: none, abstract: none, titlepage: none, outline: true, content, ) = { set text(12pt, font: "New Computer Modern") show raw: set text(font: "New Computer Modern Mono") set par(justify: true) set heading(numbering: "1.1 ", supplement: [Section]) show heading: h => pad(bottom: 0.25em, h) show heading.where(level: 1): set heading(supplement: [Chapter]) show heading.where(level: 1): h => { if h.outlined { pagebreak(weak: true) text(32pt, theme, "Chapter " + counter(heading).display()) v(2em) text(32pt, theme, h.body) v(1fr) } else { align(center, text(32pt, theme, h)) } } show heading.where(level: 2): h => { set text(18pt) locate( loc => { let count = counter(heading).at(loc).at(1) if count == 1 { v(2fr) pagebreak(weak: true) } } ) h } show heading.where(level: 3): set text(14pt) show builtin-outline.entry.where( level: 1 ): e => { v(0.65em, weak: false) link(e.element.location(), text(18pt, weight: "bold", e.body)) h(1fr) e.page v(0.65em, weak: true) } set page( paper: "us-letter", header: header, margin: 1in, footer: if some(footer) { footer } else { set text(12pt, weight: "regular", rgb(75,75,75)) place(left, align(left, title)) place(right, align(right, counter(page).display("1 / 1", both: true))) }, ) let titleblock = { v(1fr) align(center, text(theme, size: 32pt, weight: "bold", smallcaps(title))) if some(date) { align(center, date) } if some(author) { pad( 1em, if type(author) == "array" { stack(dir: ltr, ..author.map(authorblock)) } else if type(author) == "string" { author } else { authorblock(author) } ) } if some(abstract) { pad(top: 1em, bottom: 1em, left: 5%, right: 5%, text(style: "italic", abstract)) } v(1fr) if some(titlepage) { titlepage } pagebreak() } titleblock if outline { builtin-outline(title: "Table of Contents", indent: auto, depth: 2) } content }
https://github.com/kochetov-dmitrij/personal-page
https://raw.githubusercontent.com/kochetov-dmitrij/personal-page/main/cv/pdf/main.typ
typst
#let configuration = yaml("configuration.yaml") #let settings = yaml("settings.yaml") #show link: set text(blue) #set page( paper: "a4", margin: ( top: 1.5cm, bottom: 1cm, ) ) #show heading: h => [ #set text( size: eval(settings.font.size.heading_large), font: settings.font.general ) #h ] #let sidebarSection = {[ #par(justify: true)[ #par[ #set text( size: eval(settings.font.size.contacts), font: settings.font.minor_highlight, ) Email: #link("mailto:" + configuration.contacts.email) \ Phone: #link("tel:" + configuration.contacts.phone) \ LinkedIn: #link(configuration.contacts.linkedin.url)[#configuration.contacts.linkedin.displayText] \ GitHub: #link(configuration.contacts.github.url)[#configuration.contacts.github.displayText] \ Website: #link(configuration.contacts.website.url)[#configuration.contacts.website.displayText] \ Telegram: #link(configuration.contacts.telegram.url)[#configuration.contacts.telegram.displayText] \ #configuration.contacts.address ] #line(length: 100%) ] = Summary #par[ #set text( eval(settings.font.size.education_description), font: settings.font.minor_highlight, ) #configuration.summary ] = Education #{ for place in configuration.education [ #par[ #set text( size: eval(settings.font.size.heading), font: settings.font.general ) #{ if "to" in place and "from" in place [ #place.from – #place.to \ ] else if "arbitrary_interval" in place [ #place.arbitrary_interval ] } #link(place.place.link)[#place.place.name] ] #par[ #set text( eval(settings.font.size.education_description), font: settings.font.minor_highlight, ) #{ let description_items = () if "degree" in place and "major" in place [ #description_items.push(place.degree + " " + place.major) ] if "track" in place [ #description_items.push(place.track + " " + "track") ] if "note" in place [ #description_items.push(place.note) ] if "location" in place [ #description_items.push(place.location) ] description_items.join("\n") } ] ] } = Skills #{ for skill in configuration.skills [ #par[ #set text( size: eval(settings.font.size.description), ) #set text( // size: eval(settings.font.size.tags), font: settings.font.minor_highlight, ) *#skill.name* #linebreak() #skill.items.join(" • ") ] ] } ]} #let mainSection = {[ // #par[ // #set align(center) // #figure( // image("images/Kodak 20 Zanvoort Lumi.jpg", width: 6em), // placement: top, // ) // ] #par[ #set text( size: eval(settings.font.size.heading_huge), font: settings.font.general, ) *#configuration.contacts.name* ] #par[ #set text( size: eval(settings.font.size.heading), font: settings.font.minor_highlight, top-edge: 0pt ) #configuration.contacts.title ] = Experience #{ for job in configuration.jobs [ #par(justify: false)[ #set text( size: eval(settings.font.size.heading), font: settings.font.general ) *#job.position* #link(job.company.link)[\@ #job.company.name] \ #job.from – #job.to ] #v(-0.5em) #par( justify: false, leading: eval(settings.paragraph.leading) )[ #set text( size: eval(settings.font.size.description), font: settings.font.general ) #{ for point in job.description [ #h(0.1cm) – #point \ ] } ] #par( justify: true, leading: eval(settings.paragraph.leading), )[ #set text( size: eval(settings.font.size.tags), font: settings.font.minor_highlight ) #{ let tag_line = job.tags.join(" • ") tag_line } ] ] } = Projects #{ for project in configuration.projects [ #par( justify: true, leading: eval(settings.paragraph.leading) )[ #v(0.5em) #block(spacing: 0.3em)[ #set text( size: eval(settings.font.size.heading), font: settings.font.general ) - #{if "year" in project {project.year + " "}}#link(project.project.link)[#project.project.name] ] #par[ #set text( size: eval(settings.font.size.description), font: settings.font.general ) #project.description ] ] ] } = Hackathons and CTFs #{ for hack in configuration.hackathons [ #par( justify: true, leading: eval(settings.paragraph.leading) )[ #v(0.5em) #block(spacing: 0.3em)[ #set text( size: eval(settings.font.size.heading), font: settings.font.general ) - #hack.year #link(hack.hackathon.link)[#hack.hackathon.name] ] #par[ #set text( size: eval(settings.font.size.description), font: settings.font.general ) #hack.description ] ] ] } ]} #{ grid( columns: (3fr, 5fr), column-gutter: 3em, sidebarSection, mainSection, ) }
https://github.com/typst/packages
https://raw.githubusercontent.com/typst/packages/main/packages/preview/hydra/0.2.0/src/util.typ
typst
Apache License 2.0
#import "@preview/oxifmt:0.2.0" as oxi // assert the element is of the given typ #let assert-element(element, func, message: none, name: "element") = { assert.eq(type(element), content, message: if message != none { message } else { oxi.strfmt("`{}` must be content, was `{}`", name , element) } ) assert.eq(element.func(), func, message: if message != none { message } else { oxi.strfmt("`{}` must be a `{}`", name, func) } ) } // split a selector into a pair of selector and post filter #let into-sel-filter-pair(sel, name: "sel") = { if type(sel) in (selector, function) { (selector(sel), (_, _) => true) } else if ( type(sel) == array and sel.len() == 2 and type(sel.at(0)) in (selector, function) and type(sel.at(1)) == function ) { let (sel, func) = sel (selector(sel), func) } else { panic(oxi.strfmt("`{}` must be a selector or a selector and filter function", name)) } } // taken from `page.rs` #let page-sizes = ( // ---------------------------------------------------------------------- // // ISO 216 A Series a0: (w: 841.0mm, h: 1189.0mm), a1: (w: 594.0mm, h: 841.0mm), a2: (w: 420.0mm, h: 594.0mm), a3: (w: 297.0mm, h: 420.0mm), a4: (w: 210.0mm, h: 297.0mm), a5: (w: 148.0mm, h: 210.0mm), a6: (w: 105.0mm, h: 148.0mm), a7: (w: 74.0mm, h: 105.0mm), a8: (w: 52.0mm, h: 74.0mm), a9: (w: 37.0mm, h: 52.0mm), a10: (w: 26.0mm, h: 37.0mm), a11: (w: 18.0mm, h: 26.0mm), // ISO 216 B Series iso-b1: (w: 707.0mm, h: 1000.0mm), iso-b2: (w: 500.0mm, h: 707.0mm), iso-b3: (w: 353.0mm, h: 500.0mm), iso-b4: (w: 250.0mm, h: 353.0mm), iso-b5: (w: 176.0mm, h: 250.0mm), iso-b6: (w: 125.0mm, h: 176.0mm), iso-b7: (w: 88.0mm, h: 125.0mm), iso-b8: (w: 62.0mm, h: 88.0mm), // ISO 216 C Series iso-c3: (w: 324.0mm, h: 458.0mm), iso-c4: (w: 229.0mm, h: 324.0mm), iso-c5: (w: 162.0mm, h: 229.0mm), iso-c6: (w: 114.0mm, h: 162.0mm), iso-c7: (w: 81.0mm, h: 114.0mm), iso-c8: (w: 57.0mm, h: 81.0mm), // DIN D Series (extension to ISO) din-d3: (272.0mm, 385.0mm), din-d4: (192.0mm, 272.0mm), din-d5: (136.0mm, 192.0mm), din-d6: ( 96.0mm, 136.0mm), din-d7: ( 68.0mm, 96.0mm), din-d8: ( 48.0mm, 68.0mm), // SIS (used in academia) sis-g5: (w: 169.0mm, h: 239.0mm), sis-e5: (w: 115.0mm, h: 220.0mm), // ANSI Extensions ansi-a: (w: 216.0mm, h: 279.0mm), ansi-b: (w: 279.0mm, h: 432.0mm), ansi-c: (w: 432.0mm, h: 559.0mm), ansi-d: (w: 559.0mm, h: 864.0mm), ansi-e: (w: 864.0mm, h: 1118.0mm), // ANSI Architectural Paper arch-a: (w: 229.0mm, h: 305.0mm), arch-b: (w: 305.0mm, h: 457.0mm), arch-c: (w: 457.0mm, h: 610.0mm), arch-d: (w: 610.0mm, h: 914.0mm), arch-e1: (w: 762.0mm, h: 1067.0mm), arch-e: (w: 914.0mm, h: 1219.0mm), // JIS B Series jis-b0: (w: 1030.0mm, h: 1456.0mm), jis-b1: (w: 728.0mm, h: 1030.0mm), jis-b2: (w: 515.0mm, h: 728.0mm), jis-b3: (w: 364.0mm, h: 515.0mm), jis-b4: (w: 257.0mm, h: 364.0mm), jis-b5: (w: 182.0mm, h: 257.0mm), jis-b6: (w: 128.0mm, h: 182.0mm), jis-b7: (w: 91.0mm, h: 128.0mm), jis-b8: (w: 64.0mm, h: 91.0mm), jis-b9: (w: 45.0mm, h: 64.0mm), jis-b10: (w: 32.0mm, h: 45.0mm), jis-b11: (w: 22.0mm, h: 32.0mm), // SAC D Series sac-d0: (w: 764.0mm, h: 1064.0mm), sac-d1: (w: 532.0mm, h: 760.0mm), sac-d2: (w: 380.0mm, h: 528.0mm), sac-d3: (w: 264.0mm, h: 376.0mm), sac-d4: (w: 188.0mm, h: 260.0mm), sac-d5: (w: 130.0mm, h: 184.0mm), sac-d6: (w: 92.0mm, h: 126.0mm), // ISO 7810 ID iso-id-1: (w: 85.6mm, h: 53.98mm), iso-id-2: (w: 74.0mm, h: 105.0mm), iso-id-3: (w: 88.0mm, h: 125.0mm), // ---------------------------------------------------------------------- // // Asia asia-f4: (w: 210.0mm, h: 330.0mm), // Japan jp-shiroku-ban-4: (w: 264.0mm, h: 379.0mm), jp-shiroku-ban-5: (w: 189.0mm, h: 262.0mm), jp-shiroku-ban-6: (w: 127.0mm, h: 188.0mm), jp-kiku-4: (w: 227.0mm, h: 306.0mm), jp-kiku-5: (w: 151.0mm, h: 227.0mm), jp-business-card: (w: 91.0mm, h: 55.0mm), // China cn-business-card: (w: 90.0mm, h: 54.0mm), // Europe eu-business-card: (w: 85.0mm, h: 55.0mm), // French Traditional (AFNOR) fr-tellière: (w: 340.0mm, h: 440.0mm), fr-couronne-écriture: (w: 360.0mm, h: 460.0mm), fr-couronne-édition: (w: 370.0mm, h: 470.0mm), fr-raisin: (w: 500.0mm, h: 650.0mm), fr-carré: (w: 450.0mm, h: 560.0mm), fr-jésus: (w: 560.0mm, h: 760.0mm), // United Kingdom Imperial uk-brief: (w: 406.4mm, h: 342.9mm), uk-draft: (w: 254.0mm, h: 406.4mm), uk-foolscap: (w: 203.2mm, h: 330.2mm), uk-quarto: (w: 203.2mm, h: 254.0mm), uk-crown: (w: 508.0mm, h: 381.0mm), uk-book-a: (w: 111.0mm, h: 178.0mm), uk-book-b: (w: 129.0mm, h: 198.0mm), // Unites States us-letter: (w: 215.9mm, h: 279.4mm), us-legal: (w: 215.9mm, h: 355.6mm), us-tabloid: (w: 279.4mm, h: 431.8mm), us-executive: (w: 84.15mm, h: 266.7mm), us-foolscap-folio: (w: 215.9mm, h: 342.9mm), us-statement: (w: 139.7mm, h: 215.9mm), us-ledger: (w: 431.8mm, h: 279.4mm), us-oficio: (w: 215.9mm, h: 340.36mm), us-gov-letter: (w: 203.2mm, h: 266.7mm), us-gov-legal: (w: 215.9mm, h: 330.2mm), us-business-card: (w: 88.9mm, h: 50.8mm), us-digest: (w: 139.7mm, h: 215.9mm), us-trade: (w: 152.4mm, h: 228.6mm), // ---------------------------------------------------------------------- // // Other newspaper-compact: (w: 280.0mm, h: 430.0mm), newspaper-berliner: (w: 315.0mm, h: 470.0mm), newspaper-broadsheet: (w: 381.0mm, h: 578.0mm), presentation-16-9: (w: 297.0mm, h: 167.0625mm), presentation-4-3: (w: 280.0mm, h: 210.0mm), )
https://github.com/liuguangxi/erdos
https://raw.githubusercontent.com/liuguangxi/erdos/master/Problems/typstdoc/figures/p97.typ
typst
#import "@preview/cetz:0.2.1" #cetz.canvas(length: 0.7pt, { import cetz.draw: * line((0, 0), (173.32, 0), (103.95, 149.10), close: true) line((98.19, 49.37), (0, 0)) line((98.19, 49.37), (173.32, 0)) line((98.19, 49.37), (103.95, 149.10)) content((103, 158), $A$) content((181, -5), $B$) content((-8, -5), $C$) content((107, 57), $D$) content((86, -5), $a$) content((45, 75), $b$) content((146, 75), $c$) content((108, 95), $u$) content((135, 35), $v$) content((50, 35), $w$) let os = 260 line((0+os, 0), (299.7+os, 0), (149.85+os, 259.55), close: true) line((144.85+os, 95.18), (0+os, 0)) line((144.85+os, 95.18), (299.7+os, 0)) line((144.85+os, 95.18), (149.85+os, 259.55, 0)) content((-8+os, -5), $P$) content((308+os, -5), $Q$) content((150+os, 268), $R$) content((156+os, 104), $M$) content((150+os, -5), $x$) content((68+os, 135), $x$) content((234+os, 135), $x$) content((68+os, 56), $a$) content((226+os, 56), $b$) content((154+os, 160), $c$) })
https://github.com/jonaspleyer/peace-of-posters
https://raw.githubusercontent.com/jonaspleyer/peace-of-posters/main/layouts.typ
typst
MIT License
#let _default-layout = ( "spacing": 1.2em, ) #let layout-a0 = _default-layout + ( "paper": "a0", "size": (841mm, 1188mm), "body-size": 33pt, "heading-size": 50pt, "title-size": 75pt, "subtitle-size": 60pt, "authors-size": 50pt, "keywords-size": 40pt, ) #let layout-a1 = _default-layout + ( "paper": "a1", "size": (594mm, 841mm), "body-size": 27pt, "heading-size": 41pt, "title-size": 61pt, "subtitle-size": 49pt, "authors-size": 41pt, "keywords-size": 33pt, ) #let layout-a2 = _default-layout + ( "paper": "a2", "size": (420mm, 594mm), "body-size": 20pt, "heading-size": 31pt, "title-size": 47pt, "subtitle-size": 38pt, "authors-size": 31pt, "keywords-size": 25pt, ) #let layout-a3 = _default-layout + ( "paper": "a3", "size": (297mm, 420mm), "body-size": 14pt, "heading-size": 22pt, "title-size": 32pt, "subtitle-size": 26pt, "authors-size": 22pt, "keywords-size": 18pt, ) #let layout-a4 = _default-layout + ( "paper": "a4", "size": (210mm, 297mm), "body-size": 8pt, "heading-size": 12pt, "title-size": 18pt, "subtitle-size": 15pt, "authors-size": 12pt, "keywords-size": 10pt, ) /// The default layout is for an a0 poster #let _state-poster-layout = state("poster-layout", layout-a0) #let update-poster-layout(..args) = { for (arg, val) in args.named() { _state-poster-layout.update(pt => { pt.insert(arg, val) pt }) } } #let set-poster-layout(layout) = { // TODO match for strings such as "a0" "layout-a0" and so on _state-poster-layout.update(pt => { pt=layout pt }) } #let poster-layout(layout: layout-a0, ..args, body) = { // Define page size set page(paper: args.named().at("paper", default: layout.at("paper", default: layout-a0.at("paper")))) // Set default text size set text(size: args.named().at("body-size", default: layout.at("body-size", default: layout-a0.at("spacing")))) // Set spacing between blocks. // We also want to adjust the gutter between columns set block(spacing: args.named().at("spacing", default: layout.at("spacing", default: layout-a0.at("spacing")))) set columns(gutter: args.named().at("spacing", default: layout.at("spacing", default: layout-a0.at("spacing")))) set-poster-layout(layout) update-poster-layout(..args) body } // TEMPLATES // See https://typst.app/docs/tutorial/making-a-template/ #let a0-poster(doc) = [ #set page("a0", margin: 1cm) #set text(font: "Arial", size: layout-a0.at("body-size")) #let box-spacing = 1.2em #set columns(gutter: box-spacing) #set block(spacing: box-spacing) #set-poster-layout(layout-a0) #update-poster-layout(spacing: box-spacing) #doc ] #let a1-poster(doc) = [ #set page("a1", margin: 1cm) #set text(font: "Arial", size: layout-a1.at("body-size")) #let box-spacing = 1.2em #set columns(gutter: box-spacing) #set block(spacing: box-spacing) #set-poster-layout(layout-a1) #update-poster-layout(spacing: box-spacing) #doc ] #let a2-poster(doc) = [ #set page("a2", margin: 1cm) #set text(font: "Arial", size: layout-a2.at("body-size")) #let box-spacing = 1.2em #set columns(gutter: box-spacing) #set block(spacing: box-spacing) #set-poster-layout(layout-a2) #update-poster-layout(spacing: box-spacing) #doc ] #let a3-poster(doc) = [ #set page("a3", margin: 1cm) #set text(font: "Arial", size: layout-a3.at("body-size")) #let box-spacing = 1.2em #set columns(gutter: box-spacing) #set block(spacing: box-spacing) #set-poster-layout(layout-a3) #update-poster-layout(spacing: box-spacing) #doc ] #let a4-poster(doc) = [ #set page("a4", margin: 1cm) #set text(font: "Arial", size: layout-a4.at("body-size")) #let box-spacing = 1.2em #set columns(gutter: box-spacing) #set block(spacing: box-spacing) #set-poster-layout(layout-a4) #update-poster-layout(spacing: box-spacing) #doc ]
https://github.com/piepert/typst-seminar
https://raw.githubusercontent.com/piepert/typst-seminar/main/Beispiele/Hausarbeit/template.typ
typst
#import "outline-template.typ": * #let SUMMER_MONTHS = ("April", "Mai", "Juni", "Juli", "August", "September") #let project(title: "", authors: (), university: "<UNIVERSITY>", faculty: "<FACULTY>", institute: "<INSTITUTE>", docent: "<DOCENT>", course: "<COURSE>", matnr: "<MATNR>", date: "<DATE>", address: "<ADDRESS>", mail: "<MAIL>", body) = { // date: Day. Month Year // Set the document's basic properties. set document(author: authors, title: title) set page(numbering: "1", number-align: center, paper: "a4") set text(font: "Times New Roman", lang: "de", size: 12pt) set heading(numbering: "1.1.") set page(footer: []) // Title row. align(center)[ #pad(top: 4em, [ #set text(size: 14pt) #university #v(3em, weak: true) #pad(left: 2em, right: 2em, table(stroke: white, columns: (40%, 60%), ..("Fakultät:", faculty, "Institut:", institute, "Dozent:", docent, "Veranstaltung:", course).map(e => if type(e) == "string" and e.trim().ends-with(":") { strong(align(right)[#e]) } else { align(left)[#e] } ) )) // Title #pad(right: 4em, left: 4em, [ #v(1.5em, weak: true) #line(length: 100%) #v(1.5em, weak: true) #block(text(weight: 700, 1.75em, title)) #v(1.6em, weak: true) #line(length: 100%) #v(1.5em, weak: true) ]) #pad(left: 2em, right: 2em, table(stroke: white, columns: (40%, 60%), // Author information. ..( //if authors.len() > 1 { "Autoren:"} else { "Autor:" }, authors.join(", "), "Verfasser:", authors.join([, \ ], last: [\ und ]), "Matrikel-Nr.:", matnr, "Adresse:", address, "E-Mail:", raw(mail), ).map(e => if type(e) == "string" and e.trim().ends-with(":") { strong(align(right)[#e]) } else { align(left)[#e] } ) )) #{ v(3em, weak: true) if date.split(" ").len() < 2 { "<SEMESTER>" } else { let year = date.split(" ").at(2).slice(2) if date.split(" ").at(1) in SUMMER_MONTHS { "Sommersemester 20" + year } else { "Wintersemester 20" + year + "/" + str(int(year) + 1) } } [\ #date] } ]) ] // Main body. set par(justify: true) pagebreak() // outline(indent: true, fill: repeat([.#hide(".")])) outline() pagebreak() set par(leading: 1.25em) show heading: e => { v(e.level * 0.5em) e v(e.level * 0.5em) } set page(footer: align(center, counter(page).display())) set page(margin: (right: 4cm)) counter(page).update(1) body pagebreak() set page(footer: [], header: [], margin: (right: 3cm, top: 2cm)) counter(page).update(e => e - 1) heading(outlined: false, numbering: none, [Selbstständigkeitserklärung]) [Hiermit versichere ich, dass ich die vorliegende schriftliche Hausarbeit (Seminararbeit, Belegarbeit) selbstständig verfasst und keine anderen als die von mir angegebenen Quellen und Hilfsmittel benutzt habe. Die Stellen der Arbeit, die anderen Werken wörtlich oder sinngemäß entnommen sind, wurden in jedem Fall unter Angabe der Quellen (einschließlich des World Wide Web und anderer elektronischer Text- und Datensammlungen) kenntlich gemacht. Dies gilt auch für beigegebene Zeichnungen, bildliche Darstellungen, Skizzen und dergleichen. Ich versichere weiter, dass die Arbeit in gleicher oder ähnlicher Fassung noch nicht Bestandteil einer Prüfungsleistung oder einer schriftlichen Hausarbeit (Seminararbeit, Belegarbeit) war. Mir ist bewusst, dass jedes Zuwiderhandeln als Täuschungsversuch zu gelten hat, aufgrund dessen das Seminar oder die Übung als nicht bestanden bewertet und die Anerkennung der Hausarbeit als Leistungsnachweis/Modulprüfung (Scheinvergabe) ausgeschlossen wird. Ich bin mir weiter darüber im Klaren, dass das zuständige Lehrerprüfungsamt/Studienbüro über den Betrugsversuch informiert werden kann und Plagiate rechtlich als Straftatbestand gewertet werden.] v(1cm) table(columns: (auto, auto, auto, auto), stroke: white, inset: 0cm, strong([Ort, Datum:]) + h(0.5cm), repeat("."+hide("'")), h(0.5cm) + strong([Unterschrift:]) + h(0.5cm), repeat("."+hide("'"))) }