Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
715 views
in Technique[技术] by (71.8m points)

latex - Rmarkdown knit pdf - getting underlined text instead of italic using *italic* (huxtable issue?)

Rmarkdown text (between chunks) when formated italic using * * knits to pdf underlined and not italic format when I print huxtable.

Here is my example:

``` 
---
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```
``` 

Is there a solution to this issues as I need to print huxtable in pdf?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the TeXnical perspective the problem is that the ulem package is loaded without the normalem option. A couple of workarounds:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...