Typesetting documents, letters, reports, or even books in Typst is not as verbose as LaTeX, but certainly error-prone, given the need for strict syntax. A handful of Sublime Text snippets provided in this repository try to reduce this tedium to as low as practicable.
This repository contains the following custom snippets:
Snippet | Inserts |
---|---|
apdx + tab |
appendix block |
bib + tab |
BibTeX entry |
cod + tab |
python code file |
fig + tab |
figure block |
file + tab |
file |
hd + tab |
set heading no.s |
letter + tab |
letter block |
lnk + tab |
url and link label |
ltmpl + tab |
letter template |
lscape + tab |
set page to landscape |
note + tab |
note block |
ntmpl + tab |
note template |
pb + tab |
page break |
ref + tab |
reference block |
tbl + tab |
table block |
These snippets work when the file under edit is set as a Typst file from the pull-up menu in the status bar. (Suggest installing Typst package.)
The concept of a snippet is simple. Think of a block of pre-formatted text (i.e., a template) that one needs to use often. One can of-course type or copy-paste such blocks of text repeatedly the hard way, or one could instead assign such common blocks of text with an abbreviated keyword, which in turn calls the entire block of text. To ensure such blocks do not accidentally appear while typing the actual content of the note, paper, or report, a trigger is required. The trigger in this case is a tab key.
This is done in two steps, viz., (a) add a repository and then (b) activate it. The how to is described below.
- From Tools > Command Palette... type Add Repository, and in the input box, enter
https://github.com/ckunte/typst-snippets-st
- From Tools > Command Palette... type Install Package, and in the result list, type
typst-snippets-st
and select the thus found package.
From Tools > Command Palette... type Upgrade Package, and select one of the two options presented (i.e., Package Control: Upgrade Package or Package Control: Upgrade/Overwrite All Packages).
A custom build file (e.g. like below: Typst-Cyg.sublime-build
) can be added under Settings > Browse packages > User, with file path edited to suit:
{
"shell_cmd" : "typst compile \"$file_name\"",
"selector" : "source.typ",
"path" : "C:\\Users\\ckun\\misc\\cyg\\bin;$path",
"working_dir" : "$file_path"
}
Then From Tools > Build system, select Typst-Cyg. This will enable building (with Ctrl+B) from source to output (i.e. from .typ to .pdf file) from within Sublime Text.