我的问题与在中显示脚注的问题非常相似xtable
,尽管建议的更新解决方案对我不起作用。我认为这是因为我在自己的设置中遗漏了一些东西,因此是单独的问题。我认为问题不是这个问题中描述的,因为我sanitize.text.function
在print
通话中使用的是而不是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)
}
)
```
该.tex
表的输出如下:
\% latex table generated in R 3.4.1 by xtable 1.8-2 package \% Tue Aug
22 09:45:33 2017
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrrrrrr}
\hline
& A \footnote{my tricky footnote 1 !!} & B & C & D & E & F & G & H & I \footnote{my tricky footnote 2 !!} & J \\
\hline
1 & 1.13 & -0.00 & -0.14 & 0.83 & 0.58 & -0.65 & -1.12 & -2.04 & -0.64 & 0.50 \\
2 & 0.13 & -0.65 & -1.11 & 0.06 & -1.32 & -0.28 & 0.96 & 1.19 & -0.41 & -0.51 \\
3 & -0.73 & 0.16 & -0.26 & -1.50 & -1.34 & 0.84 & -0.28 & -0.02 & -0.98 & 1.13 \\
4 & 0.33 & 0.89 & -1.08 & -0.89 & 1.16 & 1.70 & -0.77 & -0.21 & 1.01 & 0.22 \\
5 & 0.86 & 0.19 & -0.94 & -1.36 & -2.49 & 0.62 & 0.87 & -1.17 & -0.24 & 0.17 \\
6 & 0.19 & -0.15 & 0.20 & -0.56 & 0.04 & 1.20 & -0.72 & -1.39 & -1.30 & 0.03 \\
\hline
\end{tabular}
\caption{Example of xtable footnotes}
\label{tabbig}
\end{table}