Can nbconvert join the output of multiple files? - jupyter-notebook

I have a bunch of ipython notebooks (.ipynb) that I want to convert to PDF.
I can use the following command to convert all the notebooks in a given directory.
jupyter nbconvert --to pdf *.ipynb
I was then wondering if I could output all the nbconverts to a single PDF, as if it was a book. What is the option to have a single output file? I could not find an answer in the docs.

nbconvert does not have a function to do that which I could find. There are other projects that are designed to do this. The ones I could find are:
bookbook: This is simple and does what you're talking about
jupyter-book: Many more features, allowing combining notebooks, markdown, and a few other things.
nbmerge: Really basic, combines several command line passed files into a single notebook that can then be exported using nbconvert.

Related

How to convert a Jupyter notebook latex markdown file to word?

I've spent a long time making my first Latex type-setted document in jupyter notebooks, but just now I've realised that I want to get it into a word file so that I can send it to my professor to mark. However I can't find a way to get it into word without ruining all my latex (or forcing me to go through and click 'insert equation' in word for every single symbol.) Could someone help?!
A little convoluted, but you could first convert your jupyter notebook to a latex .tex file (see e.g. https://nbconvert.readthedocs.io/en/latest/usage.html#convert-latex) and then convert that to Word using some other software (a quick google search shows e.g. https://products.aspose.app/pdf/conversion/tex-to-docx).

Render all markdown cells in a Jupyter notebook at once

Is there a convenient way to render all markdown cells in a Jupyter notebook at once without running the code cells?
I find it quite annoying that while moving through my notebook and doing some little corrections the markdown cells "loose" their formatting. Is there an extension or a command with which I can "run" (i.e. render) all and only the markdown cells? If not, is there a way to at least update the table of content from the markdown cells. My table of content is realized via nbextensions.
You could use JupyterLab which provides a Render all Markdown cells action if you are not limited to plain Jupyter notebooks. Doing this programmatically within the notebook seems to be not trivial to do as we can derive from this GitHub issue. We might be able to implement this ourselves, but I am not aware of any resources that provide something similar.

With RMarkdown is there a way to use knitr syntax to call external R code from a Jupyter notebook?

I am using RMarkdown to write a journal article. For various reasons I'd prefer to have the R analysis script in a separate Jupyter notebook. Is there a nice way to call R code from MyAnalysis.ipynb in MyArticle.Rmd?
I know I can use knitr syntax to have the .Rmd file read and execute chunks of R code from a .R file like so. And that you can use knitr::purl to call code chunks from one rmarkdown doc in another like so.
But I would like to be able to "purl" the code from the .ipynb file. Is there any way to do this?

Using Output In markdown Jupyter notebook

I am using Jupyter Notebook to write my report and it would be convenient to include an output in my markdown.
The question below is a simillar question.
Jupyter notebook output in markdown
For example, I have a code cell with the code
In[1]: import random
a = random.randint(1,4);a
and the output was
Out[1]: 2
in my report, I would realy like to include this output just like
'the chosen number was 2'
however, as the 2 is a random number, it would be very convenient to have a way to include the variation a in my markdown like;
'the chosen number was %a'
kind of way.
Is there any way to achieve this?
It's not possible in the main notebook yet (although there are discussions about it) but there is an extension which should suit your purposes:
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/python-markdown/readme.html
It's contained within the ipython-contrib-extensions package, for which the install instructions are here:
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html

How to convert Jupyter/IPython notebooks to LaTex?

How can I export Jupyter notebooks to LaTeX? I can convert to PDF through LaTeX using the inbuilt menus but I'm unsure how to step in at the intermediate step and extract the actual LaTeX file.
You have to do this from the command line rather than the web interface with the following command:
jupyter nbconvert /path/to/mynotebook.ipynb --to latex
Anaconda Navigator provides JupyterLab. Use this to open jupyter notebook.
Under File menu you can find an item "Export Notebook As...".
This provides format such as Asciidoc, HTML, latex, pdf, Markdown, etc.
You can choose your desired format.

Resources