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

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

Closed
wuffi opened this issue Mar 7, 2018 · 10 comments
Closed

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

wuffi opened this issue Mar 7, 2018 · 10 comments
Milestone

Comments

@wuffi
Copy link

wuffi commented Mar 7, 2018

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).

@yihui
Copy link
Member

yihui commented Mar 8, 2018

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.

@yihui
Copy link
Member

yihui commented Mar 8, 2018

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

@wuffi
Copy link
Author

wuffi commented Mar 8, 2018

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.

@wuffi wuffi closed this as completed Mar 8, 2018
@yihui yihui added this to the v0.6 milestone Mar 8, 2018
@yihui
Copy link
Member

yihui commented Mar 8, 2018

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

@wuffi wuffi reopened this Apr 24, 2018
@wuffi
Copy link
Author

wuffi commented Apr 24, 2018

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?

@yihui
Copy link
Member

yihui commented Apr 24, 2018

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

@wuffi
Copy link
Author

wuffi commented Apr 24, 2018

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.

@yihui
Copy link
Member

yihui commented Apr 24, 2018

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 = ...).

@wuffi wuffi closed this as completed Apr 24, 2018
@wuffi
Copy link
Author

wuffi commented Apr 24, 2018

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

@github-actions
Copy link

github-actions bot commented Nov 6, 2020

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants