Reputation: 141
I am new to Sphinx and would like to show the same figure in two different *.rst
files.
The first *.rst file "lower.rst"
is on the same level as the "figures" folder and I am including a figure in it like this:
.. figure:: figures/figure1.png
The second *.rst file "higher.rst
", is several levels higher than lower.rst. In fact, I am including lower.rst in higher.rst like this:
.. include:: relative/path/to/lower.rst.
Unfortunately, in the higher.rst
, the figures from lower.rst are not displayed:
"image file not readable" error.
higher.rst
looks in the current directory for the figure instead of pointing to the original lower directory.
This question is sort-of addressed here: Can sphinx link to documents that are not located in directories below the root document?, but I still do not understand how to resolve my problem with the information given there.
Upvotes: 9
Views: 4278
Reputation: 15045
Put your figures in a directory at the root level, and change your markup to find them relative to the root using a leading /
.
.. figure:: /_static/figure1.png
Now from the higher level file, you should be able to include the lower, and both files should display the image.
Upvotes: 8