【问题标题】:Rmarkdown knit pdf - getting underlined text instead of italic using *italic* (huxtable issue?)Rmarkdown knit pdf - 使用 *italic* 获取带下划线的文本而不是斜体(huxtable 问题?)
【发布时间】:2021-01-12 08:48:44
【问题描述】:

当我使用 * * knits to pdf 格式化斜体时,Rmarkdown 文本(在块之间)在我打印 huxtable 时带下划线而不是斜体格式。

这是我的例子:

``` 
---
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,是否有解决此问题的方法?

【问题讨论】:

  • 你能分享中间的.tex文件吗?
  • @samcarter_is_at_topanswers.xyz 这是 .tex 文件的链接。 raw.githubusercontent.com/Edlenil/share/main/example.tex
  • 谢谢!所以从tex的角度来看,这个问题可以通过使用\usepackage[normalem]{ulem}而不是\usepackage{ulem}来避免。你可以试试classoption: normalem,如下所示:stackoverflow.com/a/53393826/2777074
  • 或者您可以使用\normalem,作为标题包含或在文档的开头
  • @samcarter_is_at_topanswers.xyz,非常感谢 :) 将 classoption: normalem 添加到 yaml 效果很好!

标签: pdf latex r-markdown knitr huxtable


【解决方案1】:

从 TeXnical 的角度来看,问题是在没有 normalem 选项的情况下加载了 ulem 包。几种解决方法:

【讨论】:

    【解决方案2】:

    这个问题在 huxtable 5.2.0 中得到修复,所以你只需要更新你的包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-26
      相关资源
      最近更新 更多