mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Change indent from 4 to 2 spaces
This commit is contained in:
parent
1ee1d078e2
commit
e35fca54a0
@ -6,20 +6,20 @@
|
|||||||
|
|
||||||
// Evaluates to join of none, [My ] and the two loop bodies.
|
// Evaluates to join of none, [My ] and the two loop bodies.
|
||||||
{
|
{
|
||||||
let parts = ("my fri", "end.")
|
let parts = ("my fri", "end.")
|
||||||
[Hello, ]
|
[Hello, ]
|
||||||
for s in parts [{s}]
|
for s in parts [{s}]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evaluates to join of the templates and strings.
|
// Evaluates to join of the templates and strings.
|
||||||
{
|
{
|
||||||
[How]
|
[How]
|
||||||
if true {
|
if true {
|
||||||
" are"
|
" are"
|
||||||
}
|
}
|
||||||
[ ]
|
[ ]
|
||||||
if false [Nope]
|
if false [Nope]
|
||||||
[you] + "?"
|
[you] + "?"
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -37,24 +37,24 @@
|
|||||||
|
|
||||||
// Evaluated to int.
|
// Evaluated to int.
|
||||||
#test({
|
#test({
|
||||||
let x = 1
|
let x = 1
|
||||||
let y = 2
|
let y = 2
|
||||||
x + y
|
x + y
|
||||||
}, 3)
|
}, 3)
|
||||||
|
|
||||||
// String is joined with trailing none, evaluates to string.
|
// String is joined with trailing none, evaluates to string.
|
||||||
#test({
|
#test({
|
||||||
type("")
|
type("")
|
||||||
none
|
none
|
||||||
}, "string")
|
}, "string")
|
||||||
|
|
||||||
---
|
---
|
||||||
// Some things can't be joined.
|
// Some things can't be joined.
|
||||||
{
|
{
|
||||||
[A]
|
[A]
|
||||||
// Error: 5-6 cannot join template with integer
|
// Error: 3-4 cannot join template with integer
|
||||||
1
|
1
|
||||||
[B]
|
[B]
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -65,8 +65,8 @@
|
|||||||
---
|
---
|
||||||
// Block in expression does create a scope.
|
// Block in expression does create a scope.
|
||||||
#let a = {
|
#let a = {
|
||||||
let b = 1
|
let b = 1
|
||||||
b
|
b
|
||||||
}
|
}
|
||||||
|
|
||||||
#test(a, 1)
|
#test(a, 1)
|
||||||
@ -77,8 +77,8 @@
|
|||||||
---
|
---
|
||||||
// Double block creates a scope.
|
// Double block creates a scope.
|
||||||
{{
|
{{
|
||||||
import b from "target.typ"
|
import b from "target.typ"
|
||||||
test(b, 1)
|
test(b, 1)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// Error: 2-3 unknown variable
|
// Error: 2-3 unknown variable
|
||||||
@ -87,17 +87,17 @@
|
|||||||
---
|
---
|
||||||
// Multiple nested scopes.
|
// Multiple nested scopes.
|
||||||
{
|
{
|
||||||
let a = "a1"
|
let a = "a1"
|
||||||
|
{
|
||||||
|
let a = "a2"
|
||||||
{
|
{
|
||||||
let a = "a2"
|
test(a, "a2")
|
||||||
{
|
let a = "a3"
|
||||||
test(a, "a2")
|
test(a, "a3")
|
||||||
let a = "a3"
|
|
||||||
test(a, "a3")
|
|
||||||
}
|
|
||||||
test(a, "a2")
|
|
||||||
}
|
}
|
||||||
test(a, "a1")
|
test(a, "a2")
|
||||||
|
}
|
||||||
|
test(a, "a1")
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -117,13 +117,13 @@
|
|||||||
|
|
||||||
// Should output `3`.
|
// Should output `3`.
|
||||||
{
|
{
|
||||||
// Error: 9-12 expected identifier, found string
|
// Error: 7-10 expected identifier, found string
|
||||||
for "v"
|
for "v"
|
||||||
|
|
||||||
// Error: 10 expected keyword `in`
|
// Error: 8 expected keyword `in`
|
||||||
for v let z = 1 + 2
|
for v let z = 1 + 2
|
||||||
|
|
||||||
z
|
z
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
// Test multiple wide calls in separate expressions inside a template.
|
// Test multiple wide calls in separate expressions inside a template.
|
||||||
[
|
[
|
||||||
#font!(fill: eastern) - First
|
#font!(fill: eastern) - First
|
||||||
#font!(fill: forest) - Second
|
#font!(fill: forest) - Second
|
||||||
]
|
]
|
||||||
|
|
||||||
// Test wide call in heading.
|
// Test wide call in heading.
|
||||||
@ -59,12 +59,12 @@ C
|
|||||||
|
|
||||||
// Callee expressions.
|
// Callee expressions.
|
||||||
{
|
{
|
||||||
// Wrapped in parens.
|
// Wrapped in parens.
|
||||||
test((type)("hi"), "string")
|
test((type)("hi"), "string")
|
||||||
|
|
||||||
// Call the return value of a function.
|
// Call the return value of a function.
|
||||||
let adder(dx) = x => x + dx
|
let adder(dx) = x => x + dx
|
||||||
test(adder(2)(5), 7)
|
test(adder(2)(5), 7)
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -13,73 +13,73 @@
|
|||||||
---
|
---
|
||||||
// Basic closure without captures.
|
// Basic closure without captures.
|
||||||
{
|
{
|
||||||
let adder = (x, y) => x + y
|
let adder = (x, y) => x + y
|
||||||
test(adder(2, 3), 5)
|
test(adder(2, 3), 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
// Pass closure as argument and return closure.
|
// Pass closure as argument and return closure.
|
||||||
// Also uses shorthand syntax for a single argument.
|
// Also uses shorthand syntax for a single argument.
|
||||||
{
|
{
|
||||||
let chain = (f, g) => (x) => f(g(x))
|
let chain = (f, g) => (x) => f(g(x))
|
||||||
let f = x => x + 1
|
let f = x => x + 1
|
||||||
let g = x => 2 * x
|
let g = x => 2 * x
|
||||||
let h = chain(f, g)
|
let h = chain(f, g)
|
||||||
test(h(2), 5)
|
test(h(2), 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
// Capture environment.
|
// Capture environment.
|
||||||
{
|
{
|
||||||
let mark = "?"
|
let mark = "?"
|
||||||
let greet = {
|
let greet = {
|
||||||
let hi = "Hi"
|
let hi = "Hi"
|
||||||
name => {
|
name => {
|
||||||
hi + ", " + name + mark
|
hi + ", " + name + mark
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test(greet("Typst"), "Hi, Typst?")
|
test(greet("Typst"), "Hi, Typst?")
|
||||||
|
|
||||||
mark = "!"
|
mark = "!"
|
||||||
test(greet("Typst"), "Hi, Typst!")
|
test(greet("Typst"), "Hi, Typst!")
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
// Redefined variable.
|
// Redefined variable.
|
||||||
{
|
{
|
||||||
let x = 1
|
let x = 1
|
||||||
let f() = {
|
let f() = {
|
||||||
let x = x + 2
|
let x = x + 2
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
test(f(), 3)
|
test(f(), 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
// Don't leak environment.
|
// Don't leak environment.
|
||||||
{
|
{
|
||||||
// Error: 18-19 unknown variable
|
// Error: 16-17 unknown variable
|
||||||
let func() = x
|
let func() = x
|
||||||
let x = "hi"
|
let x = "hi"
|
||||||
func()
|
func()
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
// Too few arguments.
|
// Too few arguments.
|
||||||
{
|
{
|
||||||
let types(x, y) = "[" + type(x) + ", " + type(y) + "]"
|
let types(x, y) = "[" + type(x) + ", " + type(y) + "]"
|
||||||
test(types(14%, 12pt), "[relative, length]")
|
test(types(14%, 12pt), "[relative, length]")
|
||||||
|
|
||||||
// Error: 16-22 missing argument: y
|
// Error: 14-20 missing argument: y
|
||||||
test(types("nope"), "[string, none]")
|
test(types("nope"), "[string, none]")
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
// Too many arguments.
|
// Too many arguments.
|
||||||
{
|
{
|
||||||
let f(x) = x + 1
|
let f(x) = x + 1
|
||||||
|
|
||||||
// Error: 10-15 unexpected argument
|
// Error: 8-13 unexpected argument
|
||||||
f(1, "two", () => x)
|
f(1, "two", () => x)
|
||||||
}
|
}
|
||||||
|
@ -10,22 +10,22 @@
|
|||||||
// Dictionary is not traversed in insertion order.
|
// Dictionary is not traversed in insertion order.
|
||||||
// Should output `Age: 2. Name: Typst.`.
|
// Should output `Age: 2. Name: Typst.`.
|
||||||
#for k, v in (Name: "Typst", Age: 2) [
|
#for k, v in (Name: "Typst", Age: 2) [
|
||||||
{k}: {v}.
|
{k}: {v}.
|
||||||
]
|
]
|
||||||
|
|
||||||
// Block body.
|
// Block body.
|
||||||
// Should output `[1st, 2nd, 3rd, 4th, 5th]`.
|
// Should output `[1st, 2nd, 3rd, 4th, 5th]`.
|
||||||
{
|
{
|
||||||
"["
|
"["
|
||||||
for v in (1, 2, 3, 4, 5) {
|
for v in (1, 2, 3, 4, 5) {
|
||||||
if v > 1 [, ]
|
if v > 1 [, ]
|
||||||
[#v]
|
[#v]
|
||||||
if v == 1 [st]
|
if v == 1 [st]
|
||||||
if v == 2 [nd]
|
if v == 2 [nd]
|
||||||
if v == 3 [rd]
|
if v == 3 [rd]
|
||||||
if v >= 4 [th]
|
if v >= 4 [th]
|
||||||
}
|
}
|
||||||
"]"
|
"]"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Template body.
|
// Template body.
|
||||||
@ -37,23 +37,23 @@
|
|||||||
|
|
||||||
// Values of array.
|
// Values of array.
|
||||||
#for v in (1, 2, 3) {
|
#for v in (1, 2, 3) {
|
||||||
out += (v,)
|
out += (v,)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indices and values of array.
|
// Indices and values of array.
|
||||||
#for i, v in ("1", "2", "3") {
|
#for i, v in ("1", "2", "3") {
|
||||||
test(repr(i + 1), v)
|
test(repr(i + 1), v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values of dictionary.
|
// Values of dictionary.
|
||||||
#for v in (a: 4, b: 5) {
|
#for v in (a: 4, b: 5) {
|
||||||
out += (v,)
|
out += (v,)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keys and values of dictionary.
|
// Keys and values of dictionary.
|
||||||
#for k, v in (a: 6, b: 7) {
|
#for k, v in (a: 6, b: 7) {
|
||||||
out += (k,)
|
out += (k,)
|
||||||
out += (v,)
|
out += (v,)
|
||||||
}
|
}
|
||||||
|
|
||||||
#test(out, (1, 2, 3, 4, 5, "a", 6, "b", 7))
|
#test(out, (1, 2, 3, 4, 5, "a", 6, "b", 7))
|
||||||
@ -61,9 +61,9 @@
|
|||||||
// Chars of string.
|
// Chars of string.
|
||||||
#let first = true
|
#let first = true
|
||||||
#let joined = for c in "abc" {
|
#let joined = for c in "abc" {
|
||||||
if not first { ", " }
|
if not first { ", " }
|
||||||
first = false
|
first = false
|
||||||
c
|
c
|
||||||
}
|
}
|
||||||
|
|
||||||
#test(joined, "a, b, c")
|
#test(joined, "a, b, c")
|
||||||
@ -81,7 +81,7 @@
|
|||||||
// Keys and values of strings.
|
// Keys and values of strings.
|
||||||
// Error: 6-10 mismatched pattern
|
// Error: 6-10 mismatched pattern
|
||||||
#for k, v in "hi" {
|
#for k, v in "hi" {
|
||||||
dont-care
|
dont-care
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -3,46 +3,46 @@
|
|||||||
---
|
---
|
||||||
// Test condition evaluation.
|
// Test condition evaluation.
|
||||||
#if 1 < 2 [
|
#if 1 < 2 [
|
||||||
One.
|
One.
|
||||||
]
|
]
|
||||||
|
|
||||||
#if true == false [
|
#if true == false [
|
||||||
{Bad}, but we {dont-care}!
|
{Bad}, but we {dont-care}!
|
||||||
]
|
]
|
||||||
|
|
||||||
---
|
---
|
||||||
// Braced condition.
|
// Braced condition.
|
||||||
#if {true} [
|
#if {true} [
|
||||||
One.
|
One.
|
||||||
]
|
]
|
||||||
|
|
||||||
// Template in condition.
|
// Template in condition.
|
||||||
#if [] != none [
|
#if [] != none [
|
||||||
Two.
|
Two.
|
||||||
]
|
]
|
||||||
|
|
||||||
// Multi-line condition with parens.
|
// Multi-line condition with parens.
|
||||||
#if (
|
#if (
|
||||||
1 + 1
|
1 + 1
|
||||||
== 1
|
== 1
|
||||||
) [
|
) [
|
||||||
Nope.
|
Nope.
|
||||||
] #else {
|
] #else {
|
||||||
"Three."
|
"Three."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiline.
|
// Multiline.
|
||||||
#if false [
|
#if false [
|
||||||
Bad.
|
Bad.
|
||||||
] #else {
|
] #else {
|
||||||
let point = "."
|
let point = "."
|
||||||
"Four" + point
|
"Four" + point
|
||||||
}
|
}
|
||||||
|
|
||||||
// Template can be argument or body depending on whitespace.
|
// Template can be argument or body depending on whitespace.
|
||||||
{
|
{
|
||||||
if "template" == type[b] [Fi] else [Nope]
|
if "template" == type[b] [Fi] else [Nope]
|
||||||
if "template" == type [Nope] else [ve.]
|
if "template" == type [Nope] else [ve.]
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -50,21 +50,21 @@
|
|||||||
// Ref: false
|
// Ref: false
|
||||||
|
|
||||||
{
|
{
|
||||||
let x = 1
|
let x = 1
|
||||||
let y = 2
|
let y = 2
|
||||||
let z
|
let z
|
||||||
|
|
||||||
// Returns if branch.
|
// Returns if branch.
|
||||||
z = if x < y { "ok" }
|
z = if x < y { "ok" }
|
||||||
test(z, "ok")
|
test(z, "ok")
|
||||||
|
|
||||||
// Returns else branch.
|
// Returns else branch.
|
||||||
z = if x > y { "bad" } else { "ok" }
|
z = if x > y { "bad" } else { "ok" }
|
||||||
test(z, "ok")
|
test(z, "ok")
|
||||||
|
|
||||||
// Missing else evaluates to none.
|
// Missing else evaluates to none.
|
||||||
z = if x > y { "bad" }
|
z = if x > y { "bad" }
|
||||||
test(z, none)
|
test(z, none)
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
// Code mode
|
// Code mode
|
||||||
{
|
{
|
||||||
import b from "target.typ"
|
import b from "target.typ"
|
||||||
test(b, 1)
|
test(b, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#test(b, 1)
|
#test(b, 1)
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
// Error: 21-43 file not found
|
// Error: 19-41 file not found
|
||||||
let x = include "importable/chap3.typ"
|
let x = include "importable/chap3.typ"
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
---
|
---
|
||||||
// Assignment is right-associative.
|
// Assignment is right-associative.
|
||||||
{
|
{
|
||||||
let x = 1
|
let x = 1
|
||||||
let y = 2
|
let y = 2
|
||||||
x = y = "ok"
|
x = y = "ok"
|
||||||
test(x, none)
|
test(x, none)
|
||||||
test(y, "ok")
|
test(y, "ok")
|
||||||
}
|
}
|
||||||
|
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
// Test plus and minus.
|
// Test plus and minus.
|
||||||
#for v in (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt, 6.3fr) {
|
#for v in (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt, 6.3fr) {
|
||||||
// Test plus.
|
// Test plus.
|
||||||
test(+v, v)
|
test(+v, v)
|
||||||
|
|
||||||
// Test minus.
|
// Test minus.
|
||||||
test(-v, -1 * v)
|
test(-v, -1 * v)
|
||||||
test(--v, v)
|
test(--v, v)
|
||||||
|
|
||||||
// Test combination.
|
// Test combination.
|
||||||
test(-++ --v, -v)
|
test(-++ --v, -v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#test(-(4 + 2), 6-12)
|
#test(-(4 + 2), 6-12)
|
||||||
@ -50,24 +50,24 @@
|
|||||||
// Mathematical identities.
|
// Mathematical identities.
|
||||||
#let nums = (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt)
|
#let nums = (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt)
|
||||||
#for v in nums {
|
#for v in nums {
|
||||||
// Test plus and minus.
|
// Test plus and minus.
|
||||||
test(v + v - v, v)
|
test(v + v - v, v)
|
||||||
test(v - v - v, -v)
|
test(v - v - v, -v)
|
||||||
|
|
||||||
// Test plus/minus and multiplication.
|
// Test plus/minus and multiplication.
|
||||||
test(v - v, 0 * v)
|
test(v - v, 0 * v)
|
||||||
test(v + v, 2 * v)
|
test(v + v, 2 * v)
|
||||||
|
|
||||||
// Integer addition does not give a float.
|
// Integer addition does not give a float.
|
||||||
if type(v) != "integer" {
|
if type(v) != "integer" {
|
||||||
test(v + v, 2.0 * v)
|
test(v + v, 2.0 * v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Linears cannot be divided by themselves.
|
// Linears cannot be divided by themselves.
|
||||||
if type(v) != "linear" {
|
if type(v) != "linear" {
|
||||||
test(v / v, 1.0)
|
test(v / v, 1.0)
|
||||||
test(v / v == 1, true)
|
test(v / v == 1, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure length, relative and linear
|
// Make sure length, relative and linear
|
||||||
@ -76,15 +76,15 @@
|
|||||||
// - divided by floats.
|
// - divided by floats.
|
||||||
#let dims = (10pt, 30%, 50% + 3cm)
|
#let dims = (10pt, 30%, 50% + 3cm)
|
||||||
#for a in dims {
|
#for a in dims {
|
||||||
for b in dims {
|
for b in dims {
|
||||||
test(type(a + b), type(a - b))
|
test(type(a + b), type(a - b))
|
||||||
}
|
}
|
||||||
|
|
||||||
for b in (7, 3.14) {
|
for b in (7, 3.14) {
|
||||||
test(type(a * b), type(a))
|
test(type(a * b), type(a))
|
||||||
test(type(b * a), type(a))
|
test(type(b * a), type(a))
|
||||||
test(type(a / b), type(a))
|
test(type(a / b), type(a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -4,19 +4,19 @@
|
|||||||
// Should output `2 4 6 8 10`.
|
// Should output `2 4 6 8 10`.
|
||||||
#let i = 0
|
#let i = 0
|
||||||
#while i < 10 [
|
#while i < 10 [
|
||||||
{ i += 2 }
|
{ i += 2 }
|
||||||
#i
|
#i
|
||||||
]
|
]
|
||||||
|
|
||||||
// Should output `Hi`.
|
// Should output `Hi`.
|
||||||
#let iter = true
|
#let iter = true
|
||||||
#while iter {
|
#while iter {
|
||||||
iter = false
|
iter = false
|
||||||
"Hi."
|
"Hi."
|
||||||
}
|
}
|
||||||
|
|
||||||
#while false {
|
#while false {
|
||||||
dont-care
|
dont-care
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -36,8 +36,8 @@
|
|||||||
---
|
---
|
||||||
// Make sure that we terminate and don't complain multiple times.
|
// Make sure that we terminate and don't complain multiple times.
|
||||||
#while true {
|
#while true {
|
||||||
// Error: 5-9 unknown variable
|
// Error: 3-7 unknown variable
|
||||||
nope
|
nope
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
// the only argument to a function is a template, the parentheses can be omitted
|
// the only argument to a function is a template, the parentheses can be omitted
|
||||||
// (i.e. `f[a]` is the same as `f([a])`).
|
// (i.e. `f[a]` is the same as `f([a])`).
|
||||||
#box[
|
#box[
|
||||||
// Backslash adds a forced line break.
|
// Backslash adds a forced line break.
|
||||||
#university \
|
#university \
|
||||||
#faculty \
|
#faculty \
|
||||||
Sekretariat MA \
|
Sekretariat MA \
|
||||||
Dr. Max Mustermann \
|
Dr. Max Mustermann \
|
||||||
Ola Nordmann, John Doe
|
Ola Nordmann, John Doe
|
||||||
]
|
]
|
||||||
#align(right, box[*WiSe 2019/2020* \ Woche 3])
|
#align(right, box[*WiSe 2019/2020* \ Woche 3])
|
||||||
|
|
||||||
@ -29,10 +29,10 @@
|
|||||||
// If the last argument to a function is a template, we can also place it behind
|
// If the last argument to a function is a template, we can also place it behind
|
||||||
// the parentheses.
|
// the parentheses.
|
||||||
#align(center)[
|
#align(center)[
|
||||||
// Markdown-like syntax for headings.
|
// Markdown-like syntax for headings.
|
||||||
==== 3. Übungsblatt Computerorientierte Mathematik II #v(4mm)
|
==== 3. Übungsblatt Computerorientierte Mathematik II #v(4mm)
|
||||||
*Abgabe: 03.05.2019* (bis 10:10 Uhr in MA 001) #v(4mm)
|
*Abgabe: 03.05.2019* (bis 10:10 Uhr in MA 001) #v(4mm)
|
||||||
*Alle Antworten sind zu beweisen.*
|
*Alle Antworten sind zu beweisen.*
|
||||||
]
|
]
|
||||||
|
|
||||||
*1. Aufgabe* #align(right)[(1 + 1 + 2 Punkte)]
|
*1. Aufgabe* #align(right)[(1 + 1 + 2 Punkte)]
|
||||||
|
@ -5,22 +5,22 @@
|
|||||||
|
|
||||||
Auto-sized circle. \
|
Auto-sized circle. \
|
||||||
#circle(fill: rgb("eb5278"))[
|
#circle(fill: rgb("eb5278"))[
|
||||||
#align!(center, center)
|
#align!(center, center)
|
||||||
But, soft!
|
But, soft!
|
||||||
]
|
]
|
||||||
|
|
||||||
Center-aligned rect in auto-sized circle.
|
Center-aligned rect in auto-sized circle.
|
||||||
#circle(fill: forest)[
|
#circle(fill: forest)[
|
||||||
#align!(center, center)
|
#align!(center, center)
|
||||||
#rect!(fill: conifer)
|
#rect!(fill: conifer)
|
||||||
#pad!(5pt)
|
#pad!(5pt)
|
||||||
But, soft!
|
But, soft!
|
||||||
]
|
]
|
||||||
|
|
||||||
100%-width rect in auto-sized circle. \
|
100%-width rect in auto-sized circle. \
|
||||||
#circle(fill: forest)[
|
#circle(fill: forest)[
|
||||||
#rect!(width: 100%, fill: conifer)
|
#rect!(width: 100%, fill: conifer)
|
||||||
But, soft! what light through yonder window breaks?
|
But, soft! what light through yonder window breaks?
|
||||||
]
|
]
|
||||||
|
|
||||||
Expanded by height.
|
Expanded by height.
|
||||||
@ -29,11 +29,11 @@ Expanded by height.
|
|||||||
---
|
---
|
||||||
// Test relative sizing.
|
// Test relative sizing.
|
||||||
#rect(width: 100%, height: 50pt, fill: rgb("aaa"))[
|
#rect(width: 100%, height: 50pt, fill: rgb("aaa"))[
|
||||||
#align!(center, center)
|
#align!(center, center)
|
||||||
#font!(fill: white)
|
#font!(fill: white)
|
||||||
#circle(radius: 10pt, fill: eastern)[A]
|
#circle(radius: 10pt, fill: eastern)[A]
|
||||||
#circle(height: 60%, fill: eastern)[B]
|
#circle(height: 60%, fill: eastern)[B]
|
||||||
#circle(width: 20% + 20pt, fill: eastern)[C]
|
#circle(width: 20% + 20pt, fill: eastern)[C]
|
||||||
]
|
]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
---
|
---
|
||||||
100% rect in 100% ellipse in fixed rect. \
|
100% rect in 100% ellipse in fixed rect. \
|
||||||
#rect(width: 3cm, height: 2cm, fill: rgb("2a631a"))[
|
#rect(width: 3cm, height: 2cm, fill: rgb("2a631a"))[
|
||||||
#ellipse!(width: 100%, height: 100%, fill: forest)
|
#ellipse!(width: 100%, height: 100%, fill: forest)
|
||||||
#rect!(width: 100%, height: 100%, fill: conifer)
|
#rect!(width: 100%, height: 100%, fill: conifer)
|
||||||
#align!(center, center)
|
#align!(center, center)
|
||||||
Stuff inside an ellipse!
|
Stuff inside an ellipse!
|
||||||
]
|
]
|
||||||
|
|
||||||
Auto-sized ellipse. \
|
Auto-sized ellipse. \
|
||||||
#ellipse(fill: conifer)[
|
#ellipse(fill: conifer)[
|
||||||
But, soft! what light through yonder window breaks?
|
But, soft! what light through yonder window breaks?
|
||||||
]
|
]
|
||||||
|
@ -3,24 +3,24 @@
|
|||||||
---
|
---
|
||||||
Auto-sized square. \
|
Auto-sized square. \
|
||||||
#square(fill: eastern)[
|
#square(fill: eastern)[
|
||||||
#align!(center)
|
#align!(center)
|
||||||
#pad!(5pt)
|
#pad!(5pt)
|
||||||
#font!(fill: white, weight: bold)
|
#font!(fill: white, weight: bold)
|
||||||
Typst
|
Typst
|
||||||
]
|
]
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test height overflow.
|
// Test height overflow.
|
||||||
#page!(width: 75pt, height: 100pt)
|
#page!(width: 75pt, height: 100pt)
|
||||||
#square(fill: conifer)[
|
#square(fill: conifer)[
|
||||||
But, soft! what light through yonder window breaks?
|
But, soft! what light through yonder window breaks?
|
||||||
]
|
]
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test width overflow.
|
// Test width overflow.
|
||||||
#page!(width: 100pt, height: 75pt)
|
#page!(width: 100pt, height: 75pt)
|
||||||
#square(fill: conifer)[
|
#square(fill: conifer)[
|
||||||
But, soft! what light through yonder window breaks?
|
But, soft! what light through yonder window breaks?
|
||||||
]
|
]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -5,52 +5,52 @@
|
|||||||
|
|
||||||
#page!(width: 100pt, height: 140pt)
|
#page!(width: 100pt, height: 140pt)
|
||||||
#grid(
|
#grid(
|
||||||
columns: (auto, 1fr, 3fr, 0.25cm, 3%, 2mm + 10%),
|
columns: (auto, 1fr, 3fr, 0.25cm, 3%, 2mm + 10%),
|
||||||
rect(0.5cm, rgb("2a631a")),
|
rect(0.5cm, rgb("2a631a")),
|
||||||
rect(100%, forest),
|
rect(100%, forest),
|
||||||
rect(100%, conifer),
|
rect(100%, conifer),
|
||||||
rect(100%, rgb("ff0000")),
|
rect(100%, rgb("ff0000")),
|
||||||
rect(100%, rgb("00ff00")),
|
rect(100%, rgb("00ff00")),
|
||||||
rect(80%, rgb("00faf0")),
|
rect(80%, rgb("00faf0")),
|
||||||
rect(1cm, rgb("00ff00")),
|
rect(1cm, rgb("00ff00")),
|
||||||
rect(0.5cm, rgb("2a631a")),
|
rect(0.5cm, rgb("2a631a")),
|
||||||
rect(100%, forest),
|
rect(100%, forest),
|
||||||
rect(100%, conifer),
|
rect(100%, conifer),
|
||||||
rect(100%, rgb("ff0000")),
|
rect(100%, rgb("ff0000")),
|
||||||
rect(100%, rgb("00ff00")),
|
rect(100%, rgb("00ff00")),
|
||||||
)
|
)
|
||||||
|
|
||||||
#grid()
|
#grid()
|
||||||
|
|
||||||
---
|
---
|
||||||
#grid(
|
#grid(
|
||||||
columns: (auto, auto, 40%),
|
columns: (auto, auto, 40%),
|
||||||
gutter-columns: (1fr,),
|
gutter-columns: (1fr,),
|
||||||
gutter-rows: (1fr,),
|
gutter-rows: (1fr,),
|
||||||
rect(fill: eastern)[dddaa aaa aaa],
|
rect(fill: eastern)[dddaa aaa aaa],
|
||||||
rect(fill: conifer)[ccc],
|
rect(fill: conifer)[ccc],
|
||||||
rect(width: 100%, fill: rgb("dddddd"))[aaa],
|
rect(width: 100%, fill: rgb("dddddd"))[aaa],
|
||||||
)
|
)
|
||||||
|
|
||||||
---
|
---
|
||||||
#page!(height: 3cm, width: 2cm)
|
#page!(height: 3cm, width: 2cm)
|
||||||
#grid(
|
#grid(
|
||||||
columns: (1fr, 1cm, 1fr, 1fr),
|
columns: (1fr, 1cm, 1fr, 1fr),
|
||||||
column-dir: ttb,
|
column-dir: ttb,
|
||||||
rows: (auto, 1fr),
|
rows: (auto, 1fr),
|
||||||
rect(height: 100%, fill: rgb("222222"))[foo],
|
rect(height: 100%, fill: rgb("222222"))[foo],
|
||||||
rect(height: 100%, fill: rgb("547d0a"))[bar],
|
rect(height: 100%, fill: rgb("547d0a"))[bar],
|
||||||
rect(height: 100%, fill: eastern)[hab],
|
rect(height: 100%, fill: eastern)[hab],
|
||||||
rect(height: 100%, fill: conifer)[baz],
|
rect(height: 100%, fill: conifer)[baz],
|
||||||
rect(height: 100%, width: 100%, fill: rgb("547d0a"))[bar],
|
rect(height: 100%, width: 100%, fill: rgb("547d0a"))[bar],
|
||||||
)
|
)
|
||||||
|
|
||||||
---
|
---
|
||||||
#page!(height: 3cm, margins: 0pt)
|
#page!(height: 3cm, margins: 0pt)
|
||||||
#align!(center)
|
#align!(center)
|
||||||
#grid(
|
#grid(
|
||||||
columns: (1fr,),
|
columns: (1fr,),
|
||||||
rows: (1fr, auto, 2fr),
|
rows: (1fr, auto, 2fr),
|
||||||
[], rect(width: 100%)[A bit more to the top], [],
|
[], rect(width: 100%)[A bit more to the top], [],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,27 +3,27 @@
|
|||||||
---
|
---
|
||||||
#page!(width: 12cm, height: 2.5cm)
|
#page!(width: 12cm, height: 2.5cm)
|
||||||
#grid(
|
#grid(
|
||||||
columns: 5,
|
columns: 5,
|
||||||
gutter-columns: (2fr, 1fr, 1fr),
|
gutter-columns: (2fr, 1fr, 1fr),
|
||||||
gutter-rows: 4 * (6pt,),
|
gutter-rows: 4 * (6pt,),
|
||||||
[*Quarter*],
|
[*Quarter*],
|
||||||
[Expenditure],
|
[Expenditure],
|
||||||
[External Revenue],
|
[External Revenue],
|
||||||
[Financial ROI],
|
[Financial ROI],
|
||||||
[_total_],
|
[_total_],
|
||||||
[*Q1*],
|
[*Q1*],
|
||||||
[173,472.57 \$],
|
[173,472.57 \$],
|
||||||
[472,860.91 \$],
|
[472,860.91 \$],
|
||||||
[51,286.84 \$],
|
[51,286.84 \$],
|
||||||
[_350,675.18 \$_],
|
[_350,675.18 \$_],
|
||||||
[*Q2*],
|
[*Q2*],
|
||||||
[93,382.12 \$],
|
[93,382.12 \$],
|
||||||
[439,382.85 \$],
|
[439,382.85 \$],
|
||||||
[-1,134.30 \$],
|
[-1,134.30 \$],
|
||||||
[_344,866.43 \$_],
|
[_344,866.43 \$_],
|
||||||
[*Q3*],
|
[*Q3*],
|
||||||
[96,421.49 \$],
|
[96,421.49 \$],
|
||||||
[238,583.54 \$],
|
[238,583.54 \$],
|
||||||
[3,497.12 \$],
|
[3,497.12 \$],
|
||||||
[_145,659.17 \$_],
|
[_145,659.17 \$_],
|
||||||
)
|
)
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
---
|
---
|
||||||
#page!(width: 5cm, height: 3cm)
|
#page!(width: 5cm, height: 3cm)
|
||||||
#grid(
|
#grid(
|
||||||
columns: 2,
|
columns: 2,
|
||||||
gutter-rows: 3 * (8pt,),
|
gutter-rows: 3 * (8pt,),
|
||||||
[Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
[Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
||||||
|
|
||||||
Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis.],
|
Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis.],
|
||||||
[Text that is rather short],
|
[Text that is rather short],
|
||||||
[Fireflies],
|
[Fireflies],
|
||||||
[Critical],
|
[Critical],
|
||||||
[Decorum],
|
[Decorum],
|
||||||
[Rampage],
|
[Rampage],
|
||||||
)
|
)
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -20,60 +20,60 @@
|
|||||||
// that.
|
// that.
|
||||||
#page!(width: 5cm, height: 2cm)
|
#page!(width: 5cm, height: 2cm)
|
||||||
#grid(
|
#grid(
|
||||||
columns: 4 * (1fr,),
|
columns: 4 * (1fr,),
|
||||||
gutter-rows: (10pt,),
|
gutter-rows: (10pt,),
|
||||||
gutter-columns: (0pt, 10%),
|
gutter-columns: (0pt, 10%),
|
||||||
image("../../res/rhino.png"),
|
image("../../res/rhino.png"),
|
||||||
align(right, rect(width: 100%, fill: eastern)[LoL]),
|
align(right, rect(width: 100%, fill: eastern)[LoL]),
|
||||||
[rofl],
|
[rofl],
|
||||||
[\ A] * 3,
|
[\ A] * 3,
|
||||||
[Ha!\ ] * 3,
|
[Ha!\ ] * 3,
|
||||||
)
|
)
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test two columns in the same row overflowing by a different amount.
|
// Test two columns in the same row overflowing by a different amount.
|
||||||
#page!(width: 5cm, height: 2cm)
|
#page!(width: 5cm, height: 2cm)
|
||||||
#grid(
|
#grid(
|
||||||
columns: 3 * (1fr,),
|
columns: 3 * (1fr,),
|
||||||
gutter-rows: (8pt,),
|
gutter-rows: (8pt,),
|
||||||
gutter-columns: (0pt, 10%),
|
gutter-columns: (0pt, 10%),
|
||||||
[A], [B], [C],
|
[A], [B], [C],
|
||||||
[Ha!\ ] * 6,
|
[Ha!\ ] * 6,
|
||||||
[rofl],
|
[rofl],
|
||||||
[\ A] * 3,
|
[\ A] * 3,
|
||||||
[hello],
|
[hello],
|
||||||
[darkness],
|
[darkness],
|
||||||
[my old]
|
[my old]
|
||||||
)
|
)
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test grid within a grid, overflowing.
|
// Test grid within a grid, overflowing.
|
||||||
#page!(width: 5cm, height: 2.25cm)
|
#page!(width: 5cm, height: 2.25cm)
|
||||||
#grid(
|
#grid(
|
||||||
columns: 4 * (1fr,),
|
columns: 4 * (1fr,),
|
||||||
gutter-rows: (10pt,),
|
gutter-rows: (10pt,),
|
||||||
gutter-columns: (0pt, 10%),
|
gutter-columns: (0pt, 10%),
|
||||||
[A], [B], [C], [D],
|
[A], [B], [C], [D],
|
||||||
grid(columns: 2, [A], [B], [C\ ]*3, [D]),
|
grid(columns: 2, [A], [B], [C\ ]*3, [D]),
|
||||||
align(right, rect(width: 100%, fill: eastern)[LoL]),
|
align(right, rect(width: 100%, fill: eastern)[LoL]),
|
||||||
[rofl],
|
[rofl],
|
||||||
[E\ ]*4,
|
[E\ ]*4,
|
||||||
)
|
)
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test partition of `fr` units before and after multi-region layout.
|
// Test partition of `fr` units before and after multi-region layout.
|
||||||
#page!(width: 5cm, height: 4cm)
|
#page!(width: 5cm, height: 4cm)
|
||||||
#grid(
|
#grid(
|
||||||
columns: 2 * (1fr,),
|
columns: 2 * (1fr,),
|
||||||
rows: (1fr, 2fr, auto, 1fr, 1cm),
|
rows: (1fr, 2fr, auto, 1fr, 1cm),
|
||||||
gutter-rows: 4 * (10pt,),
|
gutter-rows: 4 * (10pt,),
|
||||||
rect(height: 100%, width: 100%, fill: rgb("ff0000"))[No height],
|
rect(height: 100%, width: 100%, fill: rgb("ff0000"))[No height],
|
||||||
[foo],
|
[foo],
|
||||||
rect(height: 100%, width: 100%, fill: rgb("fc0030"))[Still no height],
|
rect(height: 100%, width: 100%, fill: rgb("fc0030"))[Still no height],
|
||||||
[bar],
|
[bar],
|
||||||
[The nature of being itself is in question. Am I One? Am I Many? What is being alive?],
|
[The nature of being itself is in question. Am I One? Am I Many? What is being alive?],
|
||||||
[baz],
|
[baz],
|
||||||
[The answer],
|
[The answer],
|
||||||
[42],
|
[42],
|
||||||
[Other text of interest],
|
[Other text of interest],
|
||||||
)
|
)
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
// Set all margins at once.
|
// Set all margins at once.
|
||||||
#page(margins: 30pt)[
|
#page(margins: 30pt)[
|
||||||
#align(top, left)[TL]
|
#align(top, left)[TL]
|
||||||
#align(bottom, right)[BR]
|
#align(bottom, right)[BR]
|
||||||
]
|
]
|
||||||
|
|
||||||
// Set individual margins.
|
// Set individual margins.
|
||||||
|
@ -9,9 +9,9 @@ First of two
|
|||||||
// Make sure that you can't do page related stuff in a container.
|
// Make sure that you can't do page related stuff in a container.
|
||||||
A
|
A
|
||||||
#box[
|
#box[
|
||||||
B
|
B
|
||||||
#pagebreak()
|
#pagebreak()
|
||||||
#page("a4")[]
|
#page("a4")[]
|
||||||
]
|
]
|
||||||
C
|
C
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
---
|
---
|
||||||
#let rect(width, fill) = rect(width: width, height: 1cm, fill: fill)
|
#let rect(width, fill) = rect(width: width, height: 1cm, fill: fill)
|
||||||
#stack(
|
#stack(
|
||||||
rect(2cm, rgb("2a631a")),
|
rect(2cm, rgb("2a631a")),
|
||||||
rect(3cm, forest),
|
rect(3cm, forest),
|
||||||
rect(1cm, conifer),
|
rect(1cm, conifer),
|
||||||
)
|
)
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -13,6 +13,6 @@
|
|||||||
|
|
||||||
#let rect(width, fill) = rect(width: 1cm, height: 0.4cm, fill: fill)
|
#let rect(width, fill) = rect(width: 1cm, height: 0.4cm, fill: fill)
|
||||||
#box(height: 0.5cm, stack(
|
#box(height: 0.5cm, stack(
|
||||||
rect(3cm, forest),
|
rect(3cm, forest),
|
||||||
rect(1cm, conifer),
|
rect(1cm, conifer),
|
||||||
))
|
))
|
||||||
|
@ -37,5 +37,5 @@ No = heading
|
|||||||
|
|
||||||
// Code blocks continue heading.
|
// Code blocks continue heading.
|
||||||
= A {
|
= A {
|
||||||
"B"
|
"B"
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
---
|
---
|
||||||
// Test that alignment depends on the paragraph's full width.
|
// Test that alignment depends on the paragraph's full width.
|
||||||
#box[
|
#box[
|
||||||
Hello World \
|
Hello World \
|
||||||
#align(right)[World]
|
#align(right)[World]
|
||||||
]
|
]
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test that a line with multiple alignments respects the paragraph's full
|
// Test that a line with multiple alignments respects the paragraph's full
|
||||||
// width.
|
// width.
|
||||||
#box[
|
#box[
|
||||||
Hello #align(center)[World] \
|
Hello #align(center)[World] \
|
||||||
Hello from the World
|
Hello from the World
|
||||||
]
|
]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -26,7 +26,7 @@ Emoji: 🐪, 🌋, 🏞
|
|||||||
|
|
||||||
// Math.
|
// Math.
|
||||||
#font("Latin Modern Math")[
|
#font("Latin Modern Math")[
|
||||||
∫ 𝛼 + 3𝛽 d𝑡
|
∫ 𝛼 + 3𝛽 d𝑡
|
||||||
]
|
]
|
||||||
|
|
||||||
// Colors.
|
// Colors.
|
||||||
@ -37,8 +37,8 @@ Emoji: 🐪, 🌋, 🏞
|
|||||||
|
|
||||||
#page!(width: 170pt)
|
#page!(width: 170pt)
|
||||||
#let try(top, bottom) = rect(fill: conifer)[
|
#let try(top, bottom) = rect(fill: conifer)[
|
||||||
#font!(top-edge: top, bottom-edge: bottom)
|
#font!(top-edge: top, bottom-edge: bottom)
|
||||||
`From `#top` to `#bottom
|
`From `#top` to `#bottom
|
||||||
]
|
]
|
||||||
|
|
||||||
#try(ascender, descender)
|
#try(ascender, descender)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user