quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.94k stars 325 forks source link

enable captions to have a heading and text part #645

Closed jjallaire closed 1 year ago

jjallaire commented 2 years ago

For example:

Screen Shot 2022-04-15 at 9 08 12 AM

Liripo commented 2 years ago

Hello: Is it possible to add this function?or use html details?

#| label: fig-plot2
#| fig-cap: !expr tippy::tippy(icons::fontawesome("question"),"answer")
ggplot2::ggplot()
#| fig-cap: "<details><summary>question</summary>answer</details>"
jjallaire commented 2 years ago

I think to do any of this sort of thing the best way currently is to inject javascript (using e.g. include-in-header or include-after-body that transforms the rendered content as you want at page load time.

turbanisch commented 2 years ago

I would love to see table/figure notes separated from a title, too! A while ago, I filed an issue to knitr with the same request. It didn't seem to engender much interest though so I was wondering if the existing field fig-cap could be hacked to accomodate this functionality instead? Perhaps some sort of post-processing could extract both title and notes from this one field or the \caption command in LaTeX could be redefined to split them. But of course, native support would be much, much better.

amichuda commented 2 years ago

Yes, please! This sounds like it would be very useful. I'm currently struggling with trying to hack my way with current Quarto functionality and python . Any suggestions?

tbeason commented 2 years ago

This is something I would love to see have better support. Most fields suggested best practice is to include a short description next to the table, so this seems important. I have a hacked together solution for pdf/latex.

I header-includes \setkomafont{captionlabel}{\bfseries} to make the "Table X" bold, then my tables I write the caption like this

| fruit  | price  |
|--------|--------|
| apple  | 2.05   |
| pear   | 1.37   |
| orange | 3.09   |

: **Fruit prices.** The price of fruit in dollars at the end of 2000.  {#tbl-fruit tbl-colwidths="[75,25]"}

Which gives me

image

I'd prefer to be able to have more flexibility with font sizing / spacing / placement though.

cscheid commented 1 year ago

The appropriate solution for these situations is to have custom formats render their figures however they desire. This is now possible in 1.4. We have preliminary documentation available here and here, but we'll document further before the release.

Specifically, arbitrarily-formatted captions should be implemented by a filter that overrides Quarto's figure rendering and adds whatever desired process by processing the FloatRefTarget node in a Lua filter.