<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% !TeX root = ../install-latex-guide-zh-cn.tex

\chapter{Windows Subsystem for Linux}

ç›®ĺ‰Ťĺľ®č˝ŻćŽ¨ĺ‡şäş† Windows Subsystem for Linux (WSL) äľ›ĺĽ€ĺŹ‘äşşĺ‘ä˝żç”¨.
ĺś¨čż™é‡Śç®€č¦ä»‹ç»Ťĺ¦‚ä˝•ĺś¨ WSL ä¸­ĺ®‰čŁ… \TeX{} Live.
ć‘é€‰ć‹©çš„ćŻ Windows 11 ĺľ®č˝Żĺ•†ĺş—ä¸­çš„ Ubuntu.
ć­¤çŻ‡ĺ®‰čŁ…ć•™ç¨‹ä»…äľ›ĺŹ‚č€.
čż™é‡Śç§° WSL ä¸­ä˝żç”¨çš„ĺ‘˝ä»¤čˇŚä¸ş \textsf{bash}.
\textbf{ä¸Ťĺ»şč®®}ĺŻąć“Ťä˝śçł»ç»źäş†č§Łä¸Ťĺ¤šçš„ç”¨ć·é…čŻ»ćś¬ç«&nbsp;ĺ†…ĺ®ą.

\section{ĺ®‰čŁ… \TeX{} Live}

ĺś¨ä¸»çł»ç»ź%
\footnote{ĺś¨ Windows 11 ä¸­ç›´ćŽĄčż›čˇŚçš„ć“Ťä˝śĺŤłä¸şĺś¨ä¸»çł»ç»źä¸­çš„ć“Ťä˝ś}%
ä¸­ä¸‹č˝˝
\href{https://mirrors.ctan.org/systems/texlive/Images/texlive2024.iso}{iso é•śĺŹć–‡ä»¶},
ĺŹŻé€‰ć‹©ĺ›˝ĺ†…ćşä»ĄĺŠ&nbsp;ĺż«ä¸‹č˝˝é€źĺş¦.
ä¸‹č˝˝ĺ®ŚćŻ•ĺŽ, ĺś¨ \textsf{cmd} ä¸­éŞŚčŻć–‡ä»¶ćŻĺ¦ć­Łĺ¸¸.
ä¸‹č˝˝ĺŹŠć–‡ä»¶éŞŚčŻć–ąćł•ĺŚ \ref{sec:windows:install}~čŠ‚.

ĺś¨ć­ŁĺĽŹĺ®‰čŁ…ĺ‰Ť,
ç”¨ć·éś€č¦ĺś¨ \textsf{bash} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  sudo apt install fontconfig gedit
\end{lstlisting}
ä»Ąĺ‡Źĺ°‘ĺŽç»­ĺ­—ä˝“é—®é˘ĺ’Ść–‡ćś¬çĽ–čľ‘é—®é˘.
ĺś¨ Windows 11 ä¸­,
WSL ĺ·˛ç»Źč˝ĺ¤źč‡ŞĺŠ¨ĺ®ŚćĺŹŻč§†ĺŚ–ĺ·Ąä˝ś,
čż™ä¸şä¸€äş›ç”¨ć·ćŹäľ›äş†äľżĺ©.
ä¸şéżĺ…Ťĺ®‰čŁ…é€źĺş¦čż‡ć…˘,
ĺŹŻä»żç…§ \ref{sec:addition:source}~čŠ‚ć›´ć”ąć–‡ä»¶ \texttt{sources.list}.
ä¸Ťäą&nbsp;ćŻĺś¨ \textsf{gedit} ä¸­ĺšć–‡ćś¬ć“Ťä˝śçš„ Windows ç”¨ć·,
ĺŹŻĺŹ‚č€ \ref{sec:addition:wsl-editor}~čŠ‚.

ćŽĄä¸‹ćťĄ, ĺś¨ä¸»çł»ç»źä¸­ĺ°†é•śĺŹčŁ…č˝˝,
äľ‹ĺ¦‚ćŚ‚č˝˝ĺ° \texttt{X:\textbackslash},
č€ŚĺŽčż›ĺ…Ą \textsf{bash} ĺą¶ć‰§čˇŚĺ¦‚ä¸‹ĺ‘˝ä»¤
\begin{lstlisting}[language = bash]
  sudo mkdir /mnt/x
  sudo mount -t drvfs X: /mnt/x
\end{lstlisting}
ĺ¦‚ć­¤äľżĺŹŻĺś¨ \textsf{bash} ä¸­ć‰ľĺ°čŁ…č˝˝çš„ĺ…‰ç›é•śĺŹ.
äą‹ĺŽć‰§čˇŚ
\begin{lstlisting}[language = bash]
  sudo /mnt/x/install-tl
\end{lstlisting}
čż›čˇŚĺ®‰čŁ….
ĺś¨ĺ±Źĺą•ä¸Šĺş”čŻĄč˝č§ĺ°ä»Ąä¸‹ĺ†…ĺ®ą
\begin{lstlisting}
  ======================&gt; TeX Live installation procedure &lt;=====================

  ======&gt;   Letters/digits in &lt;angle brackets&gt; indicate   &lt;=======
  ======&gt;   menu items for actions or customizations      &lt;=======
  = help&gt;   https://tug.org/texlive/doc/install-tl.html   &lt;=======
  
   Detected platform: GNU/Linux on x86_64
  
   &lt;B&gt; set binary platforms: 1 out of 15
  
   &lt;S&gt; set installation scheme: scheme-full
  
   &lt;C&gt; set installation collections:
       40 collections out of 41, disk space required: 8315 MB (free: 974100 MB)
  
   &lt;D&gt; set directories:
     TEXDIR (the main TeX directory):
       /usr/local/texlive/2024
     TEXMFLOCAL (directory for site-wide local files):
       /usr/local/texlive/texmf-local
     TEXMFSYSVAR (directory for variable and automatically generated data):
       /usr/local/texlive/2024/texmf-var
     TEXMFSYSCONFIG (directory for local config):
       /usr/local/texlive/2024/texmf-config
     TEXMFVAR (personal directory for variable and automatically generated data):
       ~/.texlive2024/texmf-var
     TEXMFCONFIG (personal directory for local config):
       ~/.texlive2024/texmf-config
     TEXMFHOME (directory for user-specific files):
       ~/texmf
  
   &lt;O&gt; options:
     [ ] use letter size instead of A4 by default
     [X] allow execution of restricted list of programs via \write18
     [X] create all format files
     [X] install macro/font doc tree
     [X] install macro/font source tree
     [ ] create symlinks to standard directories
     [X] after install, set CTAN as source for package updates
  
   &lt;V&gt; set up for portable installation
  
  Actions:
   &lt;I&gt; start installation to hard disk
   &lt;P&gt; save installation profile to 'texlive.profile' and exit
   &lt;Q&gt; quit
  
  Enter command:
\end{lstlisting}
ç”¨ć·ç›´ćŽĄç‚ąĺ‡» \keys{I} ä˝żç”¨é»č®¤é…Ťç˝®ĺ®‰čŁ….
ĺ¦‚ćžśç”¨ć·ĺŻąäşŽ WSL ćŻ”čľäş†č§Ł, ĺŹŻä»Ąć&nbsp;ąćŤ®ćŹç¤ş, ć›´ć”ąĺ®‰čŁ…č®ľç˝®.
ä¸şç®€ĺŚ–čµ·č§,
ä»Ąä¸‹ĺ†…ĺ®ąĺť‡č®¤ä¸şç”¨ć·čż›čˇŚé»č®¤ĺ®‰čŁ….
ĺ®‰čŁ…ĺ®ŚćŻ•ĺŽ, éś€ç»§ç»­ĺś¨ \textsf{bash} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language = bash]
  sudo umount /mnt/x
  sudo rmdir /mnt/x
\end{lstlisting}
ĺĽąĺ‡şĺ·˛čŁ…č˝˝çš„ĺ…‰ç›é•śĺŹ.

é»č®¤ĺ®‰čŁ…ĺ®ŚćĺŽ, ç”¨ć·éś€č¦č®ľç˝®çŽŻĺ˘ĺŹé‡Ź.
ç»§ç»­ĺś¨ \textsf{bash} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language = bash]
  gedit ~/.profile
\end{lstlisting}
ĺś¨ć‰“ĺĽ€çš„ć–‡ä»¶ćś«ĺ°ľć·»ĺŠ&nbsp;
\begin{lstlisting}
  # Add TeX Live to the PATH, MANPATH, INFOPATH
  export PATH=/usr/local/texlive/2024/bin/x86_64-linux:$PATH
  export MANPATH=/usr/local/texlive/2024/texmf-dist/doc/man:$MANPATH
  export INFOPATH=/usr/local/texlive/2024/texmf-dist/doc/info:$INFOPATH
\end{lstlisting}
ĺą¶äżťĺ­é€€ĺ‡ş.
ĺŚć&nbsp;·,
ä¸Ťäą&nbsp;ćŻäşŽ \textsf{gedit} ĺ¤„ç†ć–‡ćś¬çš„ Windows ç”¨ć·ĺŹŻĺŹ‚č€ \ref{sec:addition:wsl-editor}~čŠ‚.
é€€ĺ‡ş WSL ĺ†Ťčż›ĺ…Ą,
ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  tex -v
\end{lstlisting}
ĺ°†ćľç¤ş
\begin{lstlisting}
  TeX 3.141592653 (TeX Live 2024)
  kpathsea version 6.4.0
  Copyright 2024 D.E. Knuth.
  There is NO warranty.  Redistribution of this software is
  covered by the terms of both the TeX copyright and
  the Lesser GNU General Public License.
  For more information about these matters, see the file
  named COPYING and the TeX source.
  Primary author of TeX: D.E. Knuth.
\end{lstlisting}
ĺŤłä¸şĺ®‰čŁ…ćĺŠź.

ćŽĄä¸‹ćťĄä»żç…§ Ubuntu 22.04 ĺ¤„ç†ĺ­—ä˝“.
é¦–ĺ…ĺ°†é…Ťç˝®ć–‡ä»¶ĺ¤Ťĺ¶ĺ°çł»ç»ź,
ĺś¨ \textsf{bash} ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  sudo cp /usr/local/texlive/2024/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf
\end{lstlisting}
ç„¶ĺŽĺś¨ \textsf{bash} ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  sudo fc-cache -fsv
\end{lstlisting}
ĺ·ć–°ĺ­—ä˝“çĽ“ĺ­.

\subsection{ĺś¨ç”¨ć·ć–‡ä»¶ĺ¤ąĺ®‰čŁ…}

WSL ĺŚć&nbsp;·äąźĺŹŻä»Ąĺś¨ç”¨ć·ć–‡ä»¶ĺ¤ąä¸­ĺ®‰čŁ…,
ĺ®çš„ç”¨ć·ć–‡ä»¶ĺ¤ąĺľ€ĺľ€ĺś¨ä¸»çł»ç»źçš„çł»ç»źç›ä¸­.
ĺ…·ä˝“čż‡ç¨‹äąźĺŹŻä»ĄĺŹ‚č€ç¬¬~\ref{subsec:ubuntu-user-folder}~čŠ‚.

\section{ĺŤ¸č˝˝ \TeX{} Live}

WSL ä¸­çš„ć–ąćł•ĺŚ \ref{sec:ubuntu:uninstall}~čŠ‚.

\section{č·¨ç‰ćś¬ĺŤ‡çş§ \TeX{} Live}

WSL ä¸­çš„ć–ąćł•ĺŚ \ref{sec:ubuntu:version}~čŠ‚.

\section{ĺŤ‡çş§ĺ®ŹĺŚ…}

WSL ä¸­çš„ć–ąćł•ĺŚ \ref{sec:ubuntu:update}~čŠ‚.

\section{ĺ®‰čŁ…ĺ®ŹĺŚ…}

WSL ä¸­çš„ć–ąćł•ĺŚ \ref{sec:ubuntu:installpackage}~čŠ‚.

\section{č°ĺ‡şĺ®ŹĺŚ…ć‰‹ĺ†Ś}

ç”±äşŽ WSL çš„ \textsf{bash} é»č®¤ćŻć—&nbsp;çŞ—ĺŹŁĺŚ–çš„çşŻĺ‘˝ä»¤čˇŚ,
ĺ›&nbsp;ć­¤ĺ°† \TeX{} Live ĺ®‰čŁ…č‡ł WSL ĺŽ,
ç”¨ć·ć—&nbsp;ćł•ç›´ćŽĄé€ščż‡ĺ‘˝ä»¤ \texttt{texdoc} ć‰“ĺĽ€ç›¸ĺş”çš„ć‰‹ĺ†Ś.
ä¸‹éť˘ĺ‡&nbsp;ç§Ťć–ąćł•ĺť‡ä¸şć”¶é›†č€ŚćťĄçš„ć–ąćˇ,
ĺ…¶ä¸­ćŻ”čľćŽ¨čŤć›´ć”ą \texttt{texdoc.cnf}.

\subsubsection{ć›´ć”ą \texttt{texdoc.cnf}}

ć­¤ć–ąćˇćşč‡Şćś¬ć‰‹ĺ†Śçš„ \href{https://github.com/OsbertWang/install-latex-guide-zh-cn/issues/13}{issue}.
é¦–ĺ…ĺś¨ \textsf{bash} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  texdoc --files
\end{lstlisting}
çł»ç»źčż”ĺ›žç±»äĽĽĺ¦‚ä¸‹ĺ†…ĺ®ą
\begin{lstlisting}[language=bash]
  /usr/local/texlive/2024/texmf-dist/scripts/texdoc/texdoclib.tlu 4.0.1
  Configuration file(s):
      active      /usr/local/texlive/2024/texmf-dist/texdoc/texdoc.cnf
  Recommended file(s) for personal settings:
      /home/osbertwang/texmf/texdoc/texdoc.cnf
\end{lstlisting}
čż™é‡Śç»™ĺ‡şäş† \texttt{texdoc} çš„é…Ťç˝®ć–‡ä»¶ć‰€ĺś¨ä˝Ťç˝®.
ć‰“ĺĽ€ç”¨ć·ć–‡ä»¶ĺ¤ąä¸‹çš„é…Ťç˝®ć–‡ä»¶
\begin{lstlisting}[language=bash]
  vim ~/texmf/texdoc/texdoc.cnf
\end{lstlisting}
ĺś¨ć–‡ä»¶ĺ†…ĺ†™ĺ…Ą
\begin{lstlisting}
  viewer_pdf = (powershell.exe -Command Start-Process $(wslpath -w %s)) &amp;
\end{lstlisting}
ĺą¶ä¸”äżťĺ­é€€ĺ‡ş.
ç„¶ĺŽĺ†Ťć‰§čˇŚ \texttt{texdoc} ĺŤłĺŹŻć‰“ĺĽ€ç›¸ĺş”ć–‡ćˇŁ.

\subsubsection{explorer ćµŹč§}

ĺ…ć‰ľĺ°ć‰‹ĺ†Ść‰€ĺś¨č·Żĺľ„,
äľ‹ĺ¦‚ĺŻ»ć‰ľ \texttt{lshort-zh-cn}
\begin{lstlisting}[language=bash]
  texdoc -l lshort-zh-cn
\end{lstlisting}
çł»ç»źäĽšćľç¤ş
\begin{lstlisting}
   1 /usr/local/texlive/2024/texmf-dist/doc/latex/lshort-chinese/lshort-zh-cn.pdf
     = [zh] The document itself
  Enter number of file to view, RET to view 1, anything else to skip:
\end{lstlisting}
čż™ć—¶ćŚ‰ĺ…¶ä»–é”® (ĺ¦‚ \keys{x}) é€€ĺ‡ş.
ç„¶ĺŽĺ†ĺ«ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  cd /usr/local/texlive/2024/texmf-dist/doc/latex/lshort-chinese/
  explorer.exe .
\end{lstlisting}
ä¸»çł»ç»źçš„čµ„ćşç®ˇç†ĺ™¨äľżäĽšć‰“ĺĽ€.
čż™ć—¶ç”¨ć·äľżĺŹŻä»Ąĺś¨ä¸»çł»ç»źä¸­ä˝żç”¨ pdf é…čŻ»ĺ™¨ć‰“ĺĽ€ć‰‹ĺ†Śčż›čˇŚé…čŻ».

\subsubsection{everything ćśç´˘}

ä˝żç”¨ \href{https://www.voidtools.com/zh-cn/}{everything}.
é€ščż‡ \texttt{texdoc -l} ć‰ľĺ°ç›¸ĺş”ć–‡ä»¶ĺŤ,
č€ŚĺŽç›´ćŽĄćśç´˘.
ĺ…·ä˝“ć–ąćł•čż™é‡Śä¸Ťĺ†Ťčµčż°.

\subsubsection{ĺ€źĺŠ©ĺ…¶ä»–ĺ·Ąĺ…·}

ç›®ĺ‰Ťćś‰ĺľĺ¤šĺĽ€ćşçš„ WSL čľ…ĺŠ©ç¨‹ĺşŹ,
ç›¸ĺ…łč®¨č®şč§ćś¬ć‰‹ĺ†Śçš„ \href{https://github.com/OsbertWang/install-latex-guide-zh-cn/issues/13}{issue}.

\section{çĽ–čŻ‘ć–‡ä»¶}

çĽ–čŻ‘ä¸€ä¸Şćś€ĺ°Źç¤şäľ‹ \texttt{main.tex}.

ĺś¨ä¸»çł»ç»źçš„ \textsf{cmd} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  mkdir D:\work-latex
  cd /d D:\work-latex
  notepad main.tex
\end{lstlisting}
ĺ»şç«‹ć–‡ćˇŁ,
ĺ†…ĺ®ąä¸ş
\begin{lstlisting}[language = {[LaTeX]TeX}]
  \documentclass{article}
  \begin{document}
    Hello \LaTeX{} World!
  \end{document}
\end{lstlisting}
ćŽĄä¸‹ćťĄĺś¨ \textsf{cmd} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  bash -i -c "pdflatex main"
\end{lstlisting}
ĺ®žçŽ°çĽ–čŻ‘.

äąźĺŹŻä»Ąç›´ćŽĄĺś¨ WSL ä¸­ĺ»şç«‹ć–‡ćˇŁĺą¶çĽ–čŻ‘,
ĺś¨ \texttt{bash} ä¸­äľťć¬ˇć‰§čˇŚ
\begin{lstlisting}[language=bash]
  mkdir /mnt/d/work-latex
  cd /mnt/d/work-latex
  gedit main.tex
\end{lstlisting}
ĺ»şç«‹ć–‡ćˇŁ,
ĺ†…ĺ®ąĺŚä¸Š,
ç„¶ĺŽĺś¨ \textsf{bash} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  pdflatex main
\end{lstlisting}
ĺ®žçŽ°çĽ–čŻ‘.

ĺľ…çĽ–čŻ‘ĺ®ŚćĺŽ, ĺŹŻçś‹ĺ°ĺś¨ĺ·Ąä˝śč·Żĺľ„ä¸­ç”źćäş† \texttt{main.pdf}
ć–‡ä»¶ĺ’Śĺ…¶ä»–ĺŚĺŤçš„čľ…ĺŠ©ć–‡ä»¶ \texttt{main.aux} ä¸Ž \texttt{main.log}.
ĺś¨ä¸»çł»ç»źä¸­ĺŹŻä»Ąć‰“ĺĽ€ \texttt{main.pdf} ćźĄçś‹ĺ†…ĺ®ą.

ĺŻąäşŽä¸­ć–‡ć–‡ćˇŁ,
ĺŹŻä»ĄçĽ–ĺ†™ä»Ąä¸‹ćś€ĺ°Źç¤şäľ‹%
\footnote{ćł¨ć„Źä˝żç”¨ UTF-8 çĽ–ç&nbsp;}%
\begin{lstlisting}[language={[LaTeX]TeX}]
  \documentclass[UTF8,fontset=fandol]{ctexart}
  \begin{document}
    ä˝&nbsp;ĺĄ˝ \LaTeX{} ä¸–ç•ŚďĽ
  \end{document}
\end{lstlisting}
ĺś¨ \textsf{cmd} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  bash -i -c "xelatex main"
\end{lstlisting}
ć–ĺś¨ \textsf{bash} ä¸­ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  xelatex main
\end{lstlisting}
ç­‰ĺľ…çł»ç»źĺ®ŚćçĽ–čŻ‘čż‡ç¨‹. 
\texttt{xelatex} ĺŚć&nbsp;·ĺŹŻä»Ąä˝żç”¨ WSL ĺ†…ĺ®‰čŁ…çš„ĺ­—ä˝“%
\footnote{ćł¨ć„Źä¸»çł»ç»źä¸­çš„ĺ­—ä˝“é»č®¤ä¸Ťč˝ç›´ćŽĄč˘«č°ç”¨,
ĺ¦‚ćžść‰“ç®—ä˝żç”¨ä¸»çł»ç»źä¸­çš„ĺ­—ä˝“,
č§
\href{https://github.com/OsbertWang/install-latex-guide-zh-cn/issues/14}{github ä¸Šçš„č®¨č®ş},
é‰´äşŽ WSL2 ĺ’Śä¸»çł»ç»źć–‡ä»¶çł»ç»źäş’č®żé€źĺş¦ć…˘,
čŻĄć–ąćł•ĺľĺŹŻč˝ć‹–ć…˘ xelatex é€źĺş¦},
ĺś¨ WSL ä¸­ĺ®‰čŁ…ĺ­—ä˝“çš„ć–ąćł•č§ \ref{sec:addition:font}~čŠ‚.

çĽ–čŻ‘ĺ‘˝ä»¤ĺŹŻć·»ĺŠ&nbsp;ĺŹ‚ć•°, čż™é‡Śä¸Ž \ref{sec:windows:compile}~čŠ‚ä¸­çš„ć…ĺ˝˘ä¸€č‡´, ä¸Ťĺ†Ťčµčż°.
</pre></body></html>