A Sphinx extension that renders selected figures as sticky margin sidebars while scrolling.
Project description
Sphinx Sticky Margin
sphinx-sticky-margin is a Sphinx extension that adds a sticky margin copy for figures marked with the :class: sticky-margin option.
When the original figure scrolls above the header, a duplicate appears in the right margin (on wide screens). When the original figure comes back into view, the margin copy is hidden.
Installation
pip install sphinx-sticky-margin
Enable Extension
In conf.py:
extensions = [
"sphinx_sticky_margin",
]
For Jupyter Book (_config.yml):
sphinx:
extra_extensions:
- sphinx_sticky_margin
Usage
Add the :class: sticky-margin class to figures that should get a sticky margin clone.
Insert a hide-sticky-margin directive to insert a marker after which to fade out the last sticky figure during scrolling.
The sticky margin figure will appear when the original figure scrolls out of view, and will disappear when the original figure comes back into view.
In case of multiple sticky margin figures, all will be shown in the margin.
If a hide marker scrolls out of view at the top when scrolling down, all sticky figures defined before that marker will be hidden.
When scrolling back up, the sticky margin figures above a hide marker (but after any previous hide marker) will reappear when that hide marker scrolls back below the header.
MyST Example
```{figure} path/to/image.png
:class: sticky-margin
Figure caption.
```
reStructuredText Example
.. figure:: path/to/image.png
:class: sticky-margin
Figure caption.
Hide Marker (MyST)
```{hide-sticky-margin}
```
When the marker scrolls above the header, the previous sticky margin figure is hidden with a fade-out.
Notes
- The sticky margin display is active from
1200pxviewport width and up. - The extension injects
sticky-margin.cssandsticky-margin.js. - MathJax content inside sticky figures is re-typeset when needed.
- The extension removes explicit line endings (
<br>, double space in markdown) from figure captions to prevent layout issues in the margin.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_sticky_margin-1.1.1.tar.gz.
File metadata
- Download URL: sphinx_sticky_margin-1.1.1.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7134c316dd81731742eac5632c37bbb2cb97f1124d56e6525d85235fd3945bcb
|
|
| MD5 |
c90f2393d8008bd288e78e3115062d0b
|
|
| BLAKE2b-256 |
d4e264e6032f90992b4d43423985721122fa4854bfe2c40b4e52a3aff867b725
|
Provenance
The following attestation bundles were made for sphinx_sticky_margin-1.1.1.tar.gz:
Publisher:
python-publish.yml on TeachBooks/Sphinx-Sticky-Margin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_sticky_margin-1.1.1.tar.gz -
Subject digest:
7134c316dd81731742eac5632c37bbb2cb97f1124d56e6525d85235fd3945bcb - Sigstore transparency entry: 1205729487
- Sigstore integration time:
-
Permalink:
TeachBooks/Sphinx-Sticky-Margin@623319a2934fa4d4b1bb2c34531557a9daaa30f6 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/TeachBooks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@623319a2934fa4d4b1bb2c34531557a9daaa30f6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sphinx_sticky_margin-1.1.1-py3-none-any.whl.
File metadata
- Download URL: sphinx_sticky_margin-1.1.1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e57604d84047082440ef2b4fc56e4d372c2de5b065a9bb9ea68d07f6ae2f2d1
|
|
| MD5 |
617a20ea10794d8501617666a4917b03
|
|
| BLAKE2b-256 |
c80070c43fe8e762e7ce7a3ca102e9914815288db981b2de71a22daa3cbc15bd
|
Provenance
The following attestation bundles were made for sphinx_sticky_margin-1.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on TeachBooks/Sphinx-Sticky-Margin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_sticky_margin-1.1.1-py3-none-any.whl -
Subject digest:
9e57604d84047082440ef2b4fc56e4d372c2de5b065a9bb9ea68d07f6ae2f2d1 - Sigstore transparency entry: 1205729493
- Sigstore integration time:
-
Permalink:
TeachBooks/Sphinx-Sticky-Margin@623319a2934fa4d4b1bb2c34531557a9daaa30f6 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/TeachBooks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@623319a2934fa4d4b1bb2c34531557a9daaa30f6 -
Trigger Event:
push
-
Statement type: