# Latex for Vscode ## Requirements - MikTek (https://miktex.org/download) - Strawberry Perl (https://strawberryperl.com/) - Vscode Extension : - ![image](https://hackmd.io/_uploads/SyWSa535R.png) - ![image](https://hackmd.io/_uploads/r1lUa939R.png) - Install any type of pdf reader , ex: vscode-pdf ## MikTex 1. Install MikTex I. Install for all user. ![image](https://hackmd.io/_uploads/BkW2tnacA.png) II. Always click next to finish install. III. Click on "**Check for updates now**" ![image](https://hackmd.io/_uploads/HJQMvn6qR.png) 2. Check System environment path I. Find **環境變數** ![image](https://hackmd.io/_uploads/SyTYuhp9A.png) II. Click **Red** -> **Blue** -> **Green** ![image](https://hackmd.io/_uploads/S1TZK36cC.png) III. Check whether miktex env available, if don't, uninstall miktex and go back to step 1. ![image](https://hackmd.io/_uploads/HypY53aqA.png) 3. Open MikTex Console - Click admin if below choices show up. ![image](https://hackmd.io/_uploads/Hy2_i2p9C.png) 4. Click **Red** -> **Blue** -> **Green** , update all packages and install all. ![image](https://hackmd.io/_uploads/Hyhxdn65R.png) 5. Install below package to get chinese support.(https://blog.csdn.net/qq_34809033/article/details/80680280) - Click **Red** -> Type package name in **Blue** -> **Enter** to filter ![image](https://hackmd.io/_uploads/BykHh2a9R.png) - Package list : ``` ctex l3kernel l3packages ulem zhnumber zhmetrics cjk cjkpunct ``` - Find target package, right-click that package and click install package, click **OK** ![image](https://hackmd.io/_uploads/BJJn22aqC.png) ![image](https://hackmd.io/_uploads/Hymv6na50.png) 6. After finished all five steps, can close miktex console. ## Strawberry Perl (https://strawberryperl.com/) 1. Download and install the latest release. ![image](https://hackmd.io/_uploads/Sk2ECha5R.png) 2. Check System environment path. ![image](https://hackmd.io/_uploads/ByMfJpTqR.png) 3. Check perl usability - Cmd ![image](https://hackmd.io/_uploads/SkOUya6c0.png) - Powershell ![image](https://hackmd.io/_uploads/B1Xdya69A.png) ## Vscode 1. Install Vscode Extension : [**latex workshop**] & [**latex utilities**] & [**vscode-pdf**] ![image](https://hackmd.io/_uploads/HJU8zpa90.png) ![image](https://hackmd.io/_uploads/Byqvf6p50.png) 2. Access setting of vscode (這裡應該不用做) ![image](https://hackmd.io/_uploads/rkmpf3a5R.png) 3. Filter Setting -> type "recipe" -> click "Edit in setting.json"(這裡應該不用做) ![image](https://hackmd.io/_uploads/ryDcM365R.png) 4. Find [xelatex] and move to the first place like below pic. It means that the compiler of latex will use the xelatex first to compile, and xelatex is a chinese support builder.(這裡應該不用做) ![image](https://hackmd.io/_uploads/SJOIQnT50.png) 5. Create a folder and create a **REPLACETHIS.tex**, use below example to create a fundamental tex file. (這裡應該不用做) ``` \documentclass[a4paper, 12pt]{article} \usepackage{xeCJK} \xeCJKsetup{AutoFakeBold=true, AutoFakeSlant=true} \setCJKmainfont{標楷體} \setmainfont{Times New Roman} \usepackage{setspace} \onehalfspace \setlength{\parskip}{1ex plus 0.5ex minus 0.2ex} \begin{document} 文章內容 good \end{document} ``` 6. Build tex to pdf ![image](https://hackmd.io/_uploads/B1E-HhpqC.png) 7. When building pdf, the package installation frame will show up, remember to install all the time and keep the [**Always show this dialog**] always click on. ![image](https://hackmd.io/_uploads/BJqNBhTqA.png) 8. Finally, you can see that two languages will work properly. ## Reference https://strawberryperl.com/ https://miktex.org/download https://blog.csdn.net/qq_34809033/article/details/80680280 https://kaibaoom.tw/posts/notes/vscode-latex/ https://show6114.com/2018/02/28/latex-en-ch-preamble-2018/comment-page-1/