📢 This article was translated by gemini-3-flash-preview
Writing articles with citations in Word can be a real pain. After trying LaTeX, I realized it’s just like my switch to Markdown—focusing purely on the writing experience is fantastic. Plus, the generated PDFs look professional and polished.
This post focuses on setting up LaTeX in VS Code and lists common syntax. For detailed documentation, check the official tutorials linked at the end.
Installation
Installing TeX Live is the easiest route as it includes most common dependencies:
https://www.tug.org/texlive/
. Be warned: the installation takes quite a long time.
In VS Code, press Ctrl+Shift+X to open the extensions view, search for and install LaTeX Workshop.
Once installed, press Ctrl+, to open settings. Search for “Latex Recipes” and click to edit in setting.json. Move latexmk (xelatex) to the first position in the latex-workshop.latex.recipes array. You might also want to enable word wrap while you’re at it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
| {
"latex-workshop.latex.recipes": [
{
"name": "latexmk (xelatex)",
"tools": [
"xelatexmk"
]
},
{
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "latexmk (latexmkrc)",
"tools": [
"latexmk_rconly"
]
},
{
"name": "latexmk (lualatex)",
"tools": [
"lualatexmk"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex * 2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
},
{
"name": "Compile Rnw files",
"tools": [
"rnw2tex",
"latexmk"
]
},
{
"name": "Compile Jnw files",
"tools": [
"jnw2tex",
"latexmk"
]
},
{
"name": "Compile Pnw files",
"tools": [
"pnw2tex",
"latexmk"
]
},
{
"name": "tectonic",
"tools": [
"tectonic"
]
}
],
"[latex]": {
"editor.wordWrap": "on"
},
}
|
Document Structure
A typical LaTeX document structure looks like this. The actual content starts at \begin{document}; everything before that is the preamble for imports and configuration.
1
2
3
4
5
6
7
8
9
10
11
| \documentclass[a4paper,12pt]{article} % The document class with options
% select T1 font encoding: suitable for Western European Latin scripts
\usepackage[T1]{fontenc}
% A comment in the preamble
\begin{document}
% This is a comment
This is a simple
document\footnote{with a footnote}.
This is a new paragraph.
\end{document}
|
Document Classes
LaTeX supports various document classes specified in \documentclass{}. The five standard classes are:
- article
- report
- book
- letter
- slides
Paragraph Indentation
Import the indentfirst package to ensure every paragraph is indented, then configure the indentation width.
1
2
| \usepackage{indentfirst} % indent
\setlength{\parindent}{1em} % set indent for 1em
|
Japanese Support
Use xeCJK and configure the fonts.
1
2
3
4
5
| \usepackage{xeCJK} % kanji
\setCJKmainfont{MS Mincho}
\setCJKsansfont{MS Gothic}
\setCJKmonofont{MS Gothic}
|
Headings
Use \section{} and related commands to define the structure.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| \documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Hey world!
This is a first document.
\section{Title of the first section}
Text of material in the first section
Second paragraph.
\subsection{Subsection of the first section}
Text of material in the subsection.
\section{Second section}
Text of the second section.
\end{document}
|
Math
For visual math editing, you can use
https://www.latexlive.com/
.
Lists
There are two primary ways to create lists:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| \documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Ordered
\begin{enumerate}
\item An entry
\item Another One
\item Wow! Three entries
\end{enumerate}
Unordered
\begin{itemize}
\item An entry
\item Another One
\item Wow! Three entries
\end{itemize}
\end{document}
|
Citations
You can rename the reference section title in the preamble using \renewcommand{\refname}{References}.
Create a .bib file in the same directory, e.g., citations.bib.
Cite references in your document using \cite{key}. Separate multiple keys with commas.
Generate the bibliography at the end of the document:
1
2
3
4
5
6
| \small
%% set small size
\bibliographystyle{IEEEtran}
%% you can change the style into any other styles available, I personally love IEEEtran.
\bibliography{citations}
%% to generate references, input the name of your .bib file and cite anywhere in the document.
|
References