四分之一文档中空白过多空间的问题
我有一个四开本(RMarkdown)文档,它应该显示一个显示任务完成情况的表格。该代码运行良好,但显示了过多的空白,以至于表格显示在第 2 页上,其中单页就足够了,而第 1 页主要是空白。如何使表格适合一页?代码如下:
---
title: "Debug"
author: "Data Kilimba"
format: pdf
editor: visual
---
## FAAB Market Survey Task Completion
```{r setup}
#| include: false
library(tidyverse)
monthly_submissions = tibble::tribble(
~Year, ~Month, ~FAAB, ~Submissions,
2022L, 3L, "Simon", 0L,
2022L, 3L, "Kabula", 0L,
2022L, 3L, "Innocent", 0L,
2022L, 3L, "Renatus", 0L,
2022L, 3L, "Staphord", 2L,
2022L, 3L, "Salome", 0L,
2022L, 3L, "Imani", 0L,
2022L, 3L, "Petro", 10L,
2022L, 3L, "Mihayo", 0L,
2022L, 3L, "Baraka", 0L,
2022L, 3L, "Swaum", 0L
)
```
```{r}
#| label: tbl-stats
#| tbl-cap: "FAAB Market Survey Task completion"
#| echo: false
monthly_submissions %>%
kableExtra::kable(escape = FALSE,format = "latex", booktabs = T) %>%
kableExtra::kable_styling(latex_options="scale_down",font_size = 2)
```
I have a Quarto (RMarkdown) document which is supposed to display a table showing task completion. The code works well but there is excessive white space displayed, to the point where the table is displayed on page 2 where a single page would have sufficed and page 1 is mostly white space. How can I make the table fit on one page? The code is as below:
---
title: "Debug"
author: "Data Kilimba"
format: pdf
editor: visual
---
## FAAB Market Survey Task Completion
```{r setup}
#| include: false
library(tidyverse)
monthly_submissions = tibble::tribble(
~Year, ~Month, ~FAAB, ~Submissions,
2022L, 3L, "Simon", 0L,
2022L, 3L, "Kabula", 0L,
2022L, 3L, "Innocent", 0L,
2022L, 3L, "Renatus", 0L,
2022L, 3L, "Staphord", 2L,
2022L, 3L, "Salome", 0L,
2022L, 3L, "Imani", 0L,
2022L, 3L, "Petro", 10L,
2022L, 3L, "Mihayo", 0L,
2022L, 3L, "Baraka", 0L,
2022L, 3L, "Swaum", 0L
)
```
```{r}
#| label: tbl-stats
#| tbl-cap: "FAAB Market Survey Task completion"
#| echo: false
monthly_submissions %>%
kableExtra::kable(escape = FALSE,format = "latex", booktabs = T) %>%
kableExtra::kable_styling(latex_options="scale_down",font_size = 2)
```
UPDATE:: After editing the document as suggested by Lucas, I add the YAML header and yet there seem to be syntax errors of some kind ... `
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
导致错误的 YAML 标头不应该发生——在这种情况下,Quarto 在验证过程中对其过于挑剔。我们刚刚进行了更改,允许在此处使用
header-includes
的多个值:https://github.com/quarto-dev/quarto-cli/commit/5a685aee484f4d5914e7a899968f654584e24904The YAML header causing an error shouldn't be occurring -- Quarto was in this case being too picky about it during validation. We've just made a change to permit use of multiple values for
header-includes
here: https://github.com/quarto-dev/quarto-cli/commit/5a685aee484f4d5914e7a899968f654584e24904我已经达到了一个解决方案,尽管我不得不说,关于我的yaml有一些奇怪的事情。有两个问题。
这是我的yaml(这起作用)
您可以看到,
...不仅是在@lucas上工作的,而且是在线上无数的其他示例(请在后斜线之前注意减去标志)。但是,对我来说,这导致了以下屏幕截图中的错误。 做了的工作正在删除减号。
但这还不够...
kable_styling
'slastx_option
中的规范。卢卡斯建议的是kableExtra :: kable_styling(latex_options =“ scale_down”,font_size = 2,position =“ float_left”)
,但我发现工作的是
float> float_leat_let_let_left
参数参数参数参数在latex_options
参数列表中,因此以下修正案有效:因此,整个(工作)代码是:
I have arrived at a solution, although I have to say there are some weird goings-on with regards to my YAML. There were two issues.
This is my YAML (this worked)
As you can see...
is what shoul have worked according not only to @Lucas, but countless other examples online (notice the minus signs before the backslashes). However this for me resulted in the errors in the below screenshot. What did work was removing the minus signs.
But this was not enough...
kable_styling
'slatex_option
. What Lucas had suggested waskableExtra::kable_styling(latex_options="scale_down",font_size = 2,position = "float_left")
However what I found to work was the
float_left
argument WITHIN thelatex_options
argument list, so the below amendment worked:So, the entire (working) code is:
乳胶的放置可能很棘手。一种选择是告诉
kable_styling
的position
参数:另外我也不确定 yaml 标头。以下对我有用:
The latex placement can be tricky. One option is to tell
kable_styling
theposition
argument:Also I am not sure about the yaml header. The following works for me: