Org-mode to Typst exporter.
(use-package ox-typst
:after org)
If you use org-export-dispatch
, then the Typst exporter is
available with the y
prefix.
Typst code can be directly used within org-mode by using the
#+TYPST:
. The provided string is not escaped by the exporter and is
put directly into the output file.
#+TYPST: #set page(paper: "a4")
Alternatively use an export block.
#+BEGIN_EXPORT typst
#set page(paper: "a4")
#+END_EXPORT
Use Typst rules to change the appearance of your document. Include these rules at the top level of the document or above the target element. It might be useful to create a file containing Typst rules and include them like below.
#+INCLUDE: "./my-theme.typ" export typst
Alternatively, rules can be put into an export block (Insert Typst Code).
Typst supports citing and bibliography by default.
#+BIBLIOGRAPHY: ./test.bib
#+print_bibliography: :title Custom Bibliography Title
#+CITE_EXPORT: typst apa
Supported styles are listed here. The second argument (in this case
apa
) is stringified and put into the bibliography
function as the
style argument (like bibliography("./test.bib", style: "apa")
).
Currently LaTeX math snippets are not supported. It is currently not possible for us to translate these elements into Typst code.
Mabye we should one of the following projects for that:
- https://github.com/msakuta/latypst
- Translate LaTeX snippets to roughly equivalent Typst snippets
- https://github.com/mitex-rs/mitex
- Emulate LaTeX inside Typst
Take a look at test/test.org
to get an idea how to use the different
org-mode statements with Typst. For real examples look in the
examples
folder.
If you want to write a letter using a third party package
(e.g. https://github.com/Sematre/typst-letter-pro), then take a look
at examples/letter.org
.
If you want more examples, maybe look into the tests. The tests contain small Org snippets and their Typst representation.
The tests contain small Org snippets and their Typst output. Changing the exporter requires to re-run the exporter on all Org files. One should manually check if the output matches the expectation. If the output matches the expectation, the newly generated files become the new golden output.
emacs --batch -l tests/test.el -f org-typst-test-generate
emacs --batch -l tests/test.el -f org-typst-test-run
It is also possible to use these functions inside Emacs. Navigate to the
tests/test.el
file and run eval-buffer
. The ox-typst.el
file is
automatically re-loaded from the current Git repository when evaluating the test
buffer.