kable full_width样式选项在表格标题下方显示奇怪的字符

时间:2018-11-15 02:05:30

标签: r knitr kable kableextra

我正在使用knitr和kable生成带有R的PDF。我得到的输出在表格标题sample of the error之前/之下打印了一些特殊字符。我发现如果在kable_styling中删除“ full_width”选项,则字符串会消失。我所有的数据帧都存在问题。 我该如何解决?

非常感谢!

我正在使用的LaTex软件包

\usepackage[margin=0.3in]{geometry}
\usepackage[hidelinks]{hyperref}
\usepackage{booktabs}
\usepackage{colortbl}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage[normalem]{ulem}
\usepackage[table]{xcolor}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage{makecell}
\usepackage{framed}

我正在使用的R包

library(knitr)
library(kableExtra)
library(readxl)
library(tidyr) 
library(dplyr)
library(tibble)
library(xtable)
library(WriteXLS)
library(stringr)
library(ggplot2)
library(lubridate) 
library(reshape2)
library(ggthemes) 
library(stats)
library(zoo)

表规范

kable(df, "latex", longtable = T, booktabs = T, align = c("l","l","l"))%>%
  column_spec(1, width = "0em")%>%
  column_spec(2,width = "10em")%>%
  kable_styling(latex_options = c("striped", "repeat_header","scale_down"), full_width = T)%>%
  collapse_rows(columns = 1:2, latex_hline = "major", valign = "top", row_group_label_position = 'stack')

1 个答案:

答案 0 :(得分:0)

我发现添加

\usepackage{caption}
\captionsetup{width=8in}

改善输出。现在,如果我有一个表标题,它将完全覆盖奇怪的字符。但是,表标题的位置并未作为默认sample of the error的中心。没有表标题,它看起来仍然像this

如果有人可以提供更好的解决方案,那就太好了。

相关问题