如何将匕首符号包含在Kable列标题中

发布于 2025-01-25 02:04:36 字数 624 浏览 6 评论 0原文

我有一个RMD文件中的表格要打印到PDF,其中我需要在列标题中添加匕首符号。基本的测试代码是:

---
title: "Untitled"
author: "L. G. Hunsicker"
date: "4/29/2022"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F)
library(magrittr)
library(knitr)
library(kableExtra)
```

```{r test}
df <- data.frame(x = 1:10)
names(df)[1] <- 'maxCpep (ng/mL) &#x2020;' 
df %>% kbl()

```

我已经尝试了几种方法来获取匕首符号打印,但是每次努力,结果是,匕首符号的代码被简单地打印为文本或引起错误(带有后斜线)。我尝试使用bquote,\匕首,\匕首等。我还尝试使用上标“ a”作为替代方案。同样,KBL仅在不替换所需符号的情况下打印文字代码文本。必须有一种直接的方式将特殊字符或数学字符串插入Kable标头中,但我找不到它。
在此先感谢您在此问题上的任何帮助。 拉里·亨西克(Larry Hunsicker)

I have a table in a Rmd file to print to pdf in which I need to add a dagger symbol into a column header. The basic test code is:

---
title: "Untitled"
author: "L. G. Hunsicker"
date: "4/29/2022"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F)
library(magrittr)
library(knitr)
library(kableExtra)
```

```{r test}
df <- data.frame(x = 1:10)
names(df)[1] <- 'maxCpep (ng/mL) †' 
df %>% kbl()

```

I have tried several ways to get the dagger symbol to print, but with each effort, the outcome is that the code for the dagger symbol is simply printed as text or raises an error (with the backslash). I have tried using bquote, \dagger, \dagger, etc. I also tried to use a superscript "a" as an alternative. Again, kbl just prints the literal code text without substituting the required symbol. There must be a straight-forward way to insert special characters or math strings into a kable header, but I have been unable to find it.
Thanks in advance for any help with this issue.
Larry Hunsicker

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

欲拥i 2025-02-01 02:04:36

您可以直接添加一个Unicode逃生:

df <- data.frame(x = 1:10)
names(df)[1] <- 'maxCpep (ng/mL) \u2020' 
df %>% kbl()

”在此处输入图像说明”

You can directly add a Unicode escape:

df <- data.frame(x = 1:10)
names(df)[1] <- 'maxCpep (ng/mL) \u2020' 
df %>% kbl()

enter image description here

风轻花落早 2025-02-01 02:04:36

使用inttoutf8获得特殊字符。

names(df)[1] <- paste('maxCpep (ng/mL)', intToUtf8(8224))

Use intToUtf8 to get the special character.

names(df)[1] <- paste('maxCpep (ng/mL)', intToUtf8(8224))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文