Skip to content

Feature: Allow customizing emphasis and bold text colors via html_theme_options #354

@mmcky

Description

@mmcky

Feature Request

Summary

Allow users to customize the colors used for emphasis (em) and bold/strong (strong, b) text through html_theme_options in their Jupyter Book _config.yml.

Current Behavior

The theme uses hardcoded colors defined in SCSS:

  • Emphasis (italics): Green (#2d9f42)
  • Bold/Strong: Brown (#8b4513)

These colors are compiled into the CSS and cannot be changed without custom CSS overrides.

Proposed Solution

Add new theme options to allow customization:

# _config.yml
sphinx:
  config:
    html_theme_options:
      emphasis_color: "#1a73e8"
      emphasis_color_dark: "#8ab4f8"
      definition_color: "#d93025"
      definition_color_dark: "#f28b82"

Implementation Approach

  1. Add CSS custom properties (variables) to the theme CSS
  2. Expose these as theme options in theme.conf
  3. Inject the custom property values via a Jinja template or inline styles

Example CSS variables approach:

:root {
  --qe-emphasis-color: #2d9f42;
  --qe-definition-color: #8b4513;
}

body.dark-theme {
  --qe-emphasis-color: #66bb6a;
  --qe-definition-color: #cd853f;
}

em {
  color: var(--qe-emphasis-color);
}

strong, b {
  color: var(--qe-definition-color);
}

Workaround

Until this feature is implemented, users can override colors with custom CSS. See: https://gist.github.com/mmcky/f3cd498225627424b3237a4b2fdb959f

Additional Context

This feature would make it easier for different QuantEcon projects to have consistent but distinct visual identities without requiring custom CSS files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions