Marios67 downloadsConvert notes to LaTeX and optionally compile them to PDF using a bundled Python converter script.
⚠️⚠️Additional steps needed before you can use this plugin:
If any problems arise, feel free to email me at [email protected].
This repository doubles as an installable Obsidian plugin that runs converter.py for you, from inside Obsidian.
MariosGkMeng/Straightforward-Obsidian2Latex) in the BRAT plugin.<your-vault>/.obsidian/plugins/, then enable "Ultimate LaTeX Converter" in Obsidian's Community plugins settings.PATH (or set a full path in the plugin settings) — no Python? On Windows, click "Set up bundled Python" in the plugin settings and it'll download a private, self-contained Python + numpy just for this plugin (~30 MB), without touching any system-wide install.PATH, only if you use the "compile to PDF" commands (no bundled option for this one — it requires a full LaTeX distribution like MiKTeX or TeX Live)Open Settings → Ultimate LaTeX Converter:
python, python3, or a full path. Defaults to python.converter.py bundled with this plugin install.convert_note:: [[Note Name]]. The plugin temporarily rewrites this line to point at the note being converted, runs converter.py, then restores the note's original content.latexmk.latexmk.Please cite the following if you use it for publishable work (i.e., if you write your paper in Obsidian, and use this code to print to Latex)
@misc{MariosGkionisObsidian2Latex,
author = {Marios Gkionis},
title = {Straightforward Obsidian to Latex},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/MariosGkMeng/Straightforward-Obsidian2Latex}},
}
example_vault in the repoobsidian.zip file and rename the folder .obsidian (github doesn't allow folders that start with .). This action is needed, because the .obsidian folder I provided includes the community plugins that you need to use (mainly the QuickAdd plugin)example_writing note in Obsidian and check out the functionalities👨💻convert_to_latex noteAre you annoyed by:
Do you just want to be able to seamlessly write formal content in the same software as your notes, and print it from there, without the need to move to external software? Or do you just want to write pretty scientific documents without needing to learn Latex at all (with the exception of the equation environment)?
This Obsidian to Latex translator is complete, straightforward to use, and has no 🐂💩 unnecessary complexity as an end result.
It is the most complete that I have seen among existing ones, since it offers more niche functionalities, such as:
Yes, plugins for Obsidian to Latex already exist, but they have limitations that do not allow the user to write in Obsidian freely. Yes, I'd have loved to contribute to those projects, but I don't know Javascript and Typescript.
I consider LateX a very archaeic tool (Overleaf has come a long way and is quite comfortable to use), not suited for the intense knowledge-work of 2024. It is clunky, and forces the researcher to write code, when they just want to write about their work 😩 I want to see it not being used at all, but due to its legacy, I doubt it will happen any time soon. So, what we are left with is the need to translate content from proper tools (like Obsidian) to not-so-good old LateX.
= choice([[note]].field[0], [[note]].field[1], ""). This enhances parameterization of the document.In this section, I will be writing what actions will cause errors in this version of the code.
path_finderconverter.py.If you want to jump to some videos, here's the list:
| Link to location in the ReadMe | Comment/Description |
|---|---|
| General video | General video showcasing the tool |
| create equation block for referencing | create equation block for referencing |
| convert and see the result in LateX | convert and see the result in LateX |
| why this conversion system is very convenient | why this conversion system is very convenient |
| how to write equations quickly | Much faster than vanilla LateX, or vanilla Obsidian! |
| (⭐📢NEW) SyncTex-like functionality (navigate to the proper location in Obsidian by clicking the text in the .pdf file) | SyncTex-like functionality (navigate to the proper location in Obsidian by clicking the text in the .pdf file) |
👨💻convert_to_latex.md, you will need to change the path that links to the converter.py, since it is dependent on where you place it (will make the path relative in the future).In the note 👨💻convert_to_latex.md you can specify which note you wish to convert, and then trigger the converter.py script to perform the conversion.
To set the paths for the .md file to be converted, inside converter.py, under "User Parameters" section, change the:
👨💻convert_to_latex.md.You won't need to change anything else inside converter.py, since the other paths are given in 👨💻convert_to_latex.md.
👨💻convert_to_latex.md contains the instructions inside commands.
You can use the example vault in order to see how the converter works, and a showcase of what it can convert. The only modification you will need to do in order to use the vault as I intended to is to rename the "obsidian" folder to ".obsidian", since the latter name implies a hidden folder, github does not allow me to upload it, therefore I had to rename it.
In 👨💻convert_to_latex.md, click on the links next to the code_run:: field. The 1st command performs the conversion from Obsidian to Latex and compiles to .pdf.
Make sure you first set the correct path to the converter.py file that runs the code. This basically opens the python file, which executes it. Make sure that the default app for opening the python file is python, not some editor (otherwise, you need to trigger a .bat file that triggers the .py file).
back to comparisons to other converters
This uses what we can call "==note-block logic==". I.e., writing the equation in a single note, but without writing anything else in that note (hence the "block" part of the name). We will use the same logic for Tables and Figures, so that their referencing becomes easier, and automatic upon name changes.
Due to the inherent difficulty of equation numbering and referencing in Obsidian (read this thread for details), there is no direct way to number and refer to the equations in Obsidian.
The workaround that I have used requires creation of a separate note wherein only the equation is to be added. The note has to obey a few formatting rules, which can be automated with QuickAdd. To learn how to use it, please refer to the plugin guide. It is quite easy.
The folder that you specify in QuickAdd wherein your equation note/block is to be created must be the same as PARS['📂']['equation_blocks'] (in the get_parameters.py).
Those steps above would normally require manual work, which would be annoying.
A way to automatically create an equation-note with the right format, in the right folder is to use the QUICKADD community plugin.
📽 The videos below illustrate how it creates those automatic equation notes, reference them, and how it looks in LateX.
Citations are added as internal links with the syntax: "[[pItemNumber]]". For example, [[p62]] is the note that represents the 62nd literature file (be it an article, a book, etc)
Obsidian Text: "In [[p63]], the authors mention that ..."
Converted Latex Text: "In \cite{p63}, the authors mention that ..."
BUT: as a user, you have to add the BibTex citation manually in your designated BibTex file, and use the "p63" as a name. That Bibtex file should be located in the same path as PARS['📁']['tex-file']!
I will add different rules upon user request.
It is possible to compile the .pdf file such that for each embedded note, you can navigate to that note by clicking on its beginning in the .pdf file. An example is shown in the video below.
In order for the converter to establish the links between the .pdf file and your Obsidian notes, first navigate to the 👨💻convert_to_latex.md note (located in the example_vault) and set the field add_clickable_to_embedded_obsidian_note to true (and to false in order to deactivate this).
https://github.com/user-attachments/assets/47255690-7a18-4e52-8dd1-408277e3d170
back to comparisons to other converters
For when you want to parameterize your document, here's a handy trick. You might have some fields in a note that contain text that you programmatically insert into your document.
For example, assume that you have a note titled fields_for_report. In that note, you might have the field:
argument_1:: true
argument_1:: We use this method, because it's awesome.
The first entry of argument_1 is a boolean that we set to true if we want to print the message (the second entry of argument_1).
And then, in the main note (the one you want to convert to latex), you can write:
We used method_1. `=choice([[fields_for_report]].argument_1[0], [[fields_for_report]].argument_1[1], "")`
back to comparisons to other converters
In case you want to be able to parameterize the appearance of larger parts in the document, you can use the following syntax:
#Latex/Command/Use_section/Start (expression)
Your content here
#Latex/Command/Use_section/End
where expression can be either inline code that produces a boolean value (e.g., =this.use_part_A) or true/false.
Regretably, LateX suffers from one more flaw; that of needing to be concious of packages that should not be loaded together.
This is controlled in get_parameters.py, in the PARS['par']['packages-to-load'] list. The first entry of this list contains the package, the second contains the document class for which this package should not be loaded (e.g., the package cleveref should not be loaded when using the ifacconf document class).
back to comparisons to other converters
Despite the fact that there are still a few features that have not yet been fully developed, it is possible to fully compose a document completely via Obsidian. This is possible through the recognition of LateX command snippets. A command snippet is something that looks like:
plt.figure()
plt.plot(x, y)
plt.show()
This is a snippet that contains code. The first line "``` python" declares the start of the snippet and its language.
The converter is able to recognize such snippets and print them in their corresponding format.
👆However, if the language of the snippet is specified as latex, then the converter will simply paste those lines of latex code to the .tex file without any formatting, thus allowing these lines to run properly in LateX.
Examples:
\lipsum[1-3]
\begin{frontmatter}
\title{Style for IFAC Conferences & Symposia: Use Title Case for Paper Title\thanksref{footnoteinfo}}
% Title, preferably not more than 10 words.
\thanks[footnoteinfo]{Sponsor and financial support acknowledgment goes here. Paper titles should be written in uppercase and lowercase letters, not all uppercase.}
\author[First]{First A. Author}
\author[Second]{Second B. Author, Jr.}
\author[Third]{Third C. Author}
\address[First]{National Institute of Standards and Technology, Boulder, CO 80305 USA (e-mail: author@ boulder.nist.gov).}
\address[Second]{Colorado State University, Fort Collins, CO 80523 USA (e-mail: author@lamar. colostate.edu)}
\address[Third]{Electrical Engineering Department,Seoul National University, Seoul, Korea, (e-mail: [email protected])}
\begin{abstract} % Abstract of not more than 250 words.
\lipsum[1]
\end{abstract}
\begin{keyword}
Five to ten keywords, preferably chosen from the IFAC keyword list.
\end{keyword}
\end{frontmatter}
It can happen that for large notes, Obsidian starts to consume significant RAM resulting in very slow performance.
A workaround developed for this tool is the usage of the following command that avoids embedding a note in Obsidian, but having the same effect when converted to LateX:
#Latex/Command/Invoke_note [[note name]]
This way, the note [[note name]] will be unfolded in the converted version, while remaining "hidden" in the Obsidian editor, in order not to make the note to be converted very "heavy" for your computer.
Read in the Obsidian website for information on what they are.
Embedded notes allow us to:
Basically, the QuickAdd community plugin creates new notes based on user specified templates. You can make it place that note in specific folder, specify naming convention for that note, and a few other functionalities.
Install the "Quick Latex for Obsidian" Community plugin. You can write your own snippets (see video below, wherein I show a few of my own as examples).
🔋🔋🔋 This makes equation writing much faster than vanilla LateX, or vanilla Obsidian!
📽 see video below on how fast you can write equations!
⚠ For the equation snippets, don't forget to press the Space key after inserting them (not mentioned in the video)
Some errors are linked to specific LateX editors. Since Obsidian is a local program, it makes sense that you might chose to use a local latex editor. Those can be sometimes finnicky and overly strict with compilation errors. A workaround is to use Overleaf, in which case you would need to copy the .tex file content to Overleaf, and make sure that your figures are all uploaded. So far, you should put the figures in the same path as the latex file, and set the parameter: use_overleaf_all_in_the_same_folder to 🟢 or True.
I am encountering package problems when I try to run the package in a different computer (therefore with different miktex package installations). For example, the minted package cannot be loaded, causing issues with the compilation (everything is fine when I remove the package loading command for minted).
.sty files and packageslatex2pydata.sty missing. Did not have this issue with my conversions. My minted.sty file does not require the latex2pydata package. Working on it.get_parameters.py to an Obsidian noteexample_vault)converter.py from 👨💻convert_to_latex.mdQuickAdd/data.json. Install automatically if neededPARS['📂']['list_paths_notes'](➕under construction)
🦄: This feature is unique to the tool in this repo (even not available in normal LateX).
| This repo | Pandoc Plugin | Copy as Latex | Enhancing Export | |
|---|---|---|---|---|
| Embedded notes | ✔ | ❌ | ❌ | ❌ |
| Equations | ✔ | ❌❓ --> maybe not, was not able to do it so far | ✔ | not running for me |
| Equation referencing | ✔ | ❌ (seems to not be working) | ❌ | not running for me |
| 🦄 Jump to equation when using the label when the equation is inserted from another file | ✔ | ❌ | ❌ | not running for me |
| Is fast | ✔ * | ✔✔ | ✔✔ | not running for me |
| Ignores comments | ✔ | ✔ | ✔ | not running for me |
| Converting inline dataview code | ✔ | ❌ | ❌ | not running for me |
| 🦄Dataview Table conversion | ✔ | ❌ | ❌ | not running for me |
| Can add custom latex code for specific things | ✔ | ❓ | ❓ | not running for me |
| Can control the sizes and latex class types for figures and tables from Obsidian | ✔ | ❓ | ❓ | not running for me |
| Can treat cases wherein the note to be converted is too complicated, resulting in severe RAM consumption | ✔ | ❌ | ❌ | not running for me |
| Can convert admonition blocks | ✔ | ❓ | ❓ | not running for me |
| Parameterization code that hides parts of the note programmatically | ✔ | ❓ | ❓ | not running for me |
*Provided that the embedded notes are already mapped in PARS['📁']['list_paths_notes'], therefore the algorithm does not need to search in the vault for them. Also, conditional formatting takes some time, since the algorithm has to search inside every linked note for certain tags.
General video showcasing all the functionalities (it will be uploaded on YouTube. For now, you can view the video I've rendered so far here)