歡迎

本站利用 MathJax 顯示數學式子,請安裝 STIX Font 以確保數學式子顯示無誤,安裝方法請參閱 MathJax Font Help

2012年9月15日 星期六

A problem with memoir class + lualatex

這是昨天碰到的問題,使用 lualatex 編譯下列的 TeX 檔

\documentclass{memoir}

\usepackage{luatexja-fontspec}
\begin{document}
Hello World!
\end{document}

會出現下列的錯誤訊息:

! LaTeX Error: Command \printglossary already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H   for immediate help.
 ...                                              
                                                  
l.150 ...and\printglossary{\@input@{\jobname.gls}}

這是 memoir 和 luatexja-fontspec 都定義了 \printglossary 所造成的錯誤。在網路上,有看到類似的問題,解決的方法是用 \let\printglossary\relax 將 memoir 定義的 \printglossary 取消,再載入 luatexja-fontspec 即可編譯成功。所以 TeX 要改成下列的樣子:

\documentclass{memoir}
\let\printglossary\relax
\usepackage{luatexja-fontspec}
\begin{document}
Hello World!
\end{document}

雖然這樣可以解決了,但是由於更改了 memoir 的定義,不知到哪裏會出現無法預期的排版錯誤。

2012年9月4日 星期二

Windows 下的 LuaLaTeX

在 Windows 底下,使用 xelatex 應該是比較好的選擇。雖然 xelatex 和 lualatex 都能夠使用系統的字型,但是 lualatex 卻有一個先天上的缺點,只能使用字型的英文名稱,不能使用字型的中文名稱。例如,wqy-microhei.ttc 這個字型的英文名稱是「WenQuanYi Micro Hei」,而中文名稱是「文泉驛微米黑」。要在 lualatex 使用這個字型就要使用

\setmainfont{WenQuanYi Micro Hei}

而不能用

\setmainfont{文泉驛微米黑}

在 Linux 的作業系統下,很容易可以獲得字型的中、英文名稱,但在 Windows 下,比較容易得知字型的中文名稱,至於英文名稱非人還不清楚要如何得知。所以,非人在 Windows 下使用 lualatex 時,一度不曉得該如何設定中文字型。所幸,直接使用字型的檔案名稱是可以被接受的。

\setmainfont{wqy-microhei.ttc}