Skip to main content

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 1200px viewport width and up.
  • The extension injects sticky-margin.css and sticky-margin.js.
  • MathJax content inside sticky figures is re-typeset when needed.

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

sphinx_sticky_margin-1.0.1.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_sticky_margin-1.0.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_sticky_margin-1.0.1.tar.gz.

File metadata

  • Download URL: sphinx_sticky_margin-1.0.1.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sphinx_sticky_margin-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1a3b5f2b18748e90689525aff3b10b53896b2f2276db888c99ab0c1e62b80d55
MD5 67d5354f99f028455e655a0d5a127c89
BLAKE2b-256 2cf7e7e570a09688da4bf619c2436c60e23328f1c85109d685f491f0a4a18e94

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_sticky_margin-1.0.1.tar.gz:

Publisher: python-publish.yml on TeachBooks/Sphinx-Sticky-Margin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_sticky_margin-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_sticky_margin-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 661d7d746468e20c254e2ecf094ea25415604f3bcd3ba83d94fc6a60f5cd935c
MD5 d8dcea3ba6d38fa7d8cf68462c7a7237
BLAKE2b-256 d742c6a2a6759d3a7393e55352c7866feb813b3eac449221c8d8acbdb90d702a

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_sticky_margin-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on TeachBooks/Sphinx-Sticky-Margin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page