当编织下面Rmd with a landscape page和查看由它产生的字输出时,很明显,page two seems to be missing.此外,页面页脚中的页面编号仅在包含横向页面之后才开始.

相反,当编织下面的Rmd without a landscape pageno such issues.

为什么会这样?我怎样才能使带有横向页面的文档表现得像没有横向页面的文档一样?

100

---
output: officedown::rdocx_document
---

```{r setup, include=FALSE}
library(officedown) # 0.3.0
```

<!---BLOCK_TOC--->

# Chapter 1
# Chapter 2
<!---BLOCK_LANDSCAPE_START--->
# Chapter 3
<!---BLOCK_LANDSCAPE_STOP--->
# Chapter 4
\newpage
# Chapter 5
\newpage
# Chapter 6

100

---
output: officedown::rdocx_document
---

```{r setup, include=FALSE}
library(officedown) # 0.3.0
```

<!---BLOCK_TOC--->

# Chapter 1
# Chapter 2
# Chapter 3
# Chapter 4
\newpage
# Chapter 5
\newpage
# Chapter 6

推荐答案

Page 2:
Using <!---BLOCK_LANDSCAPE_STOP{break_page: "nextPage"}---> instead of <!---BLOCK_LANDSCAPE_STOP---> fixes this.

Page numbers in footer starting on page 1:
Add the below chunk right after <!---BLOCK_TOC--->. The functions in this chunk are implemented in the officer package.

```{r}
footer_default <- block_list(fpar(run_word_field(field = "PAGE"),
                                  fp_p = fp_par(text.align = "center") ))

block_section(prop_section(footer_default = footer_default))
```

All together:

---
output: officedown::rdocx_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(officedown) # 0.3.0
library(officer) # 0.6.2
```

<!---BLOCK_TOC--->

```{r}
footer_default <- block_list(fpar(run_word_field(field = "PAGE"),
                                  fp_p = fp_par(text.align = "center") ))

block_section(prop_section(footer_default = footer_default))
```

# Chapter 1
# Chapter 2
<!---BLOCK_LANDSCAPE_START--->
# Chapter 3
<!---BLOCK_LANDSCAPE_STOP{break_page: "nextPage"}--->
# Chapter 4
\newpage
# Chapter 5
\newpage
# Chapter 6

Relevant references:
https://github.com/davidgohel/officedown/discussions/103
https://github.com/davidgohel/officedown/discussions/138

R相关问答推荐

如何将y轴上的线定位得彼此更近

通过绘图 Select 线串几何体并为其着色

如何将dygraph调用到R Markdown作为一个shiny 的react 对象的参数?

将向量组合到一个数据集中,并相应地命名行

计算具有奇数日期的运行金额

制作等距离的线串副本

从外部文件读取多个值作为字符向量

如何对2个列表元素的所有组合进行操作?

您是否可以折叠R中的重复行,同时保留基于所选列的值?

无法定义沿边轨迹的 colored颜色 渐变(与值无关)

在GG图中绘制射线的自动程序

汇总数据的Sheffe检验的P值(平均值和标准差)

在R中,我如何使用滑动窗口计算位置,然后进行过滤?

将项粘贴到向量中,并将它们分组为x的倍数,用空格分隔

R中时间间隔的大向量与参考时间间隔的相交

如何根据未知数的多列排除重复行

如何构建一个for循环来循环处理动物ID?

是否有一个R函数可以输出在输入的字符向量中找到的相应正则表达式模式?

是否从列中删除★符号?

使用列名和r中的前缀 Select 列的CREATE函数