Pandoc plugin for exporting & Export to PDF

Integrating Pandoc is being looked into by the devs to allow pdf (and other format) exporting

5 Likes

I would prefer integrated Pandoc support but in the meanwhile there is this plugin:

By setting Logseq to use Computer Modern (the default LaTeX font when exporting a PDF with Pandoc) and other adjustments like using Document Mode the result is pretty similar:

2 Likes

This is VERY nice. Could you send the font link?

NewCM10Regular:

https://ctan.mirror.garr.it/mirrors/ctan/fonts/newcomputermodern/otf/

1 Like

Upvoted!

Pandoc support would be much appreciated. Especially interesting for those working in science/research and full form writers. And likely to bring interest to LogSeq from those crowds.

This might not be feasible near-term, but the LogSeq<->pandoc Holy Grail would certainly be full Pandoc readers and writers for LogSeq. In that way, conversion to/from loads of interesting formats would be possible, like:

  • markdown of various flavours
  • Org-Mode
  • HTML
  • EPUB
  • Man pages
  • LaTeX, LaTeX Beamer
  • OPML
  • various bibliography formats
  • docx, RTF, ODT
  • pdf
  • Jupyter notebook
  • various Wiki flavours

Add to that all the citation styles and formats supported by Pandoc.

And, since the LogSeq graph can then be converted to and from the Pandoc AST, the possibility to apply Pandoc filters (written in Lua or JSON) to the AST tree and, hence, to the LogSeq graph.

8 Likes

Another way to export a page relatively easy is using the ‘Doc viewer exporter’ plugin. It exports the document as a html as shown in logseq. You can open this html in Word (sadly, it does not work great together with LibreOffice). Export it to the folder that holds your pages to ensure images are included. From there, export to pdf, or open the page in Chrome/Firefox and export there as pdf.

2 Likes

Very interesting resource, it would also be very good if it was possible to create a website using the notes in Logseq, a good example is Org Mode Hello Worg, the Org-Mode Community!, it supports exporting to full HTML or PDF.

It would be great, as it could be used for public documentation, articles, blogs and other uses, even more so if it were possible to export a clean and standard Markdown or other type of format, so the HTML could be generated by a static site generator like Zola , MkDocs and the like.

2 Likes

‘Doc viewer exporter’ plugin v1.11.1 works great but its big problem is that it does not display tags.

Hi Alex. I am new to logseq, I am wondering how do you manage to print the math equations

Hi and welcome,

Logseq supports LaTeX syntax for math formulas and there are two ways to insert it:

  1. Inline: wrap the formula between two $: $E=mc^2$. This is meant to be used in the same line with other text.

  2. Block (it will be centered), you need a line with two $$, then one or more lines of formulas and then a line with two $$:

    $$
    E=mc^2
    $$

To insert a new line inside the same block, press Shift+Enter (as opposed to Enter that by default create a new block).

This is how almost all Markdown editors support math formulas.

In case you don’t know LaTeX, it’s the industry standard to produce academic documents and math ones in particular, start from here to learn it:

That guide comes from a popular LaTeX online editor, Overleaf.

Logseq doesn’t support the whole LaTex but just the math formulas and does so thanks to a popular library to display LaTeX formulas on the Web: KaTeX.

Since people often need other features from LaTeX in their formulas, KaTeX adds some “functions” to bridge the gap: Supported Functions · KaTeX

The functions above are syntax you can use in Logseq too and in other Markdown editors that uses KaTeX for formulas.

2 Likes

Thank you for your great response! (I was using the block equation before, and I didn’t know the in line one). I had some difficulty in printing the latex math equations in my logseq document. When I’m using the pdf exporting plug-in you referred to, the latex equations will be printed as its source code form instead of the displayed form. Do you have any suggestions?

With reference to the plugin mentioned above, I use Download as PDF > Print with Retained Formatting.

The other option is export as Markdown and then use Pandoc to convert it to PDF.

1 Like

Thank you! That works great! Do you mind to explain how to update the font if you have a chance?

Sure, you need to open custom.css (it’s in /your-graph/logseq folder or you can open it from Logseq settings) and add the following.

This one if you want to change the font only in Document Mode (the one you activate with t d shortcut (press Esc, then t then d)) like me:

:root :is(.document-mode){
  font-family: "Only Emoji", "NewComputerModernMath", "cmr10", "Noto Sans";
  font-size: 20px;
}

Or use this one for the whole page content anyway:

{
  font-family: "Only Emoji", "NewComputerModernMath", "cmr10", "Noto Sans";
  font-size: 20px;
}

In case you also want to hide block&page Properties in Document Mode:

:root :is(.document-mode)  .block-properties.block-properties.block-properties {
    display: none !important;
}

Of course you need the font I linked installed in your system.

3 Likes

I wrote a filter that uses the Pandoc AST. It first reads the Logseq Markdown using Pandoc, processes it to smooth over some idiosyncrasies of logseq itself and of my workflow at the time, and writes out Pandoc again. It’s not documented, and might not do what you want, but it might be an example to build on.

4 Likes

That’s great! I’ll check it out!

Hi! Could you please provide a brief explanation on how to implement it in logseq? Thanks for your kind contribution

Re-upping @alexfazio’s question about documentation. Would love to know how this works.

1 Like

Hey @Ed_Nico , just curious if there are any updates on this, or if there might even be a timeline if the team did decide to develop this functionality.

Also just to cast my vote specifically for full pandoc integration and handling of logseq markdown idiosyncrasies.

Thank you!

Here is some documentation about the script: GitHub - Tamriel/logseq2pandoc: Export Logseq pages to PDF or epub

1 Like