This is an opinionated small program in development that transpiles an Obsidian vault to a single LaTeX file or an mdbook
book. It aims to:
- allow markdown to include LaTeX theorem/figure environment and references
- and provide WYSIWYG experience in the Obsidian markdown editor.
The following video demonstrates the usage.
demo.mp4
The code is mainly for myself to transpile a draft of mine. It has a lot of rough corners so it is not recommended for any general use as of now.
LaTeX takes too much mental space for drafting by requiring users to adhere to complicated syntax with no immediate feedback on how the result will look like.
- Typst is a promising project, but as academy standard expects LaTeX files right now I can't use it immediately for my needs.
- Obsidian is a nice markdown what-you-see-is-what-you-mean editor that still gives the full control to users to edit the markdown file as-is. But it does not support LaTeX theorem environments natively.
With this, I'm using Pandoc to transpile an Obsidian vault to a LaTeX project.
This software uses a subset of Markdown to represent environments in LaTeX often used for math papers. They are designed look like the LaTeX rendering even in vanilla Obsidian and other markdown editors.
The definitions are not precise and subject to change anytime.
Definition [theorem-environment]. A theorem environment is a block quote that contains the following elements. ^def-theorem-environment
- Right after the block quote marker, the text
__EnvType [EnvName].__
(including the whitespace at the end) follows.
EnvType
should be one of the followings in the table.EnvName
can be any name, but it only consists of lowercase alphabets, dash-
, and should start with an alphabet.- Then any contents can be inside the block quote.
- It should have exactly one block identifier somewhere inside the block quote which is exactly
^EnvAbbr-EnvName
.
EnvAbbr
should correspond toEnvType
as the following table.- The identifier should be positioned at the very end of a line with no trailing spaces.
EnvType | EnvAbbr |
---|---|
Theorem | thm |
Lemma | lem |
Definition | def |
Corollary | cor |
Remark | rem |
Figure | fig |
Proof. A proof environment is simply a series of paragraphs, with the first letters of the first paragraph starting with _Proof._
, and the last string of the last paragraph ending with the symbol □
(□). □
Figure [sample]. This is a sample figure. A figure environment is followed by a single line of image link with no blockquote marker. ^fig-sample
To refer to a theorem or figure environment, we use Obsidian's way to refer a block identifier like [[#^def-theorem-environment]] or [[#^fig-sample]].
We only use double brackets [[]]
for referencing environments.
For the ease of use, I use the following Obsidian plugins.
- Latex Suite to type environments easily.
- Simply typing
> thm
expands to aTheorem
environment. - Then by typing the name of the environment name, and pressing tab, it autopopulates the name.
- Simply typing
- Copy Block Link to copy the reference of a theorem easily.