r markdown longtable + 가로 케이블 캡션 너비 축소 (더 이상 페이지 너비 아님)

Dec 14 2020

여러 페이지에 걸쳐있는 넓은 테이블에 longtable과 lanscape를 함께 사용하려고합니다. 이렇게하면 테이블 캡션이 페이지의 전체 너비에서 페이지 중간에 찌그러집니다.

나는 소용이없는 다음 제안을 사용하려고 시도했습니다. kable 및 longtable이있는 R Markdown 테이블 캡션 너비

나는 r markdown을 처음 사용하고 라텍스에 전혀 익숙하지 않으므로 위의 지침을 따르는 것이 옳다고 생각하는 모든 옵션을 시도했지만 혼란 스러웠습니다. 누군가가이 문제를 해결하기 위해 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()
```

kable 및 longtable이있는 R Markdown 테이블 캡션 너비에 따른 솔루션