Bookdown table references when not using Kable

329 views Asked by At

Yihui Xie's Bookdown book https://bookdown.org/yihui/bookdown/tables.html is very clear that the cross -referencing system requires adaptations for non-kable tables. The last paragraph in this section is key, but it is (to my lay mind) inscrutable, and I would appreciate an example or two to follow.

To make matters slightly more complicated, my project uses Rchunks, which may complicate the task a bit more.

But,does anyone have examples of bookdown crossref code (perhaps including Rchunks, Rmd calls to those Rchunks or \@ref(tab:...)) that they would share, and which do not call kable?

1

There are 1 answers

1
ekstroem On

No entirely sure what you are asking but here is an example of a manually typed table that works with bookdown:

R includes a lot of advanced mathematical functions. Table \@ref(tab:mathfunctions) shows a list of the most common functions.

Table: (\#tab:mathfunctions) Common mathematical functions in R.

| Function | Explanation | Example|
|----------|------------|-------------|
|   `abs(x)`  | Absolute value| `abs(-3) = 3`|
|   `sqrt(x)` | Square root | `sqrt(9) = 3` |
|   `log(x)`  | Natural logarithm | `log(10) = 2.303` |
|   `log10(x)`  | Base 10 logarithm | `log10(10) = 1` |
|   `log(x, base=2)`  | Base 2 logarithm | `log(10, base=2) = 3.322` |
|   `exp(x)`  | Exponential function | `exp(1) = 2.718` |


R also allows you to yada yada yada.