Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified src/lib.pdf
Binary file not shown.
1,712 changes: 1,022 additions & 690 deletions src/lib.typ

Large diffs are not rendered by default.

Binary file removed src/main.pdf
Binary file not shown.
Binary file added test/identation.pdf
Binary file not shown.
39 changes: 39 additions & 0 deletions test/identation.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#import "@local/texporter:0.1.0"

#show: texporter.texporter-build

= Introduction

#lorem(50)

#figure(caption: [My caption])[
#box(width: 100pt, height: 100pt, stroke: 2pt, fill: silver)
]

#lorem(50)

#figure(caption: [My caption])[
#box(width: 100pt, height: 100pt, stroke: 2pt, fill: silver)
]

#lorem(50)

- First item
$
a = b
$<eq:1>
- Second item
$
b = c
$<eq:2>
+ Subitem in second item
$
c = a
$<eq:3>

+ First item
+ Second item
+ Third item
- Subitem in third item
- Subsubitem
- Second subitem
Binary file modified test/main.pdf
Binary file not shown.
19 changes: 14 additions & 5 deletions test/main.typ
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#show: texporter-build



= Introduction

A brief *introduction*.
Expand All @@ -14,8 +16,15 @@ A brief *introduction*.
== Maxwell equations

$
nabla dot bold(E) &= ρ/ε_0 \
nabla dot bold(B) &= 0 \
nabla times bold(E) &= -pdv(bold(B), t) \
nabla times bold(B) &= μ_0 (bold(J) + ε_0 pdv(bold(E), t))
$
nabla dot bold(E) & = ρ/ε_0 \
nabla dot bold(B) & = 0 \
nabla times bold(E) & = -pdv(bold(B), t) \
nabla times bold(B) & = μ_0 (bold(J) + ε_0 pdv(bold(E), t))
$

== Colored equations

This is currently handled wrong:
$
text(#red, q) = text(#blue, p)
$
Binary file added test/symbols.pdf
Binary file not shown.
125 changes: 125 additions & 0 deletions test/symbols.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#import "@local/texporter:0.1.0"

#let get-symbol-variants(base, s) = {
if type(s) == module {
dictionary(s)
.pairs()
.map(((name, ss)) => {
get-symbol-variants(repr(s).slice(8, -1) + "." + name, ss)
})
.sum()
} else if type(s) == symbol {
let variants = eval(repr(s).slice(6))
if type(variants) == str {
((base, variants),)
} else if type(variants) == array {
variants.map(variant => {
if type(variant) == str {
(base, variant)
} else {
(base + "." + variant.at(0), variant.at(1))
}
})
}
}
}

#let depricated = (
"Kai",
"alef",
"angle.l",
"angle.r",
"angle.oblique",
"angle.l",
"angle.r",
"angle.right.sq",
"angle.spheric.top",
"ast.small",
"ast.circle",
"backslash.circle",
"bar.circle",
"bet",
"brace.double",
"bracket.double",
"circle.nested",
"dalet",
"dash.circle",
"diff",
"div.circle",
"dot.circle",
"eq.circle",
"eq.small",
"franc",
"gimmel",
"gt.circle",
"gt.small",
"integral.sect",
"kai",
"lt.circle",
"lt.small",
"minus.circle",
"parallel.circle",
"paren.double",
"perp.circle",
"planck.reduce",
"plus.circle",
"plus.small",
"quote.angle",
"sect",
"shell.double",
"shin",
"times.circle",
)

#let all-symbols = (
(
dictionary(sym).pairs().map(((name, s)) => get-symbol-variants(name, s))
)
.sum()
.filter(((name, s)) => not depricated.any(d => name.starts-with(d)))
)

#set text(10pt)
#set page(margin: 10mm)

In the following table we list all symbols available in `std.sym` module with corresponding rendered
symbol and the result of conversion to latex using `texporter`. The symbols marked with "#text(
orange,
"(literal)",
)" are inserted to latex code literally as the unicode character, which corresponds to cases when
either latex supports that symbol direcly, or, more likely, it is not supported by `texporter` yet.


#show: columns.with(2, gutter: 1%)
#table(
columns: (auto, 8em, auto, auto),
table.header(
[*#sym.numero*], [*symbol code \ in typst*], [*symbol \ string*], [*symbol code \ in tex*]
),
// [typst name], [symbol], [tex code],
// [typst name], [symbol], [tex code],
..all-symbols
.enumerate()
.map(((i, (name, s))) => {
let symbol_con = eval("$" + name + "$") // errorbar.circle gives warning for depricated bar.circle, etc
let symbol_ltx = texporter.render-latex(symbol_con, 0, 0).first().slice(1, -1)
let symbol_str = if symbol_con.body.has("text") { symbol_con.body.text } else {
"Symbol has no text"
}

let symbol_typst = name
.split(".")
.enumerate()
.map(((i, name)) => if i != 0 { raw("." + name) } else { raw(name) })
.map(r => box[#r])
.join()

let ltx = if symbol_str in texporter.math-symbols-to-latex {
raw(lang: "tex", symbol_ltx)
} else {
[#raw(lang: "tex", symbol_ltx) #text(orange, "(literal)")]
}
(str(i), symbol_typst, symbol_str, ltx)
})
.flatten(),
)