天天看點

使用atom-latex編寫中文Latex文檔

問題

含有中文的latex文檔在編譯時候報錯如下:

使用atom-latex編寫中文Latex文檔

出錯原因

當latex文檔含有中文時,編譯器應該為xelatex而不是pdflatex。

解決方法

已有的解決方法主要針對TeXShop編輯器[1]和使用latex包在Atom中進行編譯[2],對于高度依賴atom-latex的使用者(比如我)相當不友好。折騰了很久最後發現在這個包github closed issue中提及如何調用xelatex作為編譯器[3].

首先調出atom-latex的settings界面。

使用atom-latex編寫中文Latex文檔

修改

latexmk execution parameters

,在末尾加上

-xelatex

使用atom-latex編寫中文Latex文檔

需要注意的是不需要修改預設編輯器,保持

Default: pdflatex

即可。

使用atom-latex編寫中文Latex文檔

測試

參考代碼如下:

\documentclass{article}
\usepackage{ctex}
\begin{document}
english test

中文測試
\end{document}
           

輸出結果如下:

使用atom-latex編寫中文Latex文檔

References

[1] http://ijs.me/2019/04/03/mactex-chinese/

[2] https://blog.csdn.net/u013517182/article/details/93032871?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

[3] https://github.com/ashthespy/Atom-LaTeX/issues/105