-
DescriptionHello, I posted this also on Posit Community and once I get responses, I will update both places Quarto Cross Reference references.bib in ggplot2 I know how to reference figures in Quarto thanks to Quarto Subcaptions. For example, I can create subcaptions like figSubcap <- "Data Source: @x" and the cross reference works great when using the div syntax. However, when I pass figSubcap into a ggplot2 plot, it just passes the literal string Data Source: @x instead of Data Source: Reference (2020)... . Question: Is there a way to get the citation generated in Quarto (like the Quarto Subcaption) and pass it to a ggplot2 plot, without manually creating the reference string? Here's an example (not fully representative as it lacks a references.bib file). I pass the reference into the x-axis because when converting a ggplot2 plot to plotly via plotly::ggplotly, the ggplot2 caption is not carried forward. However, by putting the reference on the x-axis, we avoid adding an extra argument to plotly::ggplotly. It really doesn't matter where I pass the reference; I just want to know if there's a syntax that allows the citation to be referenced in a ggplot2 plot.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Beta Was this translation helpful? Give feedback.
Sounds good thank you.
As a side note, if you pass a reference from a code block to the document, underscores in the reference name can break the reference. You might already know this, but underscores _ prevent the reference from being passed from a code block. However, if there are no underscores _, cross-referencing currently works in Quarto from a code block. Please see images below (they are from my other Quarto document not the example that @mcanouil provided).
Image one with underscore
Image two with no underscore
Edit 1 based on @mcanouil next response: Thank you for the advice. I will do better in the future. While it won't look as nice as my screenshots above, the overall synt…