r Abschriften-Longtable + Querformat-Kable-Beschriftungsbreite verkleinern (keine Seitenbreite mehr)

Dec 14 2020

Ich versuche, Longtable und Lanscape zusammen für eine breite Tabelle zu verwenden, die mehrere Seiten umfasst. Wenn ich das mache, geht die Tabellenbeschriftung von der vollen Breite der Seite bis in die Mitte der Seite.

Ich habe versucht, die folgenden Vorschläge ohne Erfolg zu verwenden. R Markdown-Tabellenbeschriftungsbreite mit Kable und Longtable

Ich bin neu in r Markdown, und ich bin mit Latek überhaupt nicht vertraut. Das Befolgen der obigen Anweisungen war für mich verwirrend, obwohl ich alle Optionen ausprobiert habe, die ich für richtig halte. Kann mir jemand sehr explizite Schritt-für-Schritt-Anweisungen geben, wo und was in die YAML eingefügt werden soll, um dieses Problem zu beheben? Oder hat jemand eine andere Lösung? Danke für deine Hilfe

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

** bearbeiten: Ich stricke zu PDF !!

Antworten

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

Lösung gemäß R Markdown-Tabellenbeschriftungsbreite mit Kable und Longtable