pdf - Rmarkdown knit pdf - 使用 *italic* 获取带下划线的文本而不是斜体(huxtable 问题?)
问题描述
当我打印 huxtable 时,使用 * * knits to pdf 格式化斜体时的 Rmarkdown 文本(在块之间)带下划线而不是斜体格式。
这是我的例子:
```
---
title: "<center><center>"
author: "<center> jd <center><br>"
date: "<center> `r Sys.Date()` <center>"
output:
pdf_document:
fig_caption: yes
toc: yes
toc_depth: 3
number_sections: true
latex_engine: xelatex
html_document:
code_folding: show
df_print: paged
theme: yeti
highlight: tango
toc: yes
toc_float:
collapsed: false
smooth_scroll: false
number_sections: true
fontsize: 10pt
---
This * * makes text *italic*.
```{r lib, message = FALSE}
library(huxtable)
library(tidyverse)
data(iris)
dt_hux <- iris[1:5,1:5] %>% as_hux() %>%
set_font_size(8) %>% set_font("Arial") %>%
set_bold(1, everywhere) %>%
set_top_border(1, everywhere) %>%
set_bottom_border(c(1, 6), everywhere)```
Until this point using * * will give italic format in knit pdf (if next chunck is not run).
But after the next chunk is run * * will underline text (in whole Rmarkdown). Commenting out **dt_hux** returns formatting to italic. Also knit to html will print italic formatting even with dt_hux.
```{r table}
options(huxtable.latex_use_fontspec = TRUE)
options(huxtable.print=print_latex)
dt_hux```
```
由于我需要以 pdf 格式打印 huxtable,是否有解决此问题的方法?
解决方案
从 TeXnical 的角度来看,问题是在没有选项ulem
的情况下加载了包。normalem
几个解决方法:
使用
classoption: normalem
(基于Knitr 钩子在 tex 文件中的 \documentclass 行之前添加代码,以避免选项与 xcolor 冲突)。警告:这会将选项传递给所有包,如果其他包也使用相同的选项名称,这可能是不受欢迎的(我不知道有任何其他包使用此选项,但以防万一......)在文档开头添加
\normalem
或添加header-include
推荐阅读
- android - 如何确定移动设备上的设备屏幕刷新开始/停止
- python-3.x - 用逗号分割文本并追加行 pandas
- java - 在旋转手机上维护搜索视图的结果
- rust - 如何修复 Rust 中的资源暂时不可用错误?
- c - Determine the minimum number of coins required for giving a change using greedy approach
- oracle - 表2中的数据,当他们在表1中没有数据时的一个月
- android - 如何在 android 中使用开关轨道两侧的文本创建自定义开关?
- scala - 如何使用 Akka-Http 进行并行 Http 请求?
- android - Application not working in android 9 Pie only showing black screen
- c# - 创建 REST API 以允许上传大型数据集