4

Is there a way to change the color of captions on a sphinx webpage? I'm using the :caption: directive with toctree, but the caption comes out almost the same color as the sidebar. For reference here is the link to the page with the hard to see captions and here is my index file:

Contents
============

.. toctree::
   :caption: User Documentation
   :maxdepth: 2

   overview
   installation
   tutorial

.. toctree::
   :maxdepth: 2
   :caption: Developer Documentation

   dev/conventions
   dev/enviroment
   dev/docs
   dev/site
   doc/modules

* :ref:`genindex`
* :ref:`modindex`

.. toctree::
   :maxdepth: 2
   :caption: Support

   trouble/faq
   trouble/issuetracker
   trouble/contact
bad_coder
  • 11,289
  • 20
  • 44
  • 72
Syntactic Fructose
  • 18,936
  • 23
  • 91
  • 177
  • Hello, did you manage to do this? I need exactly the same thing and none of the answers provided below are working for me... ( I am using the sphinx_rtd_theme, by the way) – Martí May 11 '21 at 11:58

2 Answers2

2

You could add a color attribut to span.caption-text? For example in your source/_static/custom.cssput:

@import url("default.css");
span.caption-text {
  color: red;
}
aflp91
  • 641
  • 5
  • 12
  • This changes not only the color on the sidebar, but also on the `toctree` directive caption... What is the solution for changing the side bar color only? – bluesummers May 27 '19 at 19:55
1

@aflp91 will indeed change caption text in the side bar, but also the caption text in the toctree as well.

If you want the caption color to change in side bar - and side bar only - you should add this

.wy-menu > .caption > span.caption-text {
  color: #ffffff;
}
bluesummers
  • 11,365
  • 8
  • 72
  • 108