本文介绍了RMarkdown 中的下划线到 Microsoft Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 RMarkdown 中弄清楚如何给一些单词加下划线.如果我编织到 HTML,我可以这样做:

这些词带有下划线

在那种情况下效果很好.但是当我编织到 Microsoft Word 时,下划线不会保留.我不相信对 RMarkdown 进行了任何更改来本地执行它,例如粗体和斜体的命令.有什么建议吗?

谢谢

解决方案

对于它的价值... (; 据我所知,使用 HTML 标签是不可能的.HTML 标签在渲染时起作用的原因对于 HTML 而言,HTML 代码不会被 rmarkdownknitrpandoc 触及,而只是作为文本传递到最终的 HTML 文档.在 HTML 的情况下,浏览器知道如何处理这个文本".但在 Word 或 Latex 中,它只是将按原样显示的文本.

但是,对于 Word 输出,您可以查看

I am trying to figure out in RMarkdown how to underline some words. If I am knitting to HTML I can do this:

<u>These words are underlined</u>

Which works fine in that case. But the underlining is not persisted when I knit to Microsoft Word. I don't believe any changes have been made to RMarkdown to natively do it such as the commands for bold and italics. Any suggestions?

Thanks

解决方案

For what it's worth ... (; As far as I get it, this is not possible by using HTML tags. The reason why HTML tags work when rendering to HTML is that the HTML code is not touched upon by rmarkdown, knitr or pandoc and simply passed through to the final HTML document as text. In case of HTML the browser knows what to do with this "text". But in Word or Latex it's simply text which will be displayed as is.

However, for Word output you could have a look at the officedown package which adds some addtional Word functionalities to rmarkdown via the officer officer package , e.g. the following example RMD shows how to get underlined text in Word:

---
title: "officedown template"
output: officedown::rdocx_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.cap = TRUE)
library(officedown)
library(officer)

ft <- fp_text(underlined = TRUE)
```


This document presents most of the features of the package `r ftext("officedown", ft)`.

这篇关于RMarkdown 中的下划线到 Microsoft Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 07:11