Latex for Vscode

Requirements

MikTex

  1. Install MikTex
    I. Install for all user.

    image
    II. Always click next to finish install.
    III. Click on "Check for updates now"
    image

  2. Check System environment path
    I. Find ็’ฐๅขƒ่ฎŠๆ•ธ

    image
    II. Click Red -> Blue -> Green
    image

    III. Check whether miktex env available, if don't, uninstall miktex and go back to step 1.
    image

  3. Open MikTex Console

  • Click admin if below choices show up.
    image
  1. Click Red -> Blue -> Green , update all packages and install all.
    image
  2. 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
    • Package list :
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹ctex 
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹l3kernel
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹l3packages
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹ulem
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹zhnumber
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹zhmetrics
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹cjk
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹cjkpunct
      
    • Find target package, right-click that package and click install package, click OK
      image

      image
  3. After finished all five steps, can close miktex console.

Strawberry Perl (https://strawberryperl.com/)

  1. Download and install the latest release.
    image
  2. Check System environment path.
    image
  3. Check perl usability
    • Cmd
      image
    • Powershell
      image

Vscode

  1. Install Vscode Extension : [latex workshop] & [latex utilities] & [vscode-pdf]

    image
    image

  2. Access setting of vscode (้€™่ฃกๆ‡‰่ฉฒไธ็”จๅš)

    image

  3. Filter Setting -> type "recipe" -> click "Edit in setting.json"(้€™่ฃกๆ‡‰่ฉฒไธ็”จๅš)

    image

  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

  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

  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

  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/