You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Not so much a problem as a limitation of sphinx for scientific publication. Setting numfig=True in the conf.py enables automatic numbering of things like figures, tables, code-blocks, etc. Unfortunately, for code-blocks this only works if the :caption: has been defined.
Describe the solution you'd like
For scientific publication, it would be very nice if it were possible to reference a code block via numrefwithout explicitly having to define a caption: within the code-block directive. For example:
I want to reference the following code-block with a numref:
```{code-block} python
---
name: my-code
---
print("Hello World")
```
But when I use try to reference via {numref}`my-code`, it fails unless there is a caption.
Note that the desired behavior (numref without caption) works find for tables and figures.
Describe alternatives you've considered
Pre-labeling code-blocks doesn't work either:
(my-code)=
```{code-block} python
def foo():
pass
```
Referencing the code-block like {numref}`my-code` doesn't work either
Additional context
Note that this is a limitation of sphinx, not the myst-parser. The myst-parser output is entirely consistent with rST output with sphinx (i.e. warnings and failed xrefs). Perhaps this is something that needs to be fixed upstream in sphinx, not in MyST (let me know if that's the case).
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Not so much a problem as a limitation of sphinx for scientific publication. Setting
numfig=True
in theconf.py
enables automatic numbering of things like figures, tables, code-blocks, etc. Unfortunately, forcode-blocks
this only works if the:caption:
has been defined.Describe the solution you'd like
For scientific publication, it would be very nice if it were possible to reference a code block via
numref
without explicitly having to define acaption:
within thecode-block
directive. For example:Note that the desired behavior (numref without caption) works find for tables and figures.
Describe alternatives you've considered
Pre-labeling code-blocks doesn't work either:
Additional context
Note that this is a limitation of sphinx, not the
myst-parser
. Themyst-parser
output is entirely consistent with rST output with sphinx (i.e. warnings and failed xrefs). Perhaps this is something that needs to be fixed upstream in sphinx, not in MyST (let me know if that's the case).The text was updated successfully, but these errors were encountered: