r markdown longtable + горизонтальная ширина подписи kable уменьшается (больше не ширина страницы)

Dec 14 2020

Я пытаюсь использовать longtable и lanscape вместе для широкой таблицы, охватывающей несколько страниц. Когда я это делаю, заголовок таблицы переходит от полной ширины страницы к просто сжатой посередине страницы.

Я безуспешно пытался использовать следующие предложения. R Ширина заголовка таблицы Markdown с kable и longtable

Я новичок в r markdown и совсем не знаком с latek, поэтому следование приведенным выше инструкциям сбивает меня с толку, хотя я перепробовал все варианты, которые считаю правильными. Может ли кто-нибудь дать мне очень подробные пошаговые инструкции о том, где и что добавить в YAML, чтобы исправить эту проблему? Или у кого-нибудь есть другая работа? Спасибо за помощь

test <- data.frame(col1=rep("MyLongWordsareLong",5),
               col2=rep("MyLongWordsareLong",5),
               col3=rep("MyLongWordsareLong",5),
               col4=rep("MyLongWordsareLong",5),
               col5=rep("MyLongWordsareLong",5),
               col6=rep("MyLongWordsareLong",5))

kable(test,format='latex',booktabs=TRUE,
caption="This is my example caption. See how, when I don't use 
longtable, it extends the full width of the table, but when I use the 
longtable option, it compresses down to only a portion of the table's width. 
Is this weird or is it just me?") %>% 
 landscape()

kable(test,longtable=TRUE,format='latex',booktabs=TRUE,caption="This is my 
example caption. See how, when I don't use longtable, it extends the full 
width of the table, but when I use the longtable option, it compresses down 
to only a portion of the table's width. Is this weird or is it just me?") 
%>% 
landscape()

** редактировать: Вяжу в PDF !!

Ответы

1 Paul Dec 15 2020 at 06:11
---
title: "Untitled"
author: "anonymous"
date: "14/12/2020"
header-includes:
  - \usepackage{caption}
output:
  pdf_document:
    keep_tex: yes
  html_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(kableExtra)
```

```{r}
test <- data.frame(col1=rep("MyLongWordsareLong", 5),
               col2=rep("MyLongWordsareLong",5),
               col3=rep("MyLongWordsareLong",5),
               col4=rep("MyLongWordsareLong",5),
               col5=rep("MyLongWordsareLong",5),
               col6=rep("MyLongWordsareLong",5))

kable(test, booktabs=TRUE, caption="This is my example caption. See how, when I don't use  longtable, it extends the full width of the table, but when I use the longtable option, it compresses down to only a portion of the table's width.  Is this weird or is it just me?") %>% 
 landscape()

kable(test, longtable=TRUE, booktabs=TRUE, caption="This is my example caption. See how, when I don't use longtable, it extends the full  width of the table, but when I use the longtable option, it compresses down to only a portion of the table's width. Is this weird or is it just me?") %>% 
landscape()
```

Решение по ширине заголовка таблицы R Markdown с kable и longtable