# LaTeX in VSCode with Chinese Support

_2025-10-21_

> Step by step guide to setup LaTeX-Workshop with XeLaTeX

Canonical URL: https://cxiang.site/blog/latex-in-vscode-with-chinese-support

# Introduction

I was looking for a local alternative for Overleaf, where I came across the **[LaTeX-Workshop](https://github.com/James-Yu/LaTeX-Workshop)**** **extension for VSCode with LaTeX live preview support. You could follow the official [installation guide](https://github.com/James-Yu/LaTeX-Workshop/wiki/Install) to setup LaTeX-Workshop, however by default the extension uses `**pdfLaTeX**` as the default TeX Engine (compiler for .tex files), which is unicode unfriendly. So this post shows step by step how to setup your Computer and VSCode with unicode LaTeX support using `**XeLaTeX**`.

# Steps

## 1. Install a LaTeX distribution (TeX Live)

In this tutorial I’ll download **TeX Live **distribution as recommended by author of LaTeX-Workshop. A LaTeX distribution will include all LaTeX engine and packages we need.

> 💡
> Download TeX Live [here](https://www.tug.org/texlive/) base on your operating system.
> 
For me, I will download the macOS variant of TeX Live: **[MacTeX](https://www.tug.org/mactex/mactex-download.html)**. The full version of MacTex is rather large at 6.0G, so it will take a while to download.

![](https://www.notion.so/image/attachment%3Af04f42f4-d9bb-4f26-8bd4-04c6d33d55e4%3AScreenshot_2025-10-21_at_5.08.11_PM.png?table=block&id=293f94f7-98c1-8056-9bda-ce84a11e127c&cache=v2)
After downloading the pkg file, double click and follow the instructions to install it. 

Now we can already use some TeX GUI bundle in TeX Live like TeXShop and LaTeXiT, but to use it in VSCode there are some extra steps.

![](https://www.notion.so/image/attachment%3A07d3f449-a122-482c-bd99-af635999ecbc%3AScreenshot_2025-10-21_at_5.34.10_PM.png?table=block&id=293f94f7-98c1-80d1-a2c1-f5431843da68&cache=v2)


## 2. Add binaries to PATH

The following guide is for mac or linux, to add program to PATH in Windows follow [here](https://docs.telerik.com/teststudio/features/test-runners/add-path-environment-variables).

After we successfully installed LiveTex the binaries will be installed to the following directory:

```Bash
/usr/local/texlive/<version>/bin

# e.g. 
/usr/local/texlive/2025/bin
```
We need to add this path to the PATH environment variable so that our shell program can use it, this can be done by add the following line to the configuration file of your shell.

```Bash
export PATH=/usr/local/texlive/2025/bin:$PATH
```


A simple way of doing this to run one of the following command in your terminal:

```Bash
# For zsh users
echo "export PATH=/usr/local/texlive/2025/bin:\$PATH" >> ~/.zshrc

# For bash users
echo "export PATH=/usr/local/texlive/2025/bin:\$PATH" >> ~/.bashrc
```
Now let’s verify if the installation is successful, by reopening a new terminal window and enter the following command:

```Bash
xelatex --version
```
If you see something like the following then you installed it correctly.

![](https://www.notion.so/image/attachment%3A55213898-64fc-4566-8478-eca976420b2f%3AScreenshot_2025-10-21_at_5.45.34_PM.png?table=block&id=293f94f7-98c1-8067-94ca-f02cc169ae96&cache=v2)
## 3. Install LaTeX-Workshop

If your don’t already have VS-Code installed, download it [here](https://code.visualstudio.com/).

We can install LaTeX-Workshop by searching it in the extension shop of VSCode, or simply following the redirect in this [link](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop). If the extension is successfully installed you should see this page.

![](https://www.notion.so/image/attachment%3Aa64202ee-c99d-46d9-a554-9f15b46aa8a3%3AScreenshot_2025-10-21_at_5.50.51_PM.png?table=block&id=293f94f7-98c1-8084-bee6-e5d8e4e9fa17&cache=v2)
Now you should already be able to compile english LaTeX file, but to support other unicode languages like Chinese we need to modify some settings of LaTeX-Workshop.



## 4. Extension Settings

Open the setting’s page of VSCode and search for `@ext:James-Yu.latex-workshop tool` then click “Edit in settings.json”.

![](https://www.notion.so/image/attachment%3Afa8bbaf8-d2ce-4948-b4e5-4d9cf953ff11%3AScreenshot_2025-10-21_at_5.58.07_PM.png?table=block&id=293f94f7-98c1-8067-a92e-ed64d8999488&cache=v2)
Now in `settings.json` add the following property to `latex-workshop.latex.tools` 

```JSON
{
		"name": "xelatex",
		"command": "xelatex",
		"args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
    ]
},
{
		"name": "bibtex",
		"command": "bibtex",
		"args": [
				"%DOCFILE%"
		]
}
```
![](https://www.notion.so/image/attachment%3A15c6ccd3-cc4d-47bb-ab45-2d381cfa2fc7%3AScreenshot_2025-10-21_at_6.10.20_PM.png?table=block&id=293f94f7-98c1-8062-a755-ea4010d9d95a&cache=v2)
Then scroll up (or down) to find the `latex-workshop.latex.recipes` property and add the following to the top of the list:

```JSON
{
		"name": "xelatex",
		"tools": ["xelatex"]
},
{
		"name": "xe->bib->xe->xe",
		"tools": [
				"xelatex",
				"bibtex",
				"xelatex",
				"xelatex"
		]
},
```
![](https://www.notion.so/image/attachment%3A49b49c7f-63a0-44cb-92e5-2e3b549f6231%3AScreenshot_2025-10-21_at_6.16.18_PM.png?table=block&id=293f94f7-98c1-8027-acf2-c768de5ccb0a&cache=v2)
Now we be compile and preview LaTeX / BibTeX project with a simple click.



## 5. Additional package

To compile LaTeX files with Chinese characters, we need to import an additional package called **[xeCJK](https://www.ctan.org/pkg/xecjk)** which providing support for multiple asian languages. A simple latex template can be:

```LaTeX
\documentclass[letterpaper,11pt]{article}

\usepackage{fontspec}
\usepackage{xeCJK}

\begin{document}


\end{document}
```
# End Result

![](https://www.notion.so/image/attachment%3A37592de4-2531-4af5-9699-14ae8d4412b5%3AScreenshot_2025-10-21_at_6.26.46_PM.png?table=block&id=293f94f7-98c1-808d-aa1b-cc868c46aa2e&cache=v2)


## Sitemap

See the full [sitemap](/sitemap.md) for all pages.


## Contact Information

Chen Xiang (陈想)

- Email: xiiang.ch@gmail.com
- GitHub: https://github.com/Xiang-CH
- LinkedIn: https://www.linkedin.com/in/xiang-chen-62389526a/
- Instagram: https://www.instagram.com/chen.xiiang/
- X(Twitter): https://x.com/cxiiang

This page is also available as markdown: append `.md` to the URL path (for example, `/blog/my-post.md`) or send `Accept: text/markdown` for the same path.

