使用Hmisc LaTeX功能进行编织时,LaTeX表的标题不显示 [英] Caption not appearing for LaTeX table when knitting using Hmisc LaTeX Function

查看:283
本文介绍了使用Hmisc LaTeX功能进行编织时,LaTeX表的标题不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用表格和Hmisc软件包创建一个LaTeX表格,但是,我很难显示标题.

I am trying to create a LaTeX table using the table and Hmisc packages however, I am having trouble getting the caption to appear.

以下是可重现的示例:

    ```{r, results = "asis"}

# data:
dow <- sample(1:7, 100, replace=TRUE)
purp <- sample(1:4, 100, replace=TRUE)
dow <- factor(dow, 1:7, c("Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun"))
purp <- factor(purp, 1:4, c("Business", "Commute", "Vacation", "Other"))

dataframe <-  data.frame( dow, purp)

# The packages
library(tables)
library(Hmisc)

# The table
#tabular(  (Weekday=dow) ~  (Purpose=purp)*(Percent("row")+ 1)    ,data=dataframe        )

# The latex table
tab <- latex(  tabular(  (Weekday=dow) ~  (Purpose=purp)*(Percent("col")+ 1)    ,data=dataframe        ), caption = "This is a Caption")
print(tab)
```

编织表不包含标题.我是LaTeX的新手,我对LaTeX的唯一经验是通过 R 和Rstudio.任何建议将不胜感激.

The knitted table does not contain the caption. I am new to LaTeX and my only experience with LaTeX is through R and Rstudio. Any advice would be greatly appreciated.

推荐答案

运行时

tab <- latex(tabular(  (Weekday=dow) ~  (Purpose=purp)*(Percent("col")+ 1), data=dataframe), caption = "This is a Caption")

您使用的是默认的S3方法,在这种情况下为latex.tabular

you are using the default S3 method which in this case is latex.tabular

## S3 method for class 'tabular'
latex(object, file = "", options = NULL, append = FALSE, ...)

latex.tabular不带标题参数

latex.tabular does not take a caption argument

这篇关于使用Hmisc LaTeX功能进行编织时,LaTeX表的标题不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆