Skip to content

Supporting short figure/table captions for list of figures/tables #543

Closed

Description

@wuffi

The captions of figures or tables often need to be long in order to provide the reader with an accurate explanation about what is being shown.
To prevent the list of figures from becoming too difficult to read, LaTeX is offering an optional argument in the \caption[short description for list of figures/tables]{Here comes the full explanation, which can consist of multiple sentences. This is particularly useful when having multiple subfigures.}.
As far as I can see, there is no way to map a figure caption written in R Markdown/knitr to this macro.
However, I think this would be both, helpful and technically feasible.
Please note that there is already some discussion in the development of pandoc to implement such a feature (jgm/pandoc#2417).

Activity

  1. yihui commented on Mar 8, 2018

    @yihui
    Collaborator

    I believe this should work:

    ```{r foo, fig.cap="Long caption.", fig.scap="Short caption", out.extra=''}
    

    out.extra='' is just a token to let knitr render LaTeX code for your figure; it is not required when you have specified out.width or fig.align.

    Of course, this will only work for LaTeX/PDF output.

  2. yihui commented on Mar 8, 2018

    @yihui
    Collaborator

    BTW, next time please try to ask questions on StackOverflow instead. You may also try the RStudio Community. Thanks!

  3. wuffi commented on Mar 8, 2018

    @wuffi
    Author

    Hi Yihui,
    Thanks a lot for your quick supply. This is awesome.
    I hadn't found any documentation on the fig.scap option and thought this would be needed to be implemented first.

  4. added this to the v0.6 milestone on Mar 8, 2018
  5. yihui commented on Mar 8, 2018

    @yihui
    Collaborator

    It is not easy to discover all knitr features. I want to bring happy surprises to users for decades. Just kidding. 😀

  6. reopened this on Apr 24, 2018
  7. wuffi commented on Apr 24, 2018

    @wuffi
    Author

    Hello, sorry for re-opening this issue.
    For figures, short captions work very well.
    For tables, I can't see such an option. Is there a way to get short captions for tables?

  8. yihui commented on Apr 24, 2018

    @yihui
    Collaborator

    Not for now, e.g., knitr::kable() does not have an argument for short captions.

  9. wuffi commented on Apr 24, 2018

    @wuffi
    Author

    Thanks a lot for your quick answer.
    Doesn't kable() have an argument caption.short() (see yihui/knitr#1199 for details)?
    The issue rather is with Markdown tables in bookdown. For them, I would use something like Table: and don't see a simple way how to add a short caption.

  10. yihui commented on Apr 24, 2018

    @yihui
    Collaborator

    WAT? I had implemented it two years ago? I totally forgot it!

    You are right that there is no way to specify short captions with Markdown tables. Your only options are: (1) file a feature request to Pandoc; or (2) use knitr::kable(..., caption.short = ...).

  11. wuffi commented on Apr 24, 2018

    @wuffi
    Author

    Thanks for your reply and having implemented it in kable.
    I think this is what I will use.

  12. github-actions commented on Nov 6, 2020

    @github-actions

    This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

  13. locked as resolved and limited conversation to collaborators on Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions