R 在xtable中显示多个脚注
我的问题与在R 在xtable中显示多个脚注,r,pdf,latex,xtable,footnotes,R,Pdf,Latex,Xtable,Footnotes,我的问题与在xtable中显示脚注时的问题非常相似,尽管建议的更新解决方案对我不起作用。我想这是因为我在自己的设置中遗漏了一些东西,因此提出了另一个问题。我认为问题不在于中所述,因为我在print调用中使用的是sanitize.text.function,而不是xtable调用 下面是PDF输出的图像。可以看出,实际脚注文本即使在渲染两次后也不会出现在PDF输出中。然而,脚注上标不会出现。我正在使用RStudio中的“Knit”按钮进行渲染 如何获得要显示的实际脚注文本 PDF输出: 下面是.
xtable
中显示脚注时的问题非常相似,尽管建议的更新解决方案对我不起作用。我想这是因为我在自己的设置中遗漏了一些东西,因此提出了另一个问题。我认为问题不在于中所述,因为我在print
调用中使用的是sanitize.text.function
,而不是xtable
调用
下面是PDF输出的图像。可以看出,实际脚注文本即使在渲染两次后也不会出现在PDF输出中。然而,脚注上标不会出现。我正在使用RStudio中的“Knit”按钮进行渲染
如何获得要显示的实际脚注文本
PDF输出:
下面是.Rmd
文件中的我的代码
---
title: "xtable footnotes"
output:
pdf_document:
keep_tex: true
fig_caption: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r results = "asis"}
library(xtable)
x <- matrix(rnorm(60), ncol = 10)
x.big <- xtable(x,label = 'tabbig', caption = 'Example of xtable footnotes')
names(x.big) <- LETTERS[1:10]
names(x.big)[1] <- paste('A','footnote1') # I put the tag on A letter
names(x.big)[9] <- paste('I','footnote2') # I put the tag on I letter
print(x.big,
type = "latex",
sanitize.text.function = function(str){
str <- gsub("footnote1","\\footnote{my tricky footnote 1 !!}", str, fixed = TRUE)
str <- gsub("footnote2","\\footnote{my tricky footnote 2 !!}", str, fixed = TRUE)
}
)
```
通过反复试验,最终找到了一个简单的解决方案 要显示脚注,需要使用
longtable
LaTeX包和环境。我将它们添加到标题包括YAML
标题的一部分,然后代码按预期运行
在.Rmd
文件中使用以下代码可显示脚注:
---
title: "xtable footnotes"
output:
pdf_document:
keep_tex: true
fig_caption: true
header-includes:
- \usepackage{longtable}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r results = "asis"}
library(xtable)
x <- matrix(rnorm(60), ncol = 10)
x.big <- xtable(x,label = 'tabbig', caption = 'Example of xtable footnotes')
names(x.big) <- LETTERS[1:10]
names(x.big)[1] <- paste('A','footnote1')
names(x.big)[9] <- paste('I','footnote2')
# tabular.environment needs to be 'longtable'
# \usepackage{longtable} needs to be in the YAML header at the start of the .Rmd file
print(x.big,
tabular.environment = 'longtable',
floating = FALSE,
sanitize.text.function = function(str){
str <- gsub("footnote1","\\footnote{my tricky footnote 1 !!}", str, fixed = TRUE)
str <- gsub("footnote2","\\footnote{my tricky footnote 2 !!}", str, fixed = TRUE)
}
)
```
---
标题:“xtable脚注”
输出:
pdf\U文件:
保持沉默:是的
图(小标题)真
标题包括:
-\usepackage{longtable}
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
```
```{r results=“asis”}
图书馆(xtable)
x经过反复试验,最终找到了一个简单的解决方案
要显示脚注,需要使用longtable
LaTeX包和环境。我将它们添加到标题包括YAML
标题的一部分,然后代码按预期运行
在.Rmd
文件中使用以下代码可显示脚注:
---
title: "xtable footnotes"
output:
pdf_document:
keep_tex: true
fig_caption: true
header-includes:
- \usepackage{longtable}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r results = "asis"}
library(xtable)
x <- matrix(rnorm(60), ncol = 10)
x.big <- xtable(x,label = 'tabbig', caption = 'Example of xtable footnotes')
names(x.big) <- LETTERS[1:10]
names(x.big)[1] <- paste('A','footnote1')
names(x.big)[9] <- paste('I','footnote2')
# tabular.environment needs to be 'longtable'
# \usepackage{longtable} needs to be in the YAML header at the start of the .Rmd file
print(x.big,
tabular.environment = 'longtable',
floating = FALSE,
sanitize.text.function = function(str){
str <- gsub("footnote1","\\footnote{my tricky footnote 1 !!}", str, fixed = TRUE)
str <- gsub("footnote2","\\footnote{my tricky footnote 2 !!}", str, fixed = TRUE)
}
)
```
---
标题:“xtable脚注”
输出:
pdf\U文件:
保持沉默:是的
图(小标题)真
标题包括:
-\usepackage{longtable}
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
```
```{r results=“asis”}
图书馆(xtable)
x