Obsidian & Quarto setup, current status and questions

Hi,

I am a new user and I have been trying to integrate Obsidian with quarto.

quarto is a datascience extension of markdown that renders documents with code into many many publishable formats

Here is a 20 sec youtube video of my current setup:

Quarto in Obsidian

These are the steps I took:

  1. set up a template with the templater plugin so all files I make in the root of the Obsidian fault have a YAML file header that quarto expects. this is the YAMl I use:
---
title: "Untitled"
format: pdf
---
  1. Set up the “execute code” plugin so I can run r/python/etc interactively in Obsidian
  2. Set up the “shell commands” plugin to run the following command:
cp {{file_path:absolute}}  tmp/{{file_name}}.rmd  
quarto render tmp/{{file_name}}.rmd --to pdf --output-dir 
../quarto/ 
rm tmp/{{file_name}}.rmd 

in a tmp folder the file is rendered, then te output is stored in the quarto folder and the files I made in the process of rendering are deleted.

  1. set up the commander plugin so I have a neat blue (quarto’s color) button that runs the script to render the file I am looking at right now into pdf.

Things I still have to fing a solution for:

  1. write a script that changes Obsidian style markdown into quarto style markdown to handle internal links and possibly .bib references, and call-outs (which are coded differently)

  2. make Obsidian highlight r code even if I start a code block with ```{r} instead of ```r

  3. make separate shell scripts to render to other output formats (beamer presentations etc)

any tips on plugins that would help me solve some of these?

4 Likes

Nice workaround to render from .md with code included!

Seems like you’ve already got most of the pieces of this workflow in place. Regarding presentations, here are some details about how I work with Reveal.js presentations in Obsidian using Quarto. It’s quite similar to what you are doing.

Are you’re familiar with @echej’s work (qmd-as-md plugin maintainer)?

He has shared a lot of relevant stuff, like a lua filter that can convert Obsidian callouts into Quarto callouts:

If you just want to convert the wikilinks into markdown links, there’s several plugins that support that, like Links. You could use this in conjunction with Commander for a seamless workflow.

As for citations, these are natively supported through pandoc citekeys, so you shouldn’t need to create a script for this - unless I am misunderstanding what you meant by .bib references.

Regarding the “execute code” plugin, isn’t that a bit redundant when using Quarto, since big selling point of Quarto is exactly it’s ability to execute code when you render or preview documents? Perhaps you can clarify your workflow a bit in this regard.

2 Likes

I did try the qmd as md plugin, but the qmd files still weren’t fully featured (i.e internal links and tags not registering I think?). Since this is stille a Obsidian centric workflow I’d prefer to work in Obsidian primarily, only opting into quarto when I need/decide to generate output. Ill see if I can include the lua filter in my workflow and set up a second button to co-op your render too reveal workflow.

WRT citations, I am currently using the “citations” plugin, which means if I cite a paper using their [] citation format its a link tot he note page for that citation, while if I render I obviously want to render the pandoc citekey citation and generate a ref list. I guess I could add this to the lua filter and just build the filter out to accommodate?

WRT the execute code plugin, I was thinking of going even further. I am thinking of forking it and adding an “environment” pane, which would track and display all user generated variables and objects that are generated in chunks that are evaluated. During the writing/coding process I like to be able to run chucks to evaluate their correct and iteratively debug, way faster then rendering out to debug.

I think my dream is to have Obsidian basically contain a kind of “RStudio light” so I can freely do statistical thinking/note taking. I would only step out of Obsidian and into RStudio or VScode when I decide an idea becomes a scientific paper, that needs full on IDE/version control/high level data security

2 Likes

Looking at your reveal.js solution I am really digging the use of “quarto preview” and a fixed port, that could be a great alternative tot he code executer route I am now following!

I guess both would also be an option, but it wouldn’t be easy in my workflow where I am working in a .md, which kind of prevents processing with quarto preview… gotta figure out whether I can somehow create a tmp .qmd to mirror a specific .md and trigger the mirroring and preview with a commander button.

Gotta say I am i awe of the flexibility build into Obsidian, wish there was an easy way to bundle all my tweaks and selected/required extension into a single setup so I could share the final setup easily.

1 Like

Hi @Feralflora, @Michelnivard,

Could you please share an update about your approach to developing, updating, and sharing your (academic) work Obsidian and Quarto?

Obsidian has been great for me, but sharing progress updates and outputs my research project is difficult at the moment.

I’m now figuring out how to use the Git-plugin to generate automatic progress updates for ‘project-components’ (i.e. proposal, DMP, chapters, etc.) like release notes in software development. And Quarto seems perfect for sharing outputs and updates in a unified format.

1 Like

Hi @Opi,

I haven’t really made any changes to my Quarto workflow since I posted here. I’m probably going to try out @Michelnivard’s solution for executing code from regular markdown files by making a temporary intermediary .qmd file.

I agree that Quarto is perfect for sharing research in a reproducible manner. In addition, I’m looking into using Typst as the typesetting engine in Quarto, which also has a number of templates available.

Some find the limitations of working with Quarto in Obsidian to be too limiting, and rather opt for working with Quarto files in VS Code, coupled with the Foam PKM system / extension for VS Code instead. You could check that out too.

Hi,

First of all thanks a lot for all your valuable hints!
I try to get those pieces together, but with little luck :slight_smile:

The replacement code for wikilinks didn’t work for me, I use

:gsub("%[%[(.-)%]%]", "[fig](%1)"))

Unfortunately though the links are replaced fine images aren’t rendered. I get the links in the pdf like so : ![figure](figure.jpg)

Has anyone an idea, how to solve this?

Have you specified the resource-path, or transferred the images to the qmd project folder?

Thanks for spending your time on this! I tried various ways without success:

  1. setting the path relative to the document’s path: “…/pics/test.png”
    and
  2. moving the image right into the document’s folder (with the path “test.png”

Setting a wrong path to the image throws a LaTEX error (“test.png not found”). So the path seems to be correct.

I had a similar issue trying to render images in a manuscript that lives in a sub-folder of the parent-project. Below fixed the issue for me.

  • Create _quarto.yml root of project. It does not need to contain any metadata. (I only use this to experiment with parent-project-level-profiles and links to the project repository on GitHub.

  • Set resource path in the yaml manuscript project.

resource-path:   
- "130_msc_thesis/notes/"
- "130_msc_thesis/images/"
- "130_msc_thesis/D03-submit-manuscript/"
- "130_msc_thesis/analyse-data/"
  • include link to image
    • without cross-referencing
![Transition flower for circular agriculture](/images/external/_huntjens-preprint-transition-path-specific-transformation-flower.png)
:::{#fig-transition-flower-circular-agriculture}

![Transition flower for circular agriculture](/images/external/_huntjens-preprint-transition-path-specific-transformation-flower.png)

This text is a caption for the figure

:::

Thank you for replying and pointers to Foam and Typst.

When writing, I found working with Quarto files in Obsidian easier than VS Code with Foam.

VS Code with ojs code blocks has been great for pulling in data to generate and preview tables. Compiling and previewing work (e.g. graphs > section > manuscript) with VS Code was also incredibly simple, but it did take me a lot of time to understand and fix all inclusion and yaml errors.

How has you experience with Typst been? I’ve not tried it yet. Learning to work with GitHub, Git, SSH, GPG, VS Code, Quarto, ojs, and mermaid was distracting and challenging enough for now :')

Yeah, that’s the good thing, you can work with the same files across different programs and utilize their strengths.

Very good, mostly. Compilation is very fast, it is powerful but yet easy to learn. I’m implementing it as the pdf-engine I use in Pandoc and Quarto. Provides nice support for callouts using the “gentle-cues” package and this filter. I had some challenges with getting the citations to work correctly, though. Still working that out.

Good to hear that it’s fast and great that callouts work in pdf too. I’ll focus Typst instead of LaTex and see if I can get the citations working correctly. Is one citation style not working, or are all styles rendered incorrectly?

For those who have problem with images in subfolders (useful when I want to be able to compile single chapter in subfolder and the my whole thesis at the same time) and compile to latex/pdf only (my workaround doesnt work for docx or html): add the alternative graphic paths in _quarto.yml , in my case it was \graphicspath{{figures}{chapters/figures}{../figures}{chapters}{..}}, also I use H option to force figures to stay in given places

  pdf:
    link-citations: false
    number-sections: true
    reference-section-title: "References"
    pdf-engine: xelatex
    fontsize: 12pt
    include-in-header:
      text: |
        %% \usepackage{makeidx}
        %% \makeindex
        \usepackage{microtype}
        \usepackage{epigraph}
        \usepackage{indentfirst}
        \setlength{\parindent}{2em}
        %%\usepackage[british]{babel}
        %%
        %% Code related to fonts and how the output looks
        %%
        \usepackage{mathpazo}
        \usepackage[T1]{fontenc}
        \usepackage[sups,osf]{fbb} % osf (or tosf) for text, not math
        \usepackage[scaled=.95]{cabin} % sans serif
        \usepackage[varqu,varl]{inconsolata} % sans serif typewriter
        %%
        %% Code related to figures in document
        %%
        \usepackage{float}
        \graphicspath{{figures}{chapters/figures}{../figures}{chapters}{..}}
        \let\origfigure\figure
        \let\endorigfigure\endfigure
        \renewenvironment{figure}[1][2] {
            \expandafter\origfigure\expandafter[H]
        } {
            \endorigfigure
        }
2 Likes

I tried to get this workflow working this morning, and ended up building a little extension that others might find useful. Still waiting to be approved for the official list, but should be able to install it manually - if anybody tests it, let me know if it works!

1 Like

Interesting, can you show an example of a syntax conversion that your plugin does? I think such an example would be useful in the readme.