Search code examples
python-sphinxrestructuredtext

RST/Sphinx create inline target markup inside array


I have an array in sphinx / rst, and I would like to reference a line or cell from other part of my documentation.

How can I create an inline markup reference target in the array?

The array looks like this:

+-----------------+-------------------------+-------------------------------------------------------+
| e               | c                       | p                                                     |
+=================+=========================+=======================================================+
| e1              | c1                      | p1                                                    |
+-----------------+-------------------------+-------------------------------------------------------+
| e2              | c2                      | p2                                                    |
+-----------------+-------------------------+-------------------------------------------------------+

Solution

  • I did not think this was possible, but this worked for me.

      +----+----+-------------------------+
      | e  | c  | .. _my-reference-label: |
      |    |    |                         |
      |    |    | p                       |
      +====+====+=========================+
      | e1 | c1 | p1                      |
      +----+----+-------------------------+
      | e2 | c2 | p2                      |
      +----+----+-------------------------+
    

    and then the link to the target would be:

      :ref:`Link title <my-reference-label>`.
    

    The formatting makes the targeted cell larger than it should be, but you can fiddle with the other column widths to get percentage widths close enough.