简体   繁体   English

如何在 RMarkdown Word output 中使用不间断空格作为千位分隔符?

[英]How to use non-breaking spaces as thousands separator in RMarkdown Word output?

I am using RMarkdown to create a Word document that contains several sentences with numbers inserted to them as inline R chunks.我正在使用 RMarkdown 创建一个 Word 文档,其中包含多个句子,其中插入了数字作为内联 R 块。 I would like to use non-breaking spaces as thousands separator, but cannot seem to find a way to do this.我想使用不间断空格作为千位分隔符,但似乎无法找到这样做的方法。 I have found solutions for HTML and PDF outputs, but not for Word output.我找到了 HTML 和 PDF 输出的解决方案,但不是 Word output 的解决方案。

---
output: word_document
---

This is a long sentence with some numbers, so I would like to use non-breaking spaces as thousands separator. For instance, in the number `r formatC(1234, big.mark = " ")`.

Any help would be much appreciated.任何帮助将非常感激。

You can input the non-breaking space using its Unicode escape, ie formatC(1234, big.mark = "\ua0") .您可以使用其 Unicode 转义符输入不间断空格,即formatC(1234, big.mark = "\ua0")

Another way to do it is "\ " .另一种方法是"\ " However, this does not always work.但是,这并不总是有效。

When does it work?它什么时候起作用? Within the normal Markdown-text.在正常的 Markdown 文本中。

When does it not work?什么时候不起作用? If you use it within a chunks' cat-command or paste-command.如果您在块的 cat-command 或 paste-command 中使用它。

I don't know why, though.不过,我不知道为什么。

So better stay with "\ua0" .所以最好留在"\ua0"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM