看板 LaTeX 關於我們 聯絡資訊
請問各位高手,如何在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}} -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.119.56.212 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/LaTeX/M.1581909334.A.9C9.html
andrew43: 先把log檔放在雲端貼出來看看。 02/17 16:40
onlyyou2: 放在雲端是? 02/18 09:26
sppmg: pastebin.com 試試 02/18 22:41
onlyyou2: https://pastebin.com/index/L3cyXpbQ 02/19 10:05
onlyyou2: log: https://pastebin.com/xRAwMP2q 02/19 10:10
andrew43: 試試xecjk的CJKmath參數設成true(見xecjk的手冊) 02/19 10:46
onlyyou2: 感謝。這就去試> 02/25 16:30
showfeb: 方程式內中文字用\hbox{中文}包起來 02/28 15:26