Skip to main content
Ctrl+K
MyST Sphinx Gallery v0.3.0 documentation - Home
  • User Guide
  • Demo Gallery
  • API Reference
  • Contributing Guide
  • About
  • GitHub
  • PyPI
  • User Guide
  • Demo Gallery
  • API Reference
  • Contributing Guide
  • About
  • GitHub
  • PyPI

Section Navigation

Thumbnail selection strategies

  • Using alt attribute
    • Rst Image Directive
    • Rst Figure Directive
    • Markdown Conventional Image Syntax
    • Markdown Image Directive
    • Markdown Figure Directive
    • Notebook Conventional Image Syntax
    • Notebook Image Directive
    • Notebook Figure Directive
  • first/last Strategy
    • first strategy
    • last strategy
  • Code/Markdown Strategy for Notebooks
    • code | first strategy
    • code | last strategy
    • markdown | first strategy
    • markdown | last strategy
    • markdown | alt strategy
  • Default Gallery Thumbnail
    • Default Thumbnail

Ref Gallery

  • Using ref-gallery in Python Docs
  • ref-gallery in RST files
  • Demo Gallery

Demo Gallery#

This gallery demonstrates the functionality of the MyST Sphinx Gallery extension.

Thumbnail selection strategies#

This section provides a comprehensive overview of how to select a thumbnail for one example file in the MyST Sphinx Gallery extension.

Code for this gallery

The code for this gallery is:

index.rst#
.. gallery::
    :tooltip:
    :caption: Thumbnail selection strategies

    alt/index
    first_last/index
    code_markdown/index
    default/index

Following is the code used to customize the thumbnail selection strategies for each example file in the conf.py:

conf.py#
from myst_sphinx_gallery import FilesConfig, GalleryThumbnailConfig

myst_sphinx_gallery_files_config = FilesConfig(
    named_config={
        "first_md": GalleryThumbnailConfig(
            thumbnail_strategy="first", notebook_thumbnail_strategy="markdown"
        ),
        "first_code": GalleryThumbnailConfig(
            thumbnail_strategy="first", notebook_thumbnail_strategy="code"
        ),
        "last_md": GalleryThumbnailConfig(
            thumbnail_strategy="last", notebook_thumbnail_strategy="markdown"
        ),
        "last_code": GalleryThumbnailConfig(
            thumbnail_strategy="last", notebook_thumbnail_strategy="code"
        ),

    },
    files_config={
        "first_code": [
            "examples/code_markdown/first code.ipynb",
            ],
        "last_code": [
            "examples/code_markdown/last code.ipynb",
            ],
        "first_md": [
            "examples/code_markdown/first markdown.ipynb",
            "examples/first_last/first.rst",
            ],
        "last_md": [
            "examples/code_markdown/last markdown.ipynb",
            "examples/first_last/last.rst",
            ],
    },
)

Using alt attribute#

Rst Image Directive
alt/rst%20image.html
Rst Figure Directive
alt/rst%20figure.html
Markdown Conventional Image Syntax
alt/md%20conventional%20image.html
Markdown Image Directive
alt/md%20image.html
Markdown Figure Directive
alt/md%20figure.html
Notebook Conventional Image Syntax
alt/nb%20conventional%20image.html
Notebook Image Directive
alt/nb%20image.html
Notebook Figure Directive
alt/nb%20figure.html

first/last Strategy#

first strategy
first_last/first.html
last strategy
first_last/last.html

Code/Markdown Strategy for Notebooks#

code | first strategy
code_markdown/first%20code.html
code | last strategy
code_markdown/last%20code.html
markdown | first strategy
code_markdown/first%20markdown.html
markdown | last strategy
code_markdown/last%20markdown.html
markdown | alt strategy
code_markdown/markdown%20alt.html

Default Gallery Thumbnail#

Default Thumbnail
default/no_image.html

Ref Gallery#

This section provides a demo of a gallery with references to the examples.

Code for this gallery

The code for this gallery is:

index.rst#
.. base-gallery::
    :tooltip:
    :caption: Ref Gallery

    ref_gallery/code_ref
    ref_gallery/rst_ref
Using ref-gallery in Python Docs
ref_gallery/code_ref.html
ref-gallery in RST files
ref_gallery/rst_ref.html

No tooltip#

This section provides a demo of a gallery with no tooltips. When you hover over the example cards, no tooltips will appear.

Code for this gallery

The code for this gallery is:

index.rst#
.. ref-gallery::

    examples/alt/rst image
    examples/first_last/first
    examples/code_markdown/first code
Rst Image Directive
alt/rst%20image.html
first strategy
first_last/first.html
code | first strategy
code_markdown/first%20code.html

previous

Customizing Style of Thumbnail and Card

next

Using alt attribute

On this page
  • Thumbnail selection strategies
    • Using alt attribute
    • first/last Strategy
    • Code/Markdown Strategy for Notebooks
    • Default Gallery Thumbnail
  • Ref Gallery
  • No tooltip
Edit on GitHub
Show Source

© Copyright 2024, Fan Chengyan (Fancy).

Created using Sphinx 8.0.2.

Built with the PyData Sphinx Theme 0.15.4.