mirror of
https://github.com/TeachBooks/template.git
synced 2026-11-12 22:25:52 +00:00
867 B
867 B
Including a code block and a figure
Here is a code block that is parsed from a python file:
.. literalinclude:: ../code/sinewave.py
:language: python
Which is the result of:
```{eval-rst}
.. literalinclude:: sinewave.py
:language: python
```
We can toggle the code block by nesting it inside a toggle directive:
```{toggle}
```{eval-rst}
.. literalinclude:: sinewave.py
:language: python
```
Note the single `-triplet at the end of the toggle.
```{eval-rst}
.. literalinclude:: ../code/sinewave.py
:language: python
```
The Python file saves the figure, so we can include it using the regular markdown recipe:
---
name: sine_wave
---
A sine wave
---
name: cosine_wave
---
A cosine wave