Stream: helpdesk (published)

Topic: markdown to slides and notebooks


view this post on Zulip Patrick Toche (Jan 14 2022 at 03:13):

What workflow would you suggest to support pdf and multi-language notebook output from the same source? Or at least from a source written in a common language, e.g. markdown or similar.

My previous experience with this dates back a number of years before notebooks were popular and only worked with R: I used knitr with a markdown source to produce html and pdf output. Fast forward to today: I'd like to be able to support Julia, Python, and R and, if at all possible, output Jupyter or Pluto notebooks! :upside_down:

Context: I'm writing up an intro course in econometrics where students would be free to choose one of several languages: the department head wants me to use R, the previous instructor wants me to use Python, and I personally would like to have Julia as an option too! In my vision, I would have a markdown source and would produce beamer slides Jupyter/Pluto notebooks, with some degree of multi-language support. The code for each language would most likely be in separate files that would be sourced from one or several master file.

Your suggestion? :grinning:

view this post on Zulip Rik Huijzer (Jan 14 2022 at 06:35):

So the requirement is a tool which can take Julia, Python and R and generate Beamer PDFs?

view this post on Zulip Rik Huijzer (Jan 14 2022 at 06:37):

Due to the multiple languages, my guess would be that copy and pasting would be the most reliable and quickest way to do it. Or use the Jupyter presentation mode but I don’t know whether it does PDF

view this post on Zulip jar (Jan 14 2022 at 08:19):

Nbconvert might be able to do it

view this post on Zulip Patrick Toche (Jan 14 2022 at 09:04):

Thanks for the feedback! :grinning:

So the part where I convert markdown to beamer shouldn't be too hard. I have only tried it with Rcode and knitr, but I've seen lots of examples of that in Python and Julia, e.g. Weave.jl. I was initially thinking of having a master file that would conditionally include the code: running it three times would generate the three sets of slides. Where I have no direct experience is converting from markdown to notebooks. I was under the impression that Nbconvert uses the notebook as a source to produce markdown and other formats, rather than the other way around, or does it go both ways?

On second thoughts and seeing your comments, I guess it's probably not a good idea to try to go for a true multiple-language approach and would be easier to just copy-paste around three distinct source files... In this case I would write language-neutral slides to discuss theory and have an "appendix" with slides that contains the code for each language.

When it comes to Julia I'm guessing that Weave.jl is the package to convert markdown to slides and notebooks, right?

view this post on Zulip Davi Sales Barreira (Jan 14 2022 at 23:35):

Patrick Toche said:

Thanks for the feedback! :grinning:

So the part where I convert markdown to beamer shouldn't be too hard. I have only tried it with Rcode and knitr, but I've seen lots of examples of that in Python and Julia, e.g. Weave.jl. I was initially thinking of having a master file that would conditionally include the code: running it three times would generate the three sets of slides. Where I have no direct experience is converting from markdown to notebooks. I was under the impression that Nbconvert uses the notebook as a source to produce markdown and other formats, rather than the other way around, or does it go both ways?

On second thoughts and seeing your comments, I guess it's probably not a good idea to try to go for a true multiple-language approach and would be easier to just copy-paste around three distinct source files... In this case I would write language-neutral slides to discuss theory and have an "appendix" with slides that contains the code for each language.

When it comes to Julia I'm guessing that Weave.jl is the package to convert markdown to slides and notebooks, right?

Perhaps NotebookToLaTeX.jl might help in terms of converting the notebook to Latex (for Julia). Currently the package exports to article and book formats. But you could change the generated latex file.

view this post on Zulip Davi Sales Barreira (Jan 14 2022 at 23:37):

Davi Sales Barreira said:

Patrick Toche said:

Thanks for the feedback! :grinning:

So the part where I convert markdown to beamer shouldn't be too hard. I have only tried it with Rcode and knitr, but I've seen lots of examples of that in Python and Julia, e.g. Weave.jl. I was initially thinking of having a master file that would conditionally include the code: running it three times would generate the three sets of slides. Where I have no direct experience is converting from markdown to notebooks. I was under the impression that Nbconvert uses the notebook as a source to produce markdown and other formats, rather than the other way around, or does it go both ways?

On second thoughts and seeing your comments, I guess it's probably not a good idea to try to go for a true multiple-language approach and would be easier to just copy-paste around three distinct source files... In this case I would write language-neutral slides to discuss theory and have an "appendix" with slides that contains the code for each language.

When it comes to Julia I'm guessing that Weave.jl is the package to convert markdown to slides and notebooks, right?

Perhaps NotebookToLaTeX.jl might help in terms of converting the notebook to Latex (for Julia). Currently the package exports to article and book formats. But you could change the generated latex file.

Actually, it might even work for the other languages too if you are using Jupyter Notebooks. I think the only thing you'd need to change would be the language listing, which is set to return Julia. But you could easily change for the other languages. :D

view this post on Zulip Patrick Toche (Jan 15 2022 at 02:40):

Thanks Davi, I'll look into it! :-)

view this post on Zulip Patrick Toche (Jan 15 2022 at 02:41):

you're the author! :tada:

view this post on Zulip Davi Sales Barreira (Jan 15 2022 at 16:13):

Yep! haha. Let me know if it helps, and perhaps I can try to work a slide template.


Last updated: Oct 02 2023 at 04:34 UTC