Typst (.typ)
kakemono convert book.pdf -o book.typ (or --format typst) writes a Typst
document, from the same analysis, that compiles as it is with typst compile book.typ (no TeX
installation; the fonts it uses by default come with Typst). Typst breaks each paragraph as a
whole, so justified lines have no wide gaps, and keeps every footnote on the page of its call: it
is the output for printing a book, a translated one above all.
The file starts with its settings, which can be changed there: the layout (doc-layout), the page
size (paper: "a4", "a5", (width: 110mm, height: 180mm) for a phone, …), the fonts
(fonts: each character is taken from the first font that has it; Libertinus Serif, the default,
has the Vietnamese letters), the size of the text, the language (lang: hyphenation and quotation
marks; Vietnamese, which is not hyphenated, is found from the text) and a cover picture
(cover). The template comes next: the Typst functions (kakemono-…) that lay the document
out, which can be changed too.
There are two layouts, chosen with --layout or from the document (auto, the default):
book, for a document with chapters and nothing of a paper (no abstract, references or arXiv identifier): A5 pages, a title page, chapters that open on a right-hand page a third of the way down, their first words in small capitals (except in Vietnamese, which most fonts lack small capitals for) and their notes numbered from 1; mirrored margins; running heads with the title of the book on the left-hand pages and that of the chapter on the right-hand ones, none on the title page, on the opening page of a chapter (which has its number at the foot) or on a blank page;article: A4 pages, the title, authors and abstract at the top of the first page, page numbers at the foot.
In both:
- headings become Typst headings, without numbers of their own (theirs are part of their text);
the outermost level is
=; lists keep the markers of the document; - a table of contents is Typst’s own (
outline), with the page numbers of the new layout and links to the headings; - rebuilt tables become
tables with rules above, below and under the header and their spanning cells; text is set in a smaller size and wraps when the table is wider than the text; - formulas whose structure is clear become Typst math (with their number at the right), the others
pictures; formulas inside the text become
$…$; - footnotes and added notes (
<note>in the editable JSON) become Typst footnotes (see Footnotes); - line breaks (the lines of a poem) are kept;
- figures are pictures, always written to
<name>_assets/next to the file (--image-dirto choose it): Typst cannot embed them in its source, so--images inlineis refused; a picture is as wide as in the PDF, at most as wide as the text, and stays on one page with its caption; - figures and tables stay where they were in the text (they are not floats) and keep the label of their caption (“Figure 3:”); citations and references to figures, tables and sections are links, as are web addresses.
--scale and --equations apply. The tests compile the Typst output with Typst 0.15.