前一陣子要 re-build 之前用 LaTeX 寫的文章,試了好幾種方法,最後發現只要把 MiKTeX 裝起來就搞定了。基本上隨附的 TeXworks 編輯器也夠好用。

但如果想要在 Visual Studio Code(VS Code)中編輯,請先安裝 VS Code 外掛 LaTeX Workshop:

若要使用我之前寫的樣版(LaTeX 中英文報告 preamble 設定(2018)),要調成使用 XeLaTeX 來編譯。細節可以參考下列設定(settings.json):
{
"livePreview.notifyOnOpenLooseFile": false,
"editor.unicodeHighlight.nonBasicASCII": false,
"[python]": {
"editor.formatOnType": true
},
"python.defaultInterpreterPath": "C:\\Users\\show6\\AppData\\Local\\Programs\\Python\\Python311\\python.exe",
"window.zoomLevel": 1,
"security.workspace.trust.untrustedFiles": "open",
"git.openRepositoryInParentFolders": "always",
"explorer.confirmDelete": false,
"git.autofetch": true,
"interactiveWindow.executeWithShiftEnter": true,
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"%DOC%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "lualatexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-lualatex",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "xelatexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-xelatex",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "latexmk_rconly",
"command": "latexmk",
"args": [
"%DOC%"
],
"env": {}
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
],
"env": {}
},
{
"name": "rnw2tex",
"command": "Rscript",
"args": [
"-e",
"knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')"
],
"env": {}
},
{
"name": "jnw2tex",
"command": "julia",
"args": [
"-e",
"using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")"
],
"env": {}
},
{
"name": "jnw2texminted",
"command": "julia",
"args": [
"-e",
"using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")"
],
"env": {}
},
{
"name": "pnw2tex",
"command": "pweave",
"args": [
"-f",
"tex",
"%DOC_EXT%"
],
"env": {}
},
{
"name": "pnw2texminted",
"command": "pweave",
"args": [
"-f",
"texminted",
"%DOC_EXT%"
],
"env": {}
},
{
"name": "tectonic",
"command": "tectonic",
"args": [
"--synctex",
"--keep-logs",
"--print",
"%DOC%.tex"
],
"env": {}
}
],
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
}
]
}
測試 OK 的環境:
- Windows 11 24H2
- MikTeX 24.1
- LaTeX Workshop 10.9.1
發表留言