【问题标题】:Format text for word output while using rmd template使用 rmd 模板时为 word 输出格式化文本
【发布时间】:2018-03-16 17:14:19
【问题描述】:

我希望能够在对 word 使用 papaja 模板时格式化 word 输出(html 输出或 pdf 输出分别适用于 html 和 LaTeX)。

例如,假设我想用题词开始一篇论文,其中第一行包含某人的引用(左对齐,不缩进),第二行包含引用的人的姓名(右对齐):

由于 papaja(根据需要)和样式为“left”和“right”的 word 文档,以下为我提供了 APA 格式。

---
title: Test
author:
- name: author
  email: author@uni.com
  address: address
  corresponding: yes
output:
  papaja::apa6_word 
---


```{r message = FALSE, warning = FALSE}
knitr::opts_chunk$set(echo = FALSE)
library("papaja")
```


<div custom-style="left">This text should go on the left after editing the styles in word</div>

<div custom-style="right">This text should go on the right after editing the styles in word</div>

当我在 word 文档中编辑样式“左”和“右”时,将该文档另存为 template.docx,然后更改我的输出以包含模板作为参考(请参阅下面的 MWE),第一行的格式正确(左右对齐)。但是,由于我没有指定我想使用 papaja 的 apa6_word 模板,因此输出在逻辑上不是以 APA 样式格式化的。

---
title: Test
author:
- name: author
  email: author@uni.com
  address: address
  corresponding: yes
output: 
    word_document:
      reference_docx: template.docx
---


```{r message = FALSE, warning = FALSE}
knitr::opts_chunk$set(echo = FALSE)
library("papaja")
```

<div custom-style="left">This text should go on the left after editing the styles in word</div>

<div custom-style="right">This text should go on the right after editing the styles in word</div>

有没有办法两者兼得?即,将格式保留为papaja::apa6_word,但能够微调某些方面? 针对这个问题的黑客已经会有所帮助,但我预计会更频繁地遇到这个问题,我想知道是否有是更通用的解决方案吗?

【问题讨论】:

    标签: r ms-word r-markdown


    【解决方案1】:

    很好的问题。使用papaja (devtools::install_github("crsh/papaja@devel")) 的最新开发版本,您可以向apa6_word 提供自定义参考 DOCX 文件。因此,在您的示例中,您可以使用apa6_word 而不是word_document

    output:
      papaja::apa6_word:
        reference_docx: template.docx
    

    【讨论】:

    • 这太好了,谢谢!我可以让 papaja 做所有的格式化,如果我需要一些特别的东西,我仍然可以通过编程来实现。
    猜你喜欢
    • 2018-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-24
    相关资源
    最近更新 更多