-
I think it would be very powerful if one could include include the output of LaTeX blocks as images in html formats. I could imagine several use cases (e.g. complex tables), but the use case I’m interested most involves drawing trees in LaTeX using the forest package like this:
These work great for rendering to pdf, but when exporting to html (e.g. revealjs), I would like Quarto/pandoc to include a standalone image of these blocks. Is this possible out-of-the-box already somehow? I have searched for quite a while, but maybe I missed it. If not, any ideas how I could make it work – maybe using a Lua filter? I have no idea where to start for this. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
This is not possible for now in Quarto. However, using external tools you can have this to work. One example is using R in the qmd document. This will allow you to use this R package https://yonicd.github.io/texPreview/ that will do just what you are looking for. It should work as is within Quarto document as it works with knitr already.
Using the syntax you described would indeed require to develop a Lua filter that would do quite the same as the R package I mentioned. This could be a good Quarto extensions. I don't think there is one yet. We have some information on creating extensions and working with Lua in our doc: https://quarto.org/docs/extensions/lua.html Hope it helps |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for your quick and helpful reply. I have now checked both options and both work. After getting texPreview to work, I had a sense that a Quarto extension would be the more elegant solution, though, so I tried to get that running and eventually did. I tried to make it more broadly applicable by reading LaTeX requirements from a I’m new to pandoc/Quarto and Lua, so suggestions are most welcome: https://github.com/wuqui/teximg. If it’s interesting to others, it could also be added to the Quarto extension list – I don’t know whether it’s useful/fancy enough for that, though … One thing I haven’t figured out yet is how to specify the size of the image? |
Beta Was this translation helpful? Give feedback.
-
I'm writing a Quarto/Pandoc filter that does this, with pretty extensive customization options, e.g. zoom that you can specify for the whole document, classes or individual elements. It can also embed svg images within the html output file. It's functional, though I've focused on HTML output and MacOS/Linux only so far. I'll do further tests and add a better sample document before I create a release. But you can already have a look (issues and suggestions welcome!) https://github.com/dialoa/imagify Note: to see a sample output you'll have to clone and run |
Beta Was this translation helpful? Give feedback.
Thanks a lot for your quick and helpful reply.
I have now checked both options and both work. After getting texPreview to work, I had a sense that a Quarto extension would be the more elegant solution, though, so I tried to get that running and eventually did. I tried to make it more broadly applicable by reading LaTeX requirements from a
preamble.sty
file, so that it’s not bound to my particular use case of the forest library and so that requirements are shared between Quarto’s ‘normal’ pdf processing and the extra runs for creating svg images.I’m new to pandoc/Quarto and Lua, so suggestions are most welcome: https://github.com/wuqui/teximg. If it’s interesting to others, it could also …