问题描述
所以我的问题陈述如下:我已经使用以下代码在Sweave文档(扩展名为.Rnw)中定义了一个数据框:
So my problem statement is as follows :I have defined a data frame in my Sweave document (.Rnw extension) using the following code:
<<label=table2_1,echo=FALSE>>=
table2_1_rows <- c('Students with compulsory Evaluations',
'Teachers with compulsory evaluations1',
'Teachers without Evaluation2',
'Students without compulsory evaluations3'
)
table2_1_data <- c(1,2,3,4)
table2_1final <- data.frame(table2_1_rows,table2_1_data)
@
<<label=tab1,echo=FALSE,results=tex>>=
print(xtable(table2_1final,caption= ' ',align="|c|c|c|c|c|c|"),include.rownames=FALSE)
@
如何使xtable将数字1,2,3(紧随评估"一词之后)打印为上标?
How do I make xtable print the numbers 1,2,3 (following the word Evaluation) as superscripts?
推荐答案
实际的上标非常简单. \\textsuperscript{1}
与sanitize.text.function = identity
结合将带您到达那里.
The actual superscript is quite easy. \\textsuperscript{1}
in conjunction with sanitize.text.function = identity
will get you there.
我不得不对您的示例进行其他一些更改. align中的列过多,并且变量名称中的下划线导致编译tex时出现问题.
I had to make some other changes to your example. There are too many columns in align and the underscores in the variable names cause problems compiling tex.
<<label=table2_1,echo=FALSE>>=
require(xtable)
table2_1_rows <- c('Students with compulsory Evaluations',
'Teachers with compulsory evaluations\\textsuperscript{1}',
'Teachers without Evaluation\\textsuperscript{2}',
'Students without compulsory evaluations\\textsuperscript{3}'
)
table2_1_data <- c(1,2,3,4)
table2_1final <- data.frame(table2_1_rows,table2_1_data)
names(table2_1final) <- c("rows", "data")
@
<<label=tab1,echo=FALSE,results=tex>>=
print(xtable(table2_1final,caption= ' ',align="|c|c|c|"),include.rownames=FALSE,
sanitize.text.function = identity)
@
这篇关于如何使用xtable和sweave在表中打印上标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!