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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
% !TeX root = ../install-latex-guide-zh-cn.tex
\chapter{有关 WSL 的一点补充内容}\label{chp:appendix:wsl}
有用户指出,
WSL (本质上是 Ubuntu) 中安装字体比较麻烦.
这里引用
\href{https://www.jianshu.com/p/e7f12b8c8602}{Ubuntu系统字体命令和字体的安装}
一文.
大致步骤如下.
首先获取需要安装的字体文件,
假设文件保存在 \verb|~/fonts/|.
然后在 \texttt{/usr/share/fonts/} 文件夹中创建新的文件夹,
例如 \texttt{myfonts}
\begin{lstlisting}[language=bash]
cd /usr/share/fonts/
sudo mkdir myfonts
\end{lstlisting}
接下来将获取的字体文件复制到 \texttt{myfonts} 中
\begin{lstlisting}[language=bash]
sudo cp ~/fonts/* /usr/share/fonts/myfonts/
\end{lstlisting}
然后修改字体文件的权限
\begin{lstlisting}[language=bash]
sudo chmod -R 755 myfonts
\end{lstlisting}
最后建立字体缓存
\begin{lstlisting}[language=bash]
mkfontscale
mkfontdir
fc-cache -fv
\end{lstlisting}
实际上有部分字体可直接使用源进行安装,
如安装 \texttt{Noto CJK}
\begin{lstlisting}[language=bash]
sudo apt-get install fonts-noto-cjk
sudo apt-get install fonts-noto-cjk-extra
\end{lstlisting}
由于 \TeX studio 在 WSL 中无法正常正反搜索,
因此我使用了 VS Code 配合
\href{https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl}{Remote WSL}
和
\href{https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop}{\LaTeX{} Workshop}
来编写文档.
这里将个人使用的相关配置附上,
其中注释的部分是调用外部 SumatraPDF 阅读器的配置,
用户可参考
\href{https://github.com/OsbertWang/latex-editor-sumatrapdf}{latex-editor-sumatrapdf}
来了解更多内容.
\begin{lstlisting}
"latex-workshop.latex.tools": [
{
"name": "latexmkpdf",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-halt-on-error",
"-file-line-error",
"-pdf",
"%DOCFILE%"
]
},
{
"name": "latexmkxe",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-halt-on-error",
"-file-line-error",
"-xelatex",
"%DOCFILE%"
]
},
],
"latex-workshop.latex.recipes": [
{
"name": "latexmkpdf",
"tools": [
"latexmkpdf"
]
},
{
"name": "latexmkxe",
"tools": [
"latexmkxe"
]
},
],
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.view.pdf.viewer": "tab"
// "latex-workshop.view.pdf.viewer": "external",
// "latex-workshop.view.pdf.ref.viewer": "external",
// "latex-workshop.view.pdf.external.viewer.command": "<SumatraPDFROOT>/SumatraPDF.exe",
// "latex-workshop.view.pdf.external.viewer.args": [
// "-inverse-search",
// "\"<VSCodeROOT>/bin/code.cmd\" -r -g \"%f:%l\"",
// "%PDF%"
// ],
// "latex-workshop.view.pdf.external.synctex.command":"<SumatraPDFROOT>/SumatraPDF.exe",
// "latex-workshop.view.pdf.external.synctex.args":[
// "-forward-search",
// "%TEX%",
// "%LINE%",
// "%PDF%",
// ],
\end{lstlisting}
实际配置时,
用户需要结合自身安装情况更换 \texttt{<SumatraPDFROOT>} 和 \texttt{<VSCodeROOT>},
即 SumatraPDF 和 VS Code 各自的安装路径.
希望阅读本文的用户能够尽快上手使用 \LaTeX.
|