![](/img/trans.png)
[英]Italic text using PdfWriter and iTextSharp and SetFontAndSize function
[英]Rmarkdown knit pdf - getting underlined text instead of italic using *italic* (huxtable issue?)
當我打印 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
package 時沒有使用normalem
選項。 幾個解決方法:
使用classoption: normalem
(基於 Knitr 鈎子在 tex 文件中的 \documentclass 行之前添加代碼,以避免選項與 xcolor 沖突)。 警告:這會將選項傳遞給所有包,如果其他包也使用相同的選項名稱,這可能是不受歡迎的(我不知道使用此選項的任何其他 package,但以防萬一......)
添加\normalem
作為header-include
或在文檔的開頭
此問題已在 huxtable 5.2.0 中修復,因此您只需更新 package。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.