Ошибки с выводом r-markdown и kableExtra pdf - PullRequest
0 голосов
/ 16 декабря 2018
---
title: "test_kableExtra"
date: "14/12/2018"
output: 
  pdf_document:
    latex_engine: xelatex
    includes:
      in_header: head.tex
---

``` {r table, echo = FALSE}
library(tidyverse)
library(kableExtra)

table <- tibble(`Column title` = "lots of very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text ")

kable(table, booktabs = T, caption = "Table title") %>%
  kable_styling(full_width = F) %>%
  column_spec(1, width = "5cm")

```

More text...

В head.tex:

\usepackage{float}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}

Я получаю ошибку ! LaTeX Error: \caption outside float.

Если я удаляю caption = "Table title"

, тогда я получаю этот вывод

enter image description here

Я не понимаю, почему:

  • ширина столбца не была изменена до 5 см,

  • почему текст после фрагмента кода центрируется,

  • почему "\ begin {tab ..." и "\ end {table} идет вверх.

Спасибо за любую помощь!

...