Search code examples
python-sphinxrestructuredtextglossary

Can Greek letters be added to Sphinx documents as glossary terms?


I want to add variables that are defined as Greek letters to my glossary in a sphinx document. For example:

.. glossary::

    :math:`{\alpha}`
        Definition for alpha

The goal is to have these variables appear in the document's index. Anyone have experience with this?


Solution

  • Glossary terms are automatically added to the index. But that does not work for the glossary entry in the question. Sphinx emits this warning: WARNING: invalid single index entry '' (at least it does for me). This feels like a bug.

    Here are two workarounds:

    1. Use a substitution

      |alpha|
         Description of alpha
      
      .. |alpha| replace:: :math:`{\alpha}`
      

      The drawback is that it will say "alpha" in the index instead of "α".

    2. Use the actual alpha letter

      α
         Description of alpha
      

      Here α will be an entry in the index under the heading "Symbols".