### Touying Setup with Multiple Imports Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/start.md Demonstrates setting up Touying with various preview packages like cetz, fletcher, and numbly, along with custom themes. Ensure all imported packages are correctly installed and accessible. ```typst #import "@preview/touying:0.6.1": * #import themes.university: * #import "@preview/cetz:0.3.2" #import "@preview/fletcher:0.5.5" as fletcher: node, edge #import "@preview/numbly:0.1.0": numbly #import "@preview/theorion:0.3.2": * #import cosmos.clouds: * #show: show-theorion // cetz and fletcher bindings for touying #let cetz-canvas = touying-reducer.with(reduce: cetz.canvas, cover: cetz.draw.hide.with(bounds: true)) #let fletcher-diagram = touying-reducer.with(reduce: fletcher.diagram, cover: fletcher.hide) #show: university-theme.with( aspect-ratio: "16-9", // align: horizon, // config-common(handout: true), config-common(frozen-counters: (theorem-counter,)), // freeze theorem counter for animation config-info( title: [Title], subtitle: [Subtitle], author: [Authors], date: datetime.today(), institution: [Institution], logo: emoji.school, ), ) #set heading(numbering: numbly("{1}.", default: "1.1")) #title-slide() ``` -------------------------------- ### Read Function Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/data-loading/read.md Examples demonstrating how to use the read function. ```APIDOC ## Example ```typst An example for a HTML file: \ #let text = read("example.html") #raw(text, block: true, lang: "html") Raw bytes: #read("tiger.jpg", encoding: none) ``` ``` -------------------------------- ### Line Function Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/visualize/line.md Illustrative examples of how to use the `line` function with different parameters. ```APIDOC ## Examples ```typst #set page(height: 100pt) #line(length: 100%) #line(end: (50%, 50%)) #line( length: 4cm, stroke: 2pt + maroon, ) ``` ``` -------------------------------- ### Example Presentation with Simple Theme Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/themes/simple.md A complete example demonstrating the initialization of the Simple theme and the usage of various slide types including title, default, and focus slides. ```typst #import "@preview/touying:0.6.1": * #import themes.simple: * #show: simple-theme.with( aspect-ratio: "16-9", footer: [Simple slides], ) #title-slide[ = Keep it simple! #v(2em) Alpha #footnote[Uni Augsburg] #h(1em) Bravo #footnote[Uni Bayreuth] #h(1em) Charlie #footnote[Uni Chemnitz] #h(1em) July 23 ] == First slide #lorem(20) #focus-slide[ _Focus!_ This is very important. ] = Let's start a new section! == Dynamic slide Did you know that... #pause ...you can see the current section at the top of the slide? ``` -------------------------------- ### Complex Pinit Example with Touying Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/integration/pinit.md An advanced example integrating pinit with Touying for slide creation, featuring custom styling, definitions, and complex annotations. Requires both touying and pinit packages. ```typst #import "@preview/touying:0.6.1": * #import themes.default: * #import "@preview/pinit:0.2.2": * #set text(size: 20pt, font: "Calibri", ligatures: false) #show heading: set text(weight: "regular") #show heading: set block(above: 1.4em, below: 1em) #show heading.where(level: 1): set text(size: 1.5em) // Useful functions #let crimson = rgb("#c00000") #let greybox(..args, body) = rect(fill: luma(95%), stroke: 0.5pt, inset: 0pt, outset: 10pt, ..args, body) #let redbold(body) = { set text(fill: crimson, weight: "bold") body } #let blueit(body) = { set text(fill: blue) body } #show: default-theme.with(aspect-ratio: "4-3") // Main body #slide[ #set heading(offset: 0) = Asymptotic Notation: $O$ Use #pin("h1")asymptotic notations#pin("h2") to describe asymptotic efficiency of algorithms. (Ignore constant coefficients and lower-order terms.) #pause #greybox[ Given a function $g(n)$, we denote by $O(g(n))$ the following *set of functions*: #redbold(${f(n): "exists" c > 0 "and" n_0 > 0, "such that" f(n) <= c dot g(n) "for all" n >= n_0$}) ] #pinit-highlight("h1", "h2") #pause $f(n) = O(g(n))$: #pin(1)$f(n)$ is *asymptotically smaller* than $g(n)$.#pin(2) #pause $f(n) redbold(in) O(g(n))$: $f(n)$ is *asymptotically* #redbold[at most] $g(n)$. #only("4-", pinit-line(stroke: 3pt + crimson, start-dy: -0.25em, end-dy: -0.25em, 1, 2)) #pause #block[Insertion Sort as an #pin("r1")example#pin("r2"):] - Best Case: $T(n) approx c n + c' n - c''$ #pin(3) - Worst case: $T(n) approx c n + (c' \/ 2) n^2 - c''$ #pin(4) #pinit-rect("r1", "r2") #pause #pinit-place(3, dx: 15pt, dy: -15pt)[#redbold[$T(n) = O(n)$]] #pinit-place(4, dx: 15pt, dy: -15pt)[#redbold[$T(n) = O(n)$]] #pause #blueit[Q: Is $n^(3) = O(n^2)$#pin("que")? How to prove your answer#pin("ans")?] #pause #pinit-point-to("que", fill: crimson, redbold[No.]) #pinit-point-from("ans", body-dx: -150pt)[ Show that the equation $(3/2)^n >= c$ \ has infinitely many solutions for $n$. ] ] ``` -------------------------------- ### Touying Example with Metropolis Theme Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/themes/metropolis.md A comprehensive example demonstrating the usage of the Metropolis theme in Touying, including initialization, title slide, outline, various content slides, focus slide, animation with pause, speaker notes, and appendix. ```typst #import "@preview/touying:0.6.1": * #import themes.metropolis: * #import "@preview/numbly:0.1.0": numbly #show: metropolis-theme.with( aspect-ratio: "16-9", footer: self => self.info.institution, config-info( title: [Title], subtitle: [Subtitle], author: [Authors], date: datetime.today(), institution: [Institution], logo: emoji.city, ), ) #set heading(numbering: numbly("{1}.", default: "1.1")) #title-slide() = Outline #outline(title: none, indent: 1em, depth: 1) = First Section --- A slide without a title but with some *important* information. == A long long long long long long long long long long long long long long long long long long long long long long long long Title === sdfsdf A slide with equation: $ x_(n+1) = (x_n + a/x_n) / 2 $ #lorem(200) = Second Section #focus-slide[ Wake up! ] == Simple Animation We can use `#pause` to #pause display something later. #meanwhile Meanwhile, #pause we can also use `#meanwhile` to display other content synchronously. #speaker-note[ + This is a speaker note. + You won't see it unless you use `config-common(show-notes-on-second-screen: right)` ] #show: appendix = Appendix --- Please pay attention to the current slide number. ``` -------------------------------- ### Stargazer Example Presentation Structure Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/themes/stargazer.md A comprehensive example demonstrating the initialization of the Stargazer theme and the usage of various slide functions, including title, outline, theorem, focus, pause, and appendix slides. ```typst #import "@preview/touying:0.6.1": * #import themes.stargazer: * #import "@preview/numbly:0.1.0": numbly #show: stargazer-theme.with( aspect-ratio: "16-9", config-info( title: [Stargazer in Touying: Customize Your Slide Title Here], subtitle: [Customize Your Slide Subtitle Here], author: [Authors], date: datetime.today(), institution: [Institution], logo: emoji.school, ), ) #set heading(numbering: numbly("{1}.", default: "1.1")) #title-slide() #outline-slide() = Section A == Subsection A.1 #tblock(title: [Theorem])[ A simple theorem. $ x_(n+1) = (x_n + a / x_n) / 2 $ ] == Subsection A.2 A slide without a title but with *important* information. = Section B == Subsection B.1 #lorem(80) #focus-slide[ Wake up! ] == Subsection B.2 We can use `#pause` to #pause display something later. #pause Just like this. #meanwhile Meanwhile, #pause we can also use `#meanwhile` to #pause display other content synchronously. #show: appendix = Appendix == Appendix Please pay attention to the current slide number. ``` -------------------------------- ### Move Function Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/move.md An example demonstrating how to use the `move` function to displace a rectangle with text. ```APIDOC ```typst #rect(inset: 0pt, fill: gray, move( dx: 4pt, dy: 6pt, rect( inset: 8pt, fill: white, stroke: black, [Abra cadabra] ) )) ``` ``` -------------------------------- ### Basic Stack Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/stack.md This example demonstrates how to use the stack function to arrange three rectangles vertically. The `dir: ttb` parameter specifies a top-to-bottom direction. ```typst #stack( dir: ttb, rect(width: 40pt), rect(width: 120pt), rect(width: 90pt), ) ``` -------------------------------- ### Strike Function Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/text/strike.md Illustrative examples demonstrating the usage of the strike function with different parameter configurations. ```APIDOC ## Examples ### Basic Usage ```typst This is #strike[not] relevant. ``` ### Customizing Stroke and Offset ```typst #set text(font: "Inria Serif") This is #strike(stroke: 1.5pt + red)[very stricken through]. \ This is #strike(stroke: 10pt)[redacted]. \ This is #strike(offset: auto)[low-ish]. \ This is #strike(offset: -3.5pt)[on-top]. ``` ### Adjusting Extent ```typst This #strike(extent: -2pt)[skips] parts of the word. This #strike(extent: 2pt)[extends] beyond the word. ``` ### Background Property ```typst #set strike(stroke: red) #strike(background: true)[This is behind.] \ #strike(background: false)[This is in front.] ``` ``` -------------------------------- ### Basic Raw Text Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/text/raw.md Demonstrates embedding raw text with different backtick usages and includes a Rust code example within a raw block. ```typst Adding `rbx` to `rcx` gives the desired result. What is ```rust fn main()``` in Rust would be ```c int main()``` in C. ```rust fn main() { println!("Hello World!"); } ``` This has ``` `backticks` ``` in it (but the spaces are trimmed). And ``` here``` the leading space is also trimmed. ``` -------------------------------- ### Basic Path Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/visualize/path.md Demonstrates how to create a closed, filled path with a stroke using basic points and relative positioning. ```typst #path( fill: blue.lighten(80%), stroke: blue, closed: true, (0pt, 50pt), (100%, 50pt), ((50%, 0pt), (40pt, 0pt)), ) ``` -------------------------------- ### Typst Probe Example for Runtime Behavior Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/SKILL.md Demonstrates how to probe uncertain runtime or evaluation behavior in Typst using scripting and metadata. This example shows a fileless probe via stdin to query the result of an expression. ```bash printf '#metadata(1 + 2) \n' | typst query - "" --field value --one ``` -------------------------------- ### Locating a Specific Element Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/introspection/locate.md An example demonstrating how to use the 'locate' function to find and display the position of an element with a specific label. ```APIDOC ## Examples Locating a specific element: ```typst #context [ Introduction is at: #locate().position() ] = Introduction ``` ``` -------------------------------- ### Page Break with 'to' Parameter Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/pagebreak.md Ensures the next page is an odd page, inserting an empty page if necessary. This example sets a small page height for demonstration. ```typst #set page(height: 30pt) First. #pagebreak(to: "odd") Third. ``` -------------------------------- ### Emph Syntax Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/model/emph.md Demonstrates how to use the emph function and its alternative syntax for emphasizing text. ```APIDOC ## Example ```typst This is _emphasized._ This is #emph[too.] #show emph: it => { text(blue, it.body) } This is _emphasized_ differently. ``` ``` -------------------------------- ### Basic Skew Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/skew.md Demonstrates how to apply a horizontal skew to text content. ```typst #skew(ax: -12deg)[ This is some fake italic text. ] ``` -------------------------------- ### Basic Highlight Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/text/highlight.md Demonstrates the basic usage of the highlight function to emphasize a word. ```typst This is #highlight[important]. ``` -------------------------------- ### Getting Direction Start Point Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/direction.md Retrieves the alignment representing the start point of a given direction. ```typst #ltr.start() #rtl.start() #ttb.start() #btt.start() ``` -------------------------------- ### Basic Overline Usage Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/text/overline.md A simple example demonstrating how to apply an overline to a piece of text. ```APIDOC ```typst #overline[A line over text.] ``` ``` -------------------------------- ### Main Entry Point for Touying Project Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/multi-file.md The `main.typ` file serves as the project's entry point. It imports global configurations, applies show rules with a theme, and includes content files. ```typst // main.typ #import "/globals.typ": * #show: university-theme.with( aspect-ratio: "16-9", config-info( title: [Title], subtitle: [Subtitle], author: [Authors], date: datetime.today(), institution: [Institution], logo: emoji.school, ) ) #include "content.typ" ``` -------------------------------- ### Minimal Touying Slide Deck Setup Source: https://context7.com/apcamargo/typst-skills/llms.txt This is the simplest Touying document. It imports the package and a theme, applies it with `#show`, and uses headings and `#pause` for content. ```typst #import "@preview/touying:0.6.1": * #import themes.simple: * #show: simple-theme.with( aspect-ratio: "16-9", footer: [My Presentation], ) = Introduction == Welcome Hello, Touying! #pause This line appears on the second subslide. ``` -------------------------------- ### Minimal Typst Document Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/SKILL.md A basic Typst document structure including document settings, page numbering, text language, paragraph justification, and basic content like titles, headings, and paragraphs. Use this as a starting point for new Typst projects. ```typst #set document(title: "My Document", author: "Author Name") #set page(numbering: "1") #set text(lang: "en") // Enable paragraph justification and character-level justification #set par( justify: true, justification-limits: ( tracking: (min: -0.012em, max: 0.012em), spacing: (min: 75%, max: 120%), ) ) #title[My Document] = Heading 1 This is a paragraph in Typst. == Heading 2 #lorem(50) ``` -------------------------------- ### Apply Touying Theme with Configuration Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/SKILL.md Import Touying and a theme, then apply the theme with custom configurations like aspect ratio and footer. This is typically done in the main entry file. ```typst #import "@preview/touying:0.6.1": * #import themes.simple: * #show: simple-theme.with( aspect-ratio: "16-9", footer: [Simple slides], ) ``` -------------------------------- ### Create and Use a Dictionary Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/dictionary.md Demonstrates creating a dictionary, accessing its properties using dot notation and `.at()`, and modifying it with `.insert()`. Also shows how to check for key existence and retrieve dictionary metadata. ```typst #let dict = ( name: "Typst", born: 2019, ) #dict.name \ #(dict.launch = 20) #dict.len() \ #dict.keys() \ #dict.values() \ #dict.at("born") \ #dict.insert("city", "Berlin") #("name" in dict) ``` -------------------------------- ### Selecting Elements After a Specific Start Point Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/selector.md The `selector.after` method returns a selector that matches elements occurring *after* the first match of the `start` selector. The `inclusive` parameter determines whether the `start` element itself should be included in the match. ```typst #selector.after( start, inclusive: bool ) -> selector ``` -------------------------------- ### Typst Math Root Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/math/roots.md Demonstrates the usage of the `sqrt` and `root` functions for mathematical expressions. ```typst $ sqrt(3 - 2 sqrt(2)) = sqrt(2) - 1 $ $ root(3, x) $ ``` -------------------------------- ### Path Fill Rule Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/visualize/path.md Illustrates the usage of the `fill-rule` parameter with 'non-zero' and 'even-odd' rules for creating a star shape. ```typst // We use `.with` to get a new // function that has the common // arguments pre-applied. #let star = path.with( fill: red, closed: true, (25pt, 0pt), (10pt, 50pt), (50pt, 20pt), (0pt, 20pt), (40pt, 50pt), ) #star(fill-rule: "non-zero") #star(fill-rule: "even-odd") ``` -------------------------------- ### Touying Theorem and Proof Environments Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/start.md Demonstrates the use of theorem, proof, definition, example, and corollary environments for structuring mathematical content. Includes theorem numbering and cross-referencing. ```typst = Theorems == Prime numbers #definition[ A natural number is called a #highlight[_prime number_] if it is greater than 1 and cannot be written as the product of two smaller natural numbers. ] #example[ The numbers $2$, $3$, and $17$ are prime. @cor_largest_prime shows that this list is not exhaustive! ] #theorem(title: "Euclid")[ There are infinitely many primes. ] #pagebreak(weak: true) #proof[ Suppose to the contrary that $p_1, p_2, dots, p_n$ is a finite enumeration of all primes. Set $P = p_1 p_2 dots p_n$. Since $P + 1$ is not in our list, it cannot be prime. Thus, some prime factor $p_j$ divides $P + 1$. Since $p_j$ also divides $P$, it must divide the difference $(P + 1) - P = 1$, a contradiction. ] #corollary[ There is no largest prime number. ] #corollary[ There are infinitely many composite numbers. ] #theorem[ There are arbitrarily long stretches of composite numbers. ] #proof[ For any $n > 2$, consider $ n! + 2, quad n! + 3, quad ..., quad n! + n ] ``` -------------------------------- ### Import and use module functions Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/module.md Demonstrates importing a module from a file and calling its functions. Ensure the 'utils.typ' file exists in the correct path. ```typst #import "utils.typ" #utils.add(2, 5) #import utils: sub #sub(1, 4) ``` -------------------------------- ### Get Type of Content Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/content.md Demonstrates how to get the type of a piece of content using the `#type` function. ```typst #type([*Hello!*]) ``` -------------------------------- ### Create a Basic Table with Header and Images Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/model/table.md Demonstrates creating a table with specified columns, inset, and alignment. It includes a header row and uses images and mathematical expressions as cell content. ```typst #table( columns: (1fr, auto, auto), inset: 10pt, align: horizon, table.header( [], [*Volume*], [*Parameters*], ), image("cylinder.svg"), $ pi h (D^2 - d^2) / 4 $, [ $h$: height \ $D$: outer radius \ $d$: inner radius ], image("tetrahedron.svg"), $ sqrt(2) / 12 a^3 $, [$a$: edge length] ) ``` -------------------------------- ### Heading Numbering and Supplement Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/model/heading.md Shows how to set a numbering pattern and a supplement for headings, affecting both the displayed text and references. ```typst #set heading(numbering: "1.", supplement: [Chapter]) = Introduction In @intro, we see how to turn Sections into Chapters. And in @intro[Part], it is done manually. ``` -------------------------------- ### v Function Example Usage Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/v.md An example demonstrating the usage of the v function within a grid layout. ```APIDOC ## Example ```typst #grid( rows: 3cm, columns: 6, gutter: 1fr, [A #parbreak() B], [A #v(0pt) B], [A #v(10pt) B], [A #v(0pt, weak: true) B], [A #v(40%, weak: true) B], [A #v(1fr) B], ) ``` ``` -------------------------------- ### Get Dictionary Length Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/dictionary.md Demonstrates how to get the number of key-value pairs in a dictionary using the `.len()` method. ```typst #dictionary.len ``` -------------------------------- ### String Constructor Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/str.md Shows how to convert various data types into strings using the `str` constructor, including custom bases for integers and formatting for floats. ```typst #str(10) \ #str(4000, base: 16) \ #str(2.7) \ #str(1e8) \ #str() ``` -------------------------------- ### Typst Array Chunks Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/array.md Demonstrates splitting an array into chunks of a specified size. The first example splits into chunks of 3 elements. The second example, with `exact: true`, drops the last chunk if it's smaller than the `chunk-size`. ```typst #let array = (1, 2, 3, 4, 5, 6, 7, 8) #array.chunks(3) \ #array.chunks(3, exact: true) ``` -------------------------------- ### Basic heading styling with `show` rules Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/tutorial/advanced-styling.md Apply common styles to all headings using `show` rules. This example centers headings, sets their size and weight, and applies small caps. ```typst #show heading: set align(center) #show heading: set text( size: 13pt, weight: "regular", ) #show heading: smallcaps ... = Introduction ... == Motivation ... ``` -------------------------------- ### Set Enum Start Number Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/model/enum.md Specify the starting number for an enumeration. This affects the sequence of numbers displayed for the list items. ```typst #enum( start: 3, [Skipping], [Ahead], ) ``` -------------------------------- ### Add Vertical Line with Start Row Constraint Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/guides/tables.md Use `table.vline(x: ..., start: ...)` to add a vertical line. The `x` argument specifies the column index, and `start` controls the first row the line appears in, preventing it from crossing certain rows. ```typst // Base template already configured tables, but we need some // extra configuration for this table. #{ set table(align: (x, _) => if x == 0 { left } else { right }) show table.cell.where(x: 0): smallcaps table( columns: (auto, 1fr, 1fr, 1fr), table.vline(x: 1, start: 1), table.header[Trainset][Top Speed][Length][Weight], [TGV Réseau], [320 km/h], [200m], [383t], [ICE 403], [330 km/h], [201m], [409t], [Shinkansen N700], [300 km/h], [405m], [700t], ) } ``` -------------------------------- ### Create and Style a Table with Header Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/model/table.md Demonstrates creating a table with custom styling, including cell fills and alignment, and using `table.header` for the heading row. This example also shows how to apply styles to specific cells based on their row and column. ```typst #set page(height: 11.5em) #set table( fill: (x, y) => if x == 0 or y == 0 { gray.lighten(40%) }, align: right, ) #show table.cell.where(x: 0): strong #show table.cell.where(y: 0): strong #table( columns: 4, table.header( [], [Blue chip], [Fresh IPO], [Penny st'k], ), table.cell( rowspan: 6, align: horizon, rotate(-90deg, reflow: true)[ *USD / day* ], ), [0.20], [104], [5], [3.17], [108], [4], [1.59], [84], [1], [0.26], [98], [15], [0.01], [195], [4], [7.34], [57], [2], ) ``` -------------------------------- ### Get Dictionary Pairs Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/dictionary.md Demonstrates how to get all key-value pairs from a dictionary as an array of pairs, where each pair is a two-element array, in insertion order. ```typst #dictionary.pairs ``` -------------------------------- ### Term List Hanging Indent Parameter Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/model/terms.md Illustrates the effect of the `hanging-indent` parameter. This example sets it to `0pt`, disabling hanging indents for the description. ```typst #set terms(hanging-indent: 0pt) / Term: This term list does not make use of hanging indents. ``` -------------------------------- ### Full Example with Dewdrop Theme Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/themes/dewdrop.md Demonstrates a complete Touying presentation using the Dewdrop theme, including title slide, outline, sections, subsections, mathematical equations, focus slides, and content pausing/synchronization. ```typst #import "@preview/touying:0.6.1": * #import themes.dewdrop: * #import "@preview/numbly:0.1.0": numbly #show: dewdrop-theme.with( aspect-ratio: "16-9", footer: self => self.info.institution, navigation: "mini-slides", config-info( title: [Title], subtitle: [Subtitle], author: [Authors], date: datetime.today(), institution: [Institution], ), ) #set heading(numbering: numbly("{1}.", default: "1.1")) #title-slide() #outline-slide() = Section A == Subsection A.1 $ x_(n+1) = (x_n + a/x_n) / 2 $ == Subsection A.2 A slide without a title but with *important* infos = Section B == Subsection B.1 #lorem(80) #focus-slide[ Wake up! ] == Subsection B.2 We can use `#pause` to #pause display something later. #pause Just like this. #meanwhile Meanwhile, #pause we can also use `#meanwhile` to #pause display other content synchronously. #show: appendix = Appendix == Appendix Please pay attention to the current slide number. ``` -------------------------------- ### Scale with Origin Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/scale.md Illustrates how the `origin` parameter affects the scaling transformation. The first example uses the default origin, while the second specifies `bottom + left`. ```typst A#box(scale(75%)[A])A \ B#box(scale(75%, origin: bottom + left)[B])B ``` -------------------------------- ### Using Math Module Functions Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/changelog/earlier.md Shows how to explicitly use functions from the math module, such as setting vector delimiters. ```typst #set math.vec(delim: "[") ``` -------------------------------- ### Cetz Animation Example in Touying Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/integration/fletcher.md An example of creating an animated Cetz canvas within a Touying slide. It showcases basic shapes and pauses for animation control. ```typst #slide[ Cetz in Touying: #cetz-canvas({ import cetz.draw: * rect((0,0), (5,5)) (pause,) rect((0,0), (1,1)) rect((1,1), (2,2)) rect((2,2), (3,3)) (pause,) line((0,0), (2.5, 2.5), name: "line") }) ] ``` -------------------------------- ### Basic Tiling Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/visualize/tiling.md Demonstrates a basic tiling pattern with diagonal lines filling a rectangle. This is useful for creating simple repeating visual elements. ```typst #let pat = tiling(size: (30pt, 30pt))[ #place(line(start: (0%, 0%), end: (100%, 100%))) #place(line(start: (0%, 100%), end: (100%, 0%))) ] #rect(fill: pat, width: 100%, height: 60pt, stroke: 1pt) ``` -------------------------------- ### Touying Multiple Pages and Appendix Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/start.md Demonstrates generating multiple pages of content using `#lorem` and setting up an appendix section using `#show: appendix`. This is for longer documents or presentations. ```typst == Multiple Pages #lorem(200) #show: appendix = Appendix == Appendix Please pay attention to the current slide number. ``` -------------------------------- ### Typst Array Intersperse Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/array.md Shows how to use the `intersperse` function to insert a separator between elements of an array. This example inserts a hyphen '-' between the elements 'A', 'B', and 'C'. ```typst #("A", "B", "C").intersperse("-") ``` -------------------------------- ### Enable Fractions Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/text/text.md Illustrates how to automatically convert numbers separated by a slash into fractions using the 'fractions' parameter. It's recommended to use this locally. ```typst 1/2 \ #text(fractions: true)[1/2] ``` -------------------------------- ### Initialize Codly with Custom Languages Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/integration/codly.md Use `codly-init.with()` to set up Codly. Configure language definitions, including names, icons, and colors, within `config-common`. ```typst #import "@preview/touying:0.6.1": * #import themes.simple: * #import "@preview/codly:1.0.0": * #show: codly-init.with() #show: simple-theme.with( aspect-ratio: "16-9", config-common(preamble: { codly(languages: ( rust: ( name: "Rust", icon: text(font: "tabler-icons", "\u{fa53}"), color: rgb("#CE412B"), ), )) }), ) == First slide #raw(lang: "rust", block: true, `pub fn main() { println!("Hello, world!"); }`.text) ``` -------------------------------- ### Curve Move Function Signature Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/visualize/curve.md Shows the function signature for `curve.move` and its parameters: `start` and `relative`. The `relative` parameter determines if the start coordinates are relative to the previous point. ```typst #curve.move( start, relative: bool ) -> content ``` -------------------------------- ### Typst Math Mode Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/guides/for-latex-users.md Demonstrates basic math mode usage in Typst, including inline and display math, and variable interpretation. ```typst The sum of the numbers from $1$ to $n$ is: $ sum_(k=1)^n k = (n(n+1))/2 $ ``` -------------------------------- ### Initialize Aqua Theme Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/themes/aqua.md Initializes the Aqua theme with specified aspect ratio and configuration information. This setup is required before using any Aqua theme features. ```typst #import "@preview/touying:0.6.1": * #import themes.aqua: * #show: aqua-theme.with( aspect-ratio: "16-9", config-info( title: [Title], subtitle: [Subtitle], author: [Authors], date: datetime.today(), institution: [Institution], ) ) #title-slide() #outline-slide() ``` -------------------------------- ### Typst Align Parameter Example (Arabic) Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/align.md Example demonstrating the `alignment` parameter of the `align` function using Arabic text and combining `end` and `horizon` alignments for a specific layout. ```typst #set page(height: 6cm) #set text(lang: "ar") مثال #align( end + horizon, rect(inset: 12pt)[ركن] ) ``` -------------------------------- ### Initialize Dewdrop Theme Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/themes/dewdrop.md Initializes the Dewdrop theme with custom aspect ratio, footer, navigation style, and information configuration. Requires importing touying and dewdrop theme modules. ```typst #import "@preview/touying:0.6.1": * #import themes.dewdrop: * #import "@preview/numbly:0.1.0": numbly #show: dewdrop-theme.with( aspect-ratio: "16-9", footer: self => self.info.institution, navigation: "mini-slides", config-info( title: [Title], subtitle: [Subtitle], author: [Authors], date: datetime.today(), institution: [Institution], ), ) #title-slide() #outline-slide() ``` -------------------------------- ### Typst Array Dedup Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/array.md Shows how to remove duplicate items from an array. This example deduplicates the array `(3, 3, 1, 2, 3)`, keeping only the first occurrence of each value. ```typst #(3, 3, 1, 2, 3).dedup() ``` -------------------------------- ### Initialize University Theme Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/themes/university.md Initializes the University theme with specified configurations for aspect ratio, title slide information, and heading numbering. Ensure necessary imports are included. ```typst #import "@preview/touying:0.6.1": * #import themes.university: * #import "@preview/numbly:0.1.0": numbly #show: university-theme.with( aspect-ratio: "16-9", config-info( title: [Title], subtitle: [Subtitle], author: [Authors], date: datetime.today(), institution: [Institution], logo: emoji.school, ), ) #set heading(numbering: numbly("{1}.", default: "1.1")) #title-slide() ``` -------------------------------- ### New Import Syntax Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/changelog/earlier.md Demonstrates the new ways to import modules and specific items from modules. ```typst #import "module.typ" #import "module.typ": a, b #import "module.typ": * #import emoji: face, turtle ``` -------------------------------- ### Quadratic Bézier Curve Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/visualize/curve.md Shows how to draw a quadratic Bézier curve using `curve.quad`. The example includes a helper function `mark` to visualize the control point's position relative to the curve. ```typst // Function to illustrate where the control point is. #let mark((x, y)) = place( dx: x - 1pt, dy: y - 1pt, circle(fill: aqua, radius: 2pt), ) #mark((20pt, 20pt)) #curve( stroke: blue, curve.move((0pt, 100pt)), curve.quad((20pt, 20pt), (100pt, 0pt)), ) ``` -------------------------------- ### Alternative Math Font Configuration Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/changelog/earlier.md Demonstrates how to set an alternative math font using the `#show` rule. ```typst #show math.formula: set text("Fira Math") ``` -------------------------------- ### Term List Children Parameter Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/model/terms.md Demonstrates how term list items are collected, even through constructs like for loops. This example dynamically creates term list items for different years and products. ```typst #for (year, product) in ( "1978": "TeX", "1984": "LaTeX", "2019": "Typst", ) [/ #product: Born in #year.] ``` -------------------------------- ### Method Call Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/scripting.md Illustrates method calls on a tuple and string manipulation using chained method calls. Also shows the equivalence of method calls and direct function calls. ```typst #let values = (1, 2, 3, 4) #values.pop() \ #values.len() \ #("a, b, c" .split(", ") .join[ --- ]) #"abc".len() is the same as #str.len("abc") ``` -------------------------------- ### Simple Pinit Highlight and Point Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/integration/pinit.md Demonstrates basic usage of pinit for highlighting text and pointing from an element. Ensure the pinit package is imported. ```typst #import "@preview/pinit:0.2.2": * #set text(size: 24pt) A simple #pin(1)highlighted text#pin(2). #pinit-highlight(1, 2) #pinit-point-from(2)[It is simple.] ``` -------------------------------- ### Typst Array Split Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/array.md Demonstrates splitting an array at occurrences of a specified value. The example shows splitting the array `(1, 1, 2, 3, 2, 4, 5)` at the value `2`. ```typst #(1, 1, 2, 3, 2, 4, 5).split(2) ``` -------------------------------- ### Self-Referential Query Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/introspection/query.md This example illustrates a potentially problematic self-referential query where the query for headings can affect the generation of new headings, leading to repeated processing. Typst limits the attempts to prevent infinite loops. ```typst = Real #context { let elems = query(heading) let count = elems.len() count * [= Fake] } ``` -------------------------------- ### Create and Display a Date Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/datetime.md Demonstrates creating a date using year, month, and day, and then displaying it. ```typst #datetime( year: 2012, month: 8, day: 3, ).display() ``` -------------------------------- ### Correct State Management with Typst's state() Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/introspection/state.md This example shows the correct way to manage state using Typst's `state` function. The `update` method takes a function that receives the old state and returns the new state, ensuring correct behavior and layout order. ```typst #let star = state("star", 0) #let compute(expr) = { star.update(old => eval(expr.replace("⭐", str(old))) ) [New value is #context star.get().] } #compute("10") \ #compute("⭐ + 3") \ #compute("⭐ * 2") \ #compute("⭐ - 5") ``` -------------------------------- ### Float Constructor Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/float.md Shows how to convert different data types (booleans, integers, ratios, strings) into floating-point numbers using the `float()` constructor. ```typst #float(false) \ #float(true) \ #float(4) \ #float(40%) \ #float("2.7") \ #float("1e5") ``` -------------------------------- ### Bytes Constructor Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/bytes.md Illustrates the `bytes` constructor by converting a string and an array of integers into the bytes type. This highlights the flexibility in creating byte sequences. ```typst #bytes("Hello 😃") \ #bytes((123, 160, 22, 0)) ``` -------------------------------- ### Typst Array Windows Example Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/array.md Illustrates the `array.windows` function, which creates sliding windows of a specified size over an array. This example creates windows of 5 elements from the array `(1, 2, 3, 4, 5, 6, 7, 8)`. ```typst #let array = (1, 2, 3, 4, 5, 6, 7, 8) #array.windows(5) ``` -------------------------------- ### str.starts-with Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/foundations/str.md Checks if the string starts with the specified pattern. ```APIDOC ## str.starts-with Whether the string starts with the specified pattern. ```typst #str.starts-with( pattern ) -> bool ``` ### Parameters - pattern: - description: The pattern the string might start with. - type: str | regex - default: None ``` -------------------------------- ### Basic Citation Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/model/cite.md Demonstrates different ways to cite sources from a bibliography using shorthand and explicit calls to cite. Ensure a bibliography is added to your document. ```typst This was already noted by pirates long ago. @arrgh Multiple sources say ... @arrgh @netwok. You can also call `cite` explicitly. #cite() #bibliography("works.bib") ``` ```typst Computer Modern is an example of a modernist serif typeface. #cite(label("DBLP:books/lib/Knuth86a")). ``` -------------------------------- ### Highlight with Extent Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/text/highlight.md Example of extending the highlight background to the sides. ```APIDOC ## Highlight with Extent ```typst A long #highlight(extent: 4pt)[background]. ``` ``` -------------------------------- ### curve.move Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/visualize/curve.md Starts a new curve component at a specified point. ```APIDOC ### curve.move Starts a new curve component. If no `curve.move` element is passed, the curve will start at `(0pt, 0pt)`. ```typst #curve( fill: blue.lighten(80%), fill-rule: "even-odd", stroke: blue, curve.line((50pt, 0pt)), curve.line((50pt, 50pt)), curve.line((0pt, 50pt)), curve.close(), curve.move((10pt, 10pt)), curve.line((40pt, 10pt)), curve.line((40pt, 40pt)), curve.line((10pt, 40pt)), curve.close(), ) ``` ```typst #curve.move( start, relative: bool ) -> content ``` #### Parameters - start: - description: The starting point for the new component. - type: array - default: None - relative: - description: Whether the coordinates are relative to the previous point. - type: bool - default: false ``` -------------------------------- ### Typst Fraction and Parentheses in Math Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/guides/for-latex-users.md Illustrates Typst's automatic fraction handling with '/' and how parentheses are managed. ```typst $ f(x) = (x + 1) / x $ ``` -------------------------------- ### direction.start Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/direction.md Retrieves the starting alignment point for a given direction. ```APIDOC ## direction.start The start point of this direction, as an alignment. ### Signature ```typst .start() -> alignment ``` ``` -------------------------------- ### Global Configuration for Touying Slides Source: https://github.com/apcamargo/typst-skills/blob/main/touying-author/docs/multi-file.md Define global settings and import necessary themes and utility functions in `globals.typ`. This file should be imported by other project files. ```typst // globals.typ #import "@preview/touying:0.6.1": * #import themes.university: * // as well as some utility functions ``` -------------------------------- ### Highlight with Stroke Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/text/highlight.md Example demonstrating how to add a border (stroke) to the highlight. ```APIDOC ## Highlight with Stroke ```typst This is a #highlight(stroke: fuchsia)[stroked highlighting]. ``` ``` -------------------------------- ### Skew Origin Examples Source: https://github.com/apcamargo/typst-skills/blob/main/typst-author/docs/reference/layout/skew.md Shows different skew origins and their effect on the transformation. ```APIDOC ```typst X #box(skew(ax: -30deg, origin: center + horizon)[X]) X X #box(skew(ax: -30deg, origin: bottom + left)[X]) X X #box(skew(ax: -30deg, origin: top + right)[X]) X ``` ```