今天花了兩個(gè)小時(shí)終于搭建好了TeX的寫(xiě)作環(huán)境,還是有點(diǎn)繁瑣的,總是會(huì)動(dòng)不動(dòng)踩到坑,這里記錄下以便下次參考。
下載CTeX
CTeX的官方網(wǎng)站:CTeX下載
清華大學(xué)鏡像站:清華大學(xué)鏡像站CTeX下載
有基本版和完整版,我嫌完整版太大,選擇了基本版的下載,暫時(shí)足夠使用。
安裝CTeX
據(jù)說(shuō)安裝可能導(dǎo)致環(huán)境變量被覆蓋,所以安裝前請(qǐng)自行備份一份,我安裝的時(shí)候并沒(méi)有覆蓋,謹(jǐn)慎起見(jiàn),還是備份下吧。安裝沒(méi)有什么多余的選項(xiàng),直接一路next就好。
VScode上配置CTeX的開(kāi)發(fā)環(huán)境
- 下載插件 LaTeX Workshop
- 在首選項(xiàng)--設(shè)置--用戶(hù)設(shè)置中添加以下內(nèi)容:
"latex-workshop.latex.toolchain": [
{
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"command": "bibtex",
"args": [
"%DOCFILE%"
]
},
{
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}
],
}
來(lái)個(gè)簡(jiǎn)單的例子:
\documentclass[UTF8]{ctexart}
\title{你好,world!}
\author{Liam}
\date{\today}
\begin{document}
\maketitle
\section{你好中國(guó)}
中國(guó)在East Asia.
\subsection{Hello Beijing}
北京是capital of China.
\subsubsection{Hello Dongcheng District}
\paragraph{Tian'anmen Square}
is in the center of Beijing
\subparagraph{Chairman Mao}
is in the center of 天安門(mén)廣場(chǎng)。
\subsection{Hello 山東}
\paragraph{山東大學(xué)} is one of the best university in 山東。
\end{document}
右鍵就有編譯的選項(xiàng),或者ctrl+alt+B,然后在右上角可以選擇預(yù)覽。效果如下:
ctex.png
至此,就可以使用VScode開(kāi)心的寫(xiě)TeX啦~