在 book down 中将图形标记为 table

Label a figure as a table in book down

我有一个 table,我在 Excel 中设计并导出为图像,现在我想将它包含到我的 R Markdown 文档中。我想将其与使用 knit::kable 生成的 table 类似地对待,因为标题应位于 table 上方,编号应为 table 编号的一部分,不是数字编号。有什么办法可以做到这一点?然后我也希望能够引用它,尽管我不关心引用格式是 @ref(tab:mylabel) 还是 @ref(fig:mylabel)

在这里查看有关 table 的信息 https://bookdown.org/yihui/bookdown/tables.html

You can use any types of Markdown tables in your document. To be able to cross-reference a Markdown table, it must have a labeled caption of the form Table: (#label) Caption here, where label must have the prefix tab:, e.g., tab:simple-table.

所以可能是一种选择,将图像放在降价 ​​table 中(只包含图像而没有其他内容)。

像这样:

|  <!-- -->   | 
| :------------ | 
| ![image](figure/test.jpg)    |
Table: (\#tab:label1) My table

最后一行管理,它得到了正确的索引。

但老实说,我自己会将 Excel table 转换为 data.frame 并使用 kable/kableExtra ...应该很容易并且可能会省去麻烦长 运行.