Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python table with jupyter is showing label in caption when not a cross referenced table #8428

Closed
cderv opened this issue Jan 24, 2024 · 5 comments · Fixed by #11182
Closed
Assignees
Labels
backport bug Something isn't working crossref tables Issues with Tables including the gt integration
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented Jan 24, 2024

---
title: "Test"
format: html
keep-md: true
---

```{python}
#| label: test
#| tbl-cap: 
#|  - Test caption
import pandas as pd
from IPython.display import display, Markdown
penguins = pd.read_csv("https://pos.it/palmer-penguins-github-csv")
markdown_result = penguins.groupby("species").size().to_markdown(index=False, tablefmt="pipe", stralign="right")
display(Markdown(markdown_result))
```

This output to
image

See {#cell-test} appearing in table caption

Intermediate md is

---
title: "Test"
format: html
keep-md: true
---


::: {#cell-test .cell tbl-cap='["Test caption"]' execution_count=1}
``` {.python .cell-code}
import pandas as pd
from IPython.display import display, Markdown
penguins = pd.read_csv("https://pos.it/palmer-penguins-github-csv")
markdown_result = penguins.groupby("species").size().to_markdown(index=False, tablefmt="pipe", stralign="right")
display(Markdown(markdown_result))
```

::: {#test .cell-output .cell-output-display .cell-output-markdown}
|   0 |
|----:|
| 152 |
|  68 |
| 124 |
:::
:::

This should not be there

@cderv
Copy link
Collaborator Author

cderv commented Jan 24, 2024

This is a regression as in 1.3 we get
image

@cderv cderv added the tables Issues with Tables including the gt integration label Jan 24, 2024
@cscheid cscheid added this to the v1.5 milestone Jan 24, 2024
@cscheid cscheid added backport bug Something isn't working labels Jan 24, 2024
@cscheid
Copy link
Collaborator

cscheid commented Jan 24, 2024

Note that this only barely works in 1.3; table captions by default should be on top of the table in our style, and it's not showing up there either.

We'll fix in 1.5 and backport the fix to 1.4 on the first patch, but this doesn't qualify as a must-fix issue for me.

@cscheid cscheid self-assigned this Jun 17, 2024
@cscheid cscheid modified the milestones: v1.5, v1.6 Jun 18, 2024
@simonleandergrimm
Copy link

How can I fix this myself? I have the same issue.

1 similar comment
@simonleandergrimm
Copy link

How can I fix this myself? I have the same issue.

@cscheid
Copy link
Collaborator

cscheid commented Jun 20, 2024

You can add #| label: tbl-mytable to the cell. It will become a crossreferenceable table with Table 1: ... etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport bug Something isn't working crossref tables Issues with Tables including the gt integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants