chrisjsewell / ipypublish

A workflow for creating and editing publication ready scientific reports and presentations, from one or more Jupyter Notebooks, without leaving the browser!
http://ipypublish.readthedocs.io
BSD 3-Clause "New" or "Revised" License
224 stars 37 forks source link

How do I show the code with the output? #116

Closed bdatko closed 5 years ago

bdatko commented 5 years ago

What the title says. I have a working example of generating the code for a cell, but I also want the output of the cell as well. How do I accomplish this?

bdatko commented 5 years ago

I figured it out by reading the docs more carefully =P

code cells (output): only include if the following tags are present ...

  • “text” for plain text

Therefore, I just added text along with the code tag inside the metadata of the cell which I wanted both the code, and output to be displayed in my pdf. Shown below is the metadata I added.

{
  "ipub": {
    "code": {
      "format": {},
      "asfloat": true,
      "caption": "my_caption",
      "label": "code:my_label",
      "widefigure": false
    },
    "text": {
      "format": {}
    }
  },
  "trusted": true
}

For clarity, I was trying to convert my Jupyter notebook into a pdf using nbpublish -pdf my_notebook.ipyn