question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rendering MyST figures in the notebook?

See original GitHub issue

Hi,

Thanks a lot for creating such a wonderful project like jupyter-book! I have just started using it and it is fantastic!

I just have a quick question about inserting figures (e.g. .png files) in Jupyter notebook and then rendering them in a book.

I need to control the size of a figure, so in the Jupyter notebook, I would write:

<img src="my_image.png" width="700" align="left"/>

but this does not render properly in the book - the following code cell is rendered very small next to the image.

From issue [#562] I can see that HTML is not recommended, and thus we should use MyST, so the command above becomes like this:

```{figure} ./my_image.png
---
height: 200px
align: left
---
```

This command nicely renders the figure in the book, but not in the notebook - I see part of the code. Is that correct?

Is there a way to use one command to render figures both in jupyter book and in jupyter notebook, when I need to control and try out figure characteristics (e.g. size)?

Thanks a lot!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
chrisjsewellcommented, Aug 24, 2020

Correct rendendering of HTML images is now possible in MyST 😄 See https://myst-parser.readthedocs.io/en/latest/using/syntax.html#images This will be available in jupyter-book soon!

2reactions
nthierycommented, Jul 14, 2020

I got struck by the same problem today. I worked around it by forcing sphinx to copy the image files over so that the <img src="foo/bar.jpg"> links would work. To achieve this, I created an “assets” directory (any other name would work), reproducing the directory structure and containing links to the relevant pictures. E.g. assets/foo/bar.jpg is a link to foo/bar.jpg.

Then I added this:

sphinx:
  config:
    html_extra_path: ['assets']

Really just a workaround …

Read more comments on GitHub >

github_iconTop Results From Across the Web

MyST-NB - Read the Docs
A Sphinx and Docutils extension for compiling Jupyter Notebooks into high ... authoring features such as cross-referencing, figures, and admonitions.
Read more >
Images and figures - Jupyter Book
As discussed in this section, MyST allows for directives such as image and figure to be used (see the Sphinx documentation for available...
Read more >
Interactive notebooks - MyST Markdown
This page of the documentation is actually a Jupyter Notebook that is rendered directly using MyST. For example, let us import altair and...
Read more >
Fragments – Previewing Richly Formatted Jupyter Book Style ...
... of MyST-md and Jupyter Book with various plugins to render the content ... notebooks, the Curvenote editor and the VS Code myst-vs-code ......
Read more >
How can I use myst-markdown in Jupyter-notebook - Reddit
And MyST syntax won't render automatically in the notebook because ... sphinx to figure out what it's doing and what it's limitations are....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found