r Markdown longtable + krajobraz kable zmniejszający się szerokość napisów (brak już szerokości strony)

Dec 14 2020

Próbuję używać razem longtable i lanscape dla szerokiego stołu, który obejmuje wiele stron. Kiedy to robię, podpis tabeli przechodzi od pełnej szerokości do po prostu ściśniętego na środku strony.

Bezskutecznie próbowałem skorzystać z poniższych sugestii. R Szerokość podpisu tabeli Markdown z kable i longtable

Jestem nowy w r przecenie iw ogóle nie znam latek, więc przestrzeganie powyższych instrukcji jest dla mnie mylące, chociaż wypróbowałem wszystkie opcje, które moim zdaniem są poprawne. Czy ktoś może dać mi bardzo wyraźne instrukcje krok po kroku, gdzie i co umieścić w YAML, aby rozwiązać ten problem? A może ktoś ma w pobliżu inną pracę? Dziękuję za pomoc

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()

** edycja: robię na drutach PDF !!

Odpowiedzi

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()
```

Rozwiązanie zgodnie z R Szerokość podpisu tabeli Markdown z kable i longtable