論文排版- Rmarkdown無法顯示方程式裡的中文

匿 匿名 613 次瀏覽 0 個回答

請問各位高手,如何在Rmarkdown產生pdf檔案時,顯示方程式中的中文?
產生html檔案時沒有這個問題。嘗試許多字型,也用ctex編輯,
但是一直沒辦法解決。

Rmarkdown語法
---
title: "機率"
author:
- Me
output:
pdf_document:
toc: no
fig_caption: yes
latex_engine: xelatex
includes:
in_header: headernew.tex
html_notebook:
highlight: textmate
number_sections: yes
theme: spacelab
toc: yes
html_document:
df_print: paged
toc: yes
editor_options:
chunk_output_type: inline
---


```{r, setup, include=FALSE}
knitr::opts_chunk$set(fig.width = 8, collapse = TRUE,
latex.options.color='blue')
library(knitr)
library(kableExtra)
knitr::opts_chunk$set(echo = TRUE)
options(knitr.table.format = "latex",encoding = 'UTF-8')
```

機率公式:
\[機率=\frac{特定事件發生次數}{全部發生次數}
\]

headernew.tex:
\usepackage{mathspec}
\usepackage{amsmath,amsthm}

\usepackage{fontspec}
\usepackage[BoldFont, SlantFont]{xeCJK}
\setCJKmainfont{YouYuan}
%\setCJKmainfont{Adobe Heiti Std}
%\setCJKsansfont{Adobe Heiti Std}
\setCJKsansfont{MingLiU}
\setCJKmonofont{MingLiU}

\setCJKfamilyfont{JhengHei}{Microsoft JhengHei}
\setCJKfamilyfont{mingliu}{MingLiU}

\newcommand*{\hei}{\CJKfamily{JhengHei}}
\newcommand*{\ming}{\CJKfamily{mingliu}}


--

我要回答

0 個回答

還沒有人回答,你知道答案嗎?

我要回答

登入會員後即可回答問題。

免費註冊