# Latex On VScode 1.安裝發行版 --- 現在的發行版有兩種: MiTeX(執行到需要的封包,才會下載)、TeXLive(先把全部封包載好) 自己習慣用MiTeX,載點: https://miktex.org/download 安裝一路往下點就好 (2) 打開MiTeX console ![image](https://hackmd.io/_uploads/S1pqVCfRT.png) (3) 點擊check for update,之後update now ![image](https://hackmd.io/_uploads/HkryBCGRp.png) (4)可以在Package下載需要的套件,可先不選,系統會自動安裝 ![image](https://hackmd.io/_uploads/ByPOjAf06.png) 2.安裝Perl --- perl是一種動態語言,同腳本語言,不用經過編譯器,只需要告訴perl執行就好。 在LaTeX中,Perl用於處理一些任務,像是在生成文檔的過程,執行自動化操作或產生特定的輸出。 (1) 下載Strawberry Perl,載點: https://strawberryperl.com/ 直接執行即可 (2) 編輯系統環境變數 ![image](https://hackmd.io/_uploads/Sy2Nx17RT.png) (3) 環境變數->系統變數的Path->編輯 ![image](https://hackmd.io/_uploads/SkXXe1QA6.png) (4) 新增->確定 ![image](https://hackmd.io/_uploads/HJV5e17R6.png) 3.設定VScode與Latex Workshop --- (1) 安裝VScode擴充Latex Workshop ![image](https://hackmd.io/_uploads/ByNjeRGCa.png) (2) 點擊setting搜尋recipe ![image](https://hackmd.io/_uploads/rkWZzRzRT.png) (3)將xelatexmk移至最上行,並存檔 調整前 ![image](https://hackmd.io/_uploads/SkQjXJQRa.png) 調整後 ![image](https://hackmd.io/_uploads/SJpc7kXRp.png) 4.測試環境 --- (1) 編寫一段Latex範本 ![image](https://hackmd.io/_uploads/BJg6HWQRp.png) ```latex= \documentclass{article} \begin{document} \title{My First LaTeX Document} \author{Your Name} \date{\today} \maketitle \section{Introduction} This is my first LaTeX document. It's amazing how easy it is to create professional-looking documents with LaTeX. \section{Mathematics} LaTeX is particularly powerful for typesetting mathematical equations. For example, we can write the equation of a circle as: \[ x^2 + y^2 = r^2 \] \section{Conclusion} In conclusion, LaTeX is a fantastic tool for creating documents with mathematical content. \end{document} ``` (2) 以VS Code打開資料夾 ![image](https://hackmd.io/_uploads/H1wPIZQ0a.png) (3) 打開後,未compile前 compile方法: 存檔、按F5、按執行 ![image](https://hackmd.io/_uploads/BJ4FLW7A6.png) (4) compile產生pdf檔 ![image](https://hackmd.io/_uploads/H1PC8-X0T.png) (5) 結果 ![image](https://hackmd.io/_uploads/S1e2K-mCa.png) 5.使用中文 --- (1) 現在大多使用xeCJK宏包,簡單且問題較少 (2) 範例 ```latex= \documentclass[a4paper, 12pt]{article} %set doc type and font size \usepackage{fontspec} %allow setting fonts \usepackage{xeCJK} %call chinese package xeCJK \setCJKmainfont{SimSun} %set chinese font \setmainfont{Times New Roman} %set English font \XeTeXlinebreaklocale "zh" \XeTeXlinebreakskip = 0pt plus 1pt \title{沒有標題} \author{你的名字} \date{\today} \begin{document} \maketitle 大家好! Hello world! \end{document} ``` (3) 結果 ![image](https://hackmd.io/_uploads/BkgaTW7Aa.png) Reference --- [使用VSCode上撰寫中文Latex文件](https://kaibaoom.tw/posts/notes/vscode-latex/) [Install LaTeX Workshop and compile PDF in VSCode LaTeX (Windows)](https://www.youtube.com/watch?v=4lyHIQl4VM8) [Latex中文设置](https://medium.com/@xszhong/chinese-latex-1a261a8b557) [[LaTeX] 如何在文章中輸入中文](https://wlzhong.wordpress.com/2016/10/31/latex-%E5%A6%82%E4%BD%95%E5%9C%A8%E6%96%87%E7%AB%A0%E4%B8%AD%E8%BC%B8%E5%85%A5%E4%B8%AD%E6%96%87/)