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

add support for bookdown table references #307

Open
daroczig opened this issue Aug 13, 2017 · 2 comments
Open

add support for bookdown table references #307

daroczig opened this issue Aug 13, 2017 · 2 comments

Comments

@daroczig
Copy link
Member

As per the bookdown docs at https://bookdown.org/yihui/bookdown/tables.html:

If you decide to use other R packages to generate tables [in bookdown], you have to make sure the label for the table environment appears in the beginning of the table caption in the form (\#label) (again, label must have the prefix tab:).

And as others also noticed (see related tickets below), the standard markdown table caption requires an extra reference so that bookdown can pick it up.

Please note that I'm not familiar with bookdown and especially not with bookdwown internals, so would love to get some help from the community here. Eg we have

  • to figure out if pander is called within a bookdown document OR add an extra optional argument in pandoc.table and pander
  • add the extra (\\#tab:foobar) prefix in the table caption
  • come up with what to write instead of foobar

@yihui, can you help out with some pointers on how to do this properly?

Related tickets and questions:

@lselzer
Copy link

lselzer commented Feb 15, 2018

I have found that maybe pander can know about if it called from within bookdown is by checking knitr::opts_knit$get('bookdown.internal.label').

The other issue is how to label the tables. My take would be to automatically number them as table-1, table-2,...

Any thoughts?

@connorp
Copy link

connorp commented Aug 3, 2019

Poking through the code of knitr::kable, it looks like generating the labels from the chunk title is pretty straightforward and only takes a few lines of code, plus a call to create_label(). @yihui would it be inappropriate to just take those few lines from the source of kable() and put them in the appropriate part of pander()? Could pander just call knitr::create_label() rather than recreating its own copy of that function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants