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

use "#| label: eq-xxx" to add label to equation generated in code chunks (e.g. sympy) #3397

Closed
2 of 4 tasks
kompre opened this issue Nov 19, 2022 · 3 comments
Closed
2 of 4 tasks
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@kompre
Copy link

kompre commented Nov 19, 2022

Bug description

Hello,

I noticed that for figures and tables generated by a code chunks, Quarto let me reference those by adding a #| label: and the relevant label. The same isn't true for equation generated by code chunks.

I would like to display math and equation expressions that actually works in the document, so I'm thinking about using sympy or handcalcs to display nicely formatted math expression that actually yield results; these equation need to be cross referenceable across the document.

I got a working example where I show the issue using sympy, and a workaround that let me reference a sympy expression by wrapping it in a ``$$...$$` environment, similar to the solution used for displaying pandas dataframe mentioned in the guide.

equation_label_in_code_chunks.pdf

(I would like to attach also the qmd file, but it doesn't seems to be supported by github)

image

(So I tricked it by changing the extension, just rename it)

change file extension to qmd.md

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
@kompre kompre added the bug Something isn't working label Nov 19, 2022
@cscheid cscheid self-assigned this Nov 19, 2022
@cscheid cscheid added this to the v1.3 milestone Nov 19, 2022
@cscheid cscheid added enhancement New feature or request and removed bug Something isn't working labels Nov 19, 2022
@cscheid
Copy link
Collaborator

cscheid commented Nov 19, 2022

This would be a great feature to have.

We're hoping to put in some work in crossrefs in this pre-release version. In the meantime, if you have a way to generate Markdown from sympy, you can work around this limitation by producing Markdown that conforms to this syntax and Quarto should be able to find the cross reference.

@kompre
Copy link
Author

kompre commented Nov 20, 2022

you can work around this limitation by producing Markdown that conforms to this syntax and Quarto should be able to find the cross reference.

That is exactly the workaround I used in the qmd file attached above, and it works quite well. The only issue I have with that is that such reference get processed only when rendering, therefore the quarto extension (vscode) does not know about it and it doesn't offer it in the autocompletion list that appears when I type @.

Hence it could become an inconvenience during the draft, even tough the final output looks good

@cscheid cscheid modified the milestones: v1.3, v1.4 Feb 27, 2023
@cscheid cscheid added the duplicate This issue or pull request already exists label May 23, 2023
@cscheid
Copy link
Collaborator

cscheid commented May 23, 2023

Note to quarto devs: In Quarto 1.4's new crossref system, this is a duplicate of #2297 and #1556. Specifically, if the markdown content tells us there is a crossreferenceable item of some kind, we should trust the user to be right and accept that, even if the content doesn't match our expectation. (#2297 and #1556 are about Float crossrefs, and this is about an Inline crossref. But the principle is the same.)

@cscheid cscheid closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2023
@mcanouil mcanouil removed this from the v1.4 milestone Mar 20, 2024
@mcanouil mcanouil removed enhancement New feature or request crossref labels Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants