

Latex
source link: https://maxyoung.fun//blog/Latex.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

grammer
多行公式前后要用\begin{aligned}
和\end{aligned}
在要对齐的符号钱加上&
$$
\begin{aligned}
\sum_{k=1}^{500000}a_kp_k &= \sum_{k=1}^{500000}\left( a_k \cdot \frac{1}{5000} \right) \\
&= \frac{1}{500000}\cdot\sum_{k=1}^{500000}a_k \\
&= \frac{1}{500000}\cdot(1\cdot 999995 + 10 \cdot 995 + 10000 \cdot 5 + 488989 \cdot (-5)) \\
&= -1.78
\end{aligned}
$$
效果是:
∑k=1500000akpk=∑k=1500000(ak⋅15000)=1500000⋅∑k=1500000ak=1500000⋅(1⋅999995+10⋅995+10000⋅5+488989⋅(−5))=−1.78∑k=1500000akpk=∑k=1500000(ak⋅15000)=1500000⋅∑k=1500000ak=1500000⋅(1⋅999995+10⋅995+10000⋅5+488989⋅(−5))=−1.78
writing latex document in visual studio code
- install MacTex
brew install --cask mactex-no-gui
if install fail, probably there is not enough space in your computer.
- setting PATH environment variable
add the directory of mactex binaries to the~/.zshrc
, for example:export PATH=/usr/local/texlive/2022/bin/universal-darwin:$PATH
- update latex packges
sudo tlmgr update --self && sudo tlmgr update --all
- open/restart visual studio code if you install maxtex and set PATH environment variable during visual studio code is opening, please restart it.
- install LaTex Workshop extension
then you can build *.tex file to PDF file and preview it in visual studio code.
if you write with chinese, follow the steps below:
- add the following to the settings.json:
"latex-workshop.latex.tools": [ { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "%DOC%" ] }, { "name": "xelatex", "command": "xelatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ] }, { "name": "pdflatex", "command": "pdflatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ] }, { "name": "bibtex", "command": "bibtex", "args": [ "%DOCFILE%" ] } ], "latex-workshop.latex.recipes": [ { "name": "xelatex", "tools": [ "xelatex" ] }, { "name": "latexmk", "tools": [ "latexmk" ] }, { "name": "pdflatex -> bibtex -> pdflatex*2", "tools": [ "pdflatex", "bibtex", "pdflatex", "pdflatex" ] } ], "latex-workshop.view.pdf.viewer": "tab", "latex-workshop.latex.clean.fileTypes": [ "*.aux", "*.bbl", "*.blg", "*.idx", "*.ind", "*.lof", "*.lot", "*.out", "*.toc", "*.acn", "*.acr", "*.alg", "*.glg", "*.glo", "*.gls", "*.ist", "*.fls", "*.log", "*.fdb_latexmk" ]
- add package in your .tex file:
\usepackage[UTF8]{ctex}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK