我使用officedown包生成MS文档。我注意到了一个又奇怪又烦人的问题。在生成的输出中左右有不相等的缩进(见附图)。

我使用的Rmarkdown代码:
---
output: officedown::rdocx_document
---
No actual content我用MS 2016打开文档(桌面安装)。
R sessionInfo输出:
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=Polish_Poland.1250 LC_CTYPE=Polish_Poland.1250 LC_MONETARY=Polish_Poland.1250 LC_NUMERIC=C
[5] LC_TIME=Polish_Poland.1250
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] ggplot2_3.3.5 officedown_0.2.4
loaded via a namespace (and not attached):
[1] zip_2.2.0 Rcpp_1.0.8.3 pillar_1.7.0 compiler_4.1.0 tools_4.1.0 digest_0.6.29 uuid_1.0-4
[8] evaluate_0.15 memoise_2.0.1 lifecycle_1.0.1 tibble_3.1.6 gtable_0.3.0 pkgconfig_2.0.3 rlang_1.0.2
[15] DBI_1.1.2 cli_3.2.0 yaml_2.3.5 xfun_0.30 fastmap_1.1.0 withr_2.5.0 dplyr_1.0.8
[22] officer_0.4.1 stringr_1.4.0 xml2_1.3.3 knitr_1.37 generics_0.1.2 vctrs_0.3.8 gdtools_0.2.4
[29] systemfonts_1.0.4 tidyselect_1.1.2 grid_4.1.0 glue_1.6.2 R6_2.5.1 rvg_0.2.5 fansi_1.0.2
[36] rmarkdown_2.13 bookdown_0.25 farver_2.1.0 purrr_0.3.4 magrittr_2.0.2 scales_1.1.1 htmltools_0.5.2
[43] ellipsis_0.3.2 assertthat_0.2.1 colorspace_2.0-3 renv_0.15.4 labeling_0.4.2 utf8_1.2.2 stringi_1.7.6
[50] munsell_0.5.0 cachem_1.0.6 crayon_1.5.0 当我使用bookdown::word_document2作为输出时,问题就消失了,所以我希望officedown包有问题。然而,作者不允许在GitHub上出现新的问题。
我检查了页面大小和页边距的默认设置,它们似乎很好,即边距在两边相等。
我的第一个问题是,你能复制officedown的奇怪行为(我在两台不同的机器和码头容器中测试了它,但只在MS Word 2016中进行了测试)。第二个问题--它能以某种方式解决吗?
发布于 2022-04-14 10:28:11
您可以定义要使用的边距(请参阅?rdocx_document参数page_margins):
---
date: "`r Sys.Date()`"
author: "Your Name"
title: "officedown template"
output:
officedown::rdocx_document:
page_margins:
bottom: .75
top: .75
right: 1
left: 1
header: 0.5
footer: 0.5
gutter: 0
---Github问题已关闭,而是邀请用户开始讨论https://github.com/davidgohel/officedown/discussions
请参阅https://github.com/davidgohel/officedown#questions-and-issues

https://stackoverflow.com/questions/71869635
复制相似问题