<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{macOS}\label{chap:macOS}

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

Mac\TeX{} ćŻ \TeX{} Live ĺś¨ macOS ä¸‹çš„ĺ†Ťć‰“ĺŚ…ç‰ćś¬,
ĺą¶é˘ťĺ¤–ĺŠ&nbsp;ĺ…Ąäş†ä¸€äş›čľ…ĺŠ©ç¨‹ĺşŹ.
ĺś¨ macOS ä¸Šĺ®‰čŁ… Mac\TeX ĺŹŻä»Ąé€‰ć‹©ä»Ąä¸‹ä¸¤ç§Ťć–ąĺĽŹ: 
\begin{description}
  \item[ç›´ćŽĄä¸‹č˝˝ Mac\TeX{} ĺ®‰čŁ…ĺŚ…čż›čˇŚĺ®‰čŁ…]
  ĺ°†ĺ®‰čŁ…ć–‡ä»¶ä¸‹č˝˝ĺ°ćś¬ĺś°,
  ç„¶ĺŽćŚ‰ç…§ĺ®‰čŁ…ćŹç¤şčż›čˇŚĺ®‰čŁ….
  \item[ĺ€źĺŠ© Homebrew ä»Ąĺ‘˝ä»¤čˇŚć–ąĺĽŹĺ®‰čŁ…]
  ĺ…ĺ®‰čŁ… Homebrew,
  ç„¶ĺŽé€ščż‡ĺ‘˝ä»¤čˇŚčż›čˇŚĺś¨çşżĺ®‰čŁ….
\end{description}

ç›®ĺ‰ŤćŻ”čľćŽ¨čŤç›´ćŽĄä¸‹č˝˝ Mac\TeX{} ĺ®‰čŁ…ĺŚ…çš„ĺ®‰čŁ…ć–ąĺĽŹ,
ĺ›&nbsp;ä¸şćś€čż‘ä¸€ć®µć—¶é—´ä»ĄćťĄ,
ĺ¤§é™†ç”¨ć·ĺŻą GitHub çš„č®żé—®ćžä¸Ťç¨łĺ®š,
ćś‰ĺŹŻč˝äĽšĺŻĽč‡´ Homebrew ĺ®‰čŁ…ĺ¤±č´Ą.

\subsection{ç›´ćŽĄä¸‹č˝˝ Mac\TeX{} ĺ®‰čŁ…ĺŚ…čż›čˇŚĺ®‰čŁ…}

\href{https://mirror.ctan.org/systems/mac/mactex/MacTeX.pkg}{ä¸‹č˝˝} Mac\TeX{} çš„ĺ®‰čŁ…ĺŚ… \texttt{MacTeX.pkg},
ĺś¨çł»ç»źĺ†…ç‚ąĺ‡»ĺ·˛ä¸‹č˝˝çš„ \texttt{MacTeX.pkg} ć–‡ä»¶,
ć&nbsp;ąćŤ®çł»ç»źćŹç¤şčż›čˇŚĺ®‰čŁ…ĺŤłĺŹŻ.
čż™ä¸Şčż‡ç¨‹ä¸Žĺ®‰čŁ… macOS ä¸Šçš„ĺ…¶ä»–č˝Żä»¶ĺą¶ć—&nbsp;ĺ¤Şĺ¤šä¸ŤĺŚ.

ĺŹ¦ĺ¤–,
ç”¨ć·äąźĺŹŻä»Ąé€‰ć‹©ĺ›˝ĺ†…ĺ„ä¸Şé•śĺŹćťĄä¸‹č˝˝ \texttt{MacTeX.pkg}.
ĺ›&nbsp;ĺ…¶ç‹¬ç‰ąć€§,
ç”¨ć·éś€č°ć•´é™„ĺ˝•~\ref{chp:appendix:mirror} ä¸­ćŹäľ›çš„ĺ¤§é™†ĺś°ĺŚşçš„ćşçš„ç˝‘ĺť€,
ĺ…·ä˝“ćťĄč®˛,
ćŻĺ°† \texttt{.../texlive} ć”ąä¸ş \texttt{.../mac/mactex}.
äľ‹ĺ¦‚,
éżé‡Śäş‘çš„é•śĺŹĺś°ĺť€ä¸ş \url{https://mirrors.aliyun.com/CTAN/systems/mac/mactex/},
ĺŚ—äş¬äş¤é€šĺ¤§ĺ­¦çš„é•śĺŹĺś°ĺť€ä¸ş \url{https://mirror.bjtu.edu.cn/ctan/systems/mac/mactex/},
ĺ…¶ä»–é•śĺŹç±»äĽĽ,
ä¸Ťĺ†Ťä¸€ä¸€ĺ—ä¸ľ.

\subsection{ĺ€źĺŠ© Homebrew ä»Ąĺ‘˝ä»¤čˇŚć–ąĺĽŹĺ®‰čŁ…}

ĺ»şč®®ç”¨ć·ĺ­¦äą&nbsp;ä˝żç”¨ \href{https://brew.sh}{Homebrew},
Homebrew ćŻä¸€ä¸ŞĺŚ…ç®ˇç†ĺ·Ąĺ…·,
ç±»äĽĽ Ubuntu ä¸Šéť˘çš„ \texttt{apt-get}.

\subsubsection{ĺ®‰čŁ… Homebrew}

Homebrew ĺ®‰čŁ…ć•™ç¨‹ĺŹŻä»Ąĺś¨ĺ…¶ç˝‘ç«™ć‰ľĺ°,
čż™é‡Śç®€ĺŤ•ĺ—ĺ‡şćťĄ%
\footnote{ĺŹ‚č§ \href{https://docs.brew.sh/Installation\#git-remote-mirroring}{Homebrew ĺ®ć–ąć–‡ćˇŁ}}
\begin{lstlisting}[language=bash]
  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
\end{lstlisting}
ĺ°†ä»Ąä¸Šĺ‘˝ä»¤ĺś¨\textsf{ç»ç«Ż}\footnote{%
  ć‰“ĺĽ€ć–ąćł•ä¸ş: \keys{\cmdmac + \SPACE}, čľ“ĺ…Ą \textsf{terminal} ĺą¶ć‰“ĺĽ€ \menu{ç»ç«Ż} ĺş”ç”¨}%
ć‰§čˇŚ.
č„šćś¬äĽšĺś¨ć‰§čˇŚĺ‰Ťćš‚ĺś, ĺą¶čŻ´ćŽĺ®ĺ°†ĺšä»€äą. äľťćŤ®ĺ±Źĺą•ćŚ‡ä»¤ć‰§čˇŚĺŤłĺŹŻ.

ä¸­ĺ›˝ĺ¤§é™†ç”¨ć·ĺŹŻä»Ąä˝żç”¨é•śĺŹä»ĄćŹé«č®żé—®é€źĺş¦.
ä»Ąä¸Šćµ·äş¤é€šĺ¤§ĺ­¦é•śĺŹćşä¸şäľ‹%
\footnote{ć­¤ĺ¤„ć¶‰ĺŹŠçš„çŽŻĺ˘ĺŹé‡ŹĺŹ‚č§ \href{https://docs.brew.sh/Manpage\#environment}{Homebrew ĺ®ć–ąć–‡ćˇŁ},
ä¸Šćµ·äş¤é€šĺ¤§ĺ­¦é•śĺŹç«™çš„ĺ®‰čŁ…čŻ´ćŽč§
\href{https://mirrors.sjtug.sjtu.edu.cn/docs/git/brew.git}{git/brew.git},
\href{https://mirrors.sjtug.sjtu.edu.cn/docs/git/homebrew-core.git}{git/homebrew-core.git},
\href{https://mirrors.sjtug.sjtu.edu.cn/docs/git/homebrew-cask.git}{git/homebrew-cask.git},
\href{https://mirrors.sjtug.sjtu.edu.cn/docs/homebrew-bottles}{homebrew-bottles},
ĺ…¶ä»–é•śĺŹç«™çš„ĺ®‰čŁ…čŻ´ćŽĺŹ‚č§
\href{https://help.mirrors.cernet.edu.cn/homebrew/}{Homebrew č˝Żä»¶ä»“ĺş“é•śĺŹä˝żç”¨ĺ¸®ĺŠ©},
\href{https://help.mirrors.cernet.edu.cn/homebrew-bottles/}{Homebrew Bottles č˝Żä»¶ä»“ĺş“é•śĺŹä˝żç”¨ĺ¸®ĺŠ©}}
\begin{lstlisting}[language=bash]
  echo 'export HOMEBREW_BREW_GIT_REMOTE=https://mirrors.sjtug.sjtu.edu.cn/git/brew.git' &gt;&gt; ~/.bash_profile
  echo 'export HOMEBREW_CORE_GIT_REMOTE=https://mirrors.sjtug.sjtu.edu.cn/git/homebrew-core.git' &gt;&gt; ~/.bash_profile
  echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirror.sjtu.edu.cn/homebrew-bottles/bottles' &gt;&gt; ~/.bash_profile
  echo 'export HOMEBREW_NO_INSTALL_FROM_API=1' &gt;&gt; ~/.bash_profile
  source ~/.bash_profile
  /bin/bash -c "$(curl -fsSL https://git.sjtu.edu.cn/sjtug/homebrew-install/-/raw/master/install.sh)"
  brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.sjtug.sjtu.edu.cn/git/homebrew-cask.git
\end{lstlisting}
ĺ¦‚ćžśćŻ Zsh ç”¨ć·, čŻ·ĺ°†ä¸Ščż°ć‰€ćś‰çš„ \texttt{.bash\_profile} ć›żćŤ˘ä¸ş \texttt{.zprofile}.

\subsubsection{ĺ®‰čŁ… Mac\TeX}

ĺ®‰čŁ… Homebrew ĺŽ,
ĺŹŞéś€ĺś¨\textsf{ç»ç«Ż}ć‰§čˇŚä»Ąä¸‹ĺ‘˝ä»¤ĺŤłĺŹŻĺ®Śćĺ®‰čŁ…:
\begin{lstlisting}[language=bash]
  brew install mactex
\end{lstlisting}
ĺ¦‚ćś‰čľ“ĺ…ĄĺŻ†ç&nbsp;ç­‰ćŹç¤ş, čŻ·ć&nbsp;ąćŤ®ĺ±Źĺą•ćŚ‡ç¤şć“Ťä˝ś.č‡łäşŽçŽŻĺ˘ĺŹé‡Źç­‰çąçç»†čŠ‚, Homebrew äĽšč‡ŞĺŠ¨čż›čˇŚĺ¤„ç†,
ć—&nbsp;éˇ»ç”¨ć·ĺą˛é˘„.

ĺ¦‚ćžśç”¨ć·ĺ®Śĺ…¨ä¸Ťéś€č¦ Mac\TeX{} é™„ĺ¸¦çš„ GUI ç»„ä»¶, äąźĺŹŻä»Ąč€č™‘ä»…ĺ®‰čŁ…ĺ…¶ĺ‘˝ä»¤čˇŚĺ·Ąĺ…·, é€ščż‡ĺś¨ç»ç«Żé”®ĺ…Ąĺ‘˝ä»¤ć–č€…ä»Žĺ…¶ä»–ć–‡ćś¬çĽ–čľ‘ĺ™¨č°ç”¨.
\begin{lstlisting}[language=bash]
  brew install mactex-no-gui
\end{lstlisting}

ĺ®Ść•´çš„ Mac\TeX{} äĽšćŻ”čľĺ¤§. ĺ¦‚ćžśçŁç›ç©şé—´ĺ®žĺś¨ç´§ĺĽ&nbsp;, äąźĺŹŻä»Ąč€č™‘ĺ®‰čŁ… Basic\TeX:
\begin{lstlisting}[language=bash]
  brew install basictex
\end{lstlisting}
ĺ®‰čŁ…ĺ®ŚćĺŽ Basic\TeX{} äľťç„¶äĽšçĽşĺľĺ¤šĺŚ…, ć‰‹ĺŠ¨ĺ®‰čŁ…äĽšćŻ”čľéş»ç¦, ć‰€ä»Ąä¸ŤćŽ¨čŤć˛ˇćś‰ç»ŹéŞŚçš„ç”¨ć·ĺ°ťčŻ•.

ćł¨ć„Ź, Basic\TeX{} çš„ĺťĺ§‹č®ľĺ®šćŻä¸Ťĺ®‰čŁ…ĺ®ŹĺŚ…ć–‡ćˇŁĺ’Śćşç&nbsp;. ĺ¦‚ćś‰éś€č¦, ĺŹŻä»Ąć‰§čˇŚ
\begin{lstlisting}[language=bash]
  # 1 ä¸şĺ®‰čŁ…, 0 ä¸şä¸Ťĺ®‰čŁ…
  sudo tlmgr option docfiles 1 # ĺ®‰čŁ…ć–‡ćˇŁ, ćŽ¨čŤ
  sudo tlmgr option srcfiles 1 # ĺ®‰čŁ…ćşç&nbsp;, ĺŹŻé€‰
\end{lstlisting}
é…Ťç˝® \texttt{tlmgr}. ĺś¨é…Ťç˝®äż®ć”ąć—¶ĺ·˛ç»Źĺ®‰čŁ…çš„ĺŚ…, éś€č¦é‡Ťć–°ĺ®‰čŁ…ć‰Ťč˝ĺş”ç”¨ć–°é…Ťç˝®, äľ‹ĺ¦‚ĺŹŻä»Ąć‰§čˇŚ
\begin{lstlisting}[language=bash]
  sudo tlmgr install --reinstall \
    $(tlmgr list --only-installed | sed -e 's/^i \([^:]*\): .*$/\1/')
\end{lstlisting}

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

ĺ¦‚ćžśç”¨ć·ç›´ćŽĄä¸‹č˝˝äş† Mac\TeX{} ĺ®‰čŁ…ĺŚ…čż›čˇŚĺ®‰čŁ…,
ĺŹŻä»ĄĺŻąç…§\href{https://www.tug.org/mactex/uninstalling.html}{čż™é‡Ś}çš„ä»‹ç»ŤćťĄĺŤ¸č˝˝,
é€šĺ¸¸ć‘ä¸ŞäşşäĽšćŻ”čľĺ»şč®®ĺś¨č·¨ç‰ćś¬ĺŤ‡çş§ĺ‰ŤĺŤ¸č˝˝ć—§ç‰ćś¬.

ĺ¦‚ćžśç”¨ć·ĺ€źĺŠ© Homebrew ĺ®‰čŁ…äş† Mac\TeX,
ç»Ź%
\href{https://github.com/OsbertWang/install-latex-guide-zh-cn/pull/39#discussion_r1368152254}{ĺ®žé™…ćµ‹čŻ•},
ç›´ćŽĄä˝żç”¨
\begin{lstlisting}
  brew uninstall mactex
\end{lstlisting}
ĺŤ¸č˝˝ĺľćĺŠź,
ĺŹŞćŻćś‰ä¸€äş›ć®‹ç•™.

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

ĺ¦‚ćžśç”¨ć·ç›´ćŽĄä¸‹č˝˝äş† Mac\TeX{} ĺ®‰čŁ…ĺŚ…čż›čˇŚĺ®‰čŁ…,
ĺŹŻä»Ąĺ…ĺŤ¸č˝˝ć—§ç‰ćś¬,
ĺ†Ťĺ®‰čŁ…ć–°ç‰ćś¬,
ć–č€…ĺą˛č„†äżťç•™ĺ¤šä¸Şç‰ćś¬,
ĺ…·ä˝“č§\href{https://www.tug.org/mactex/multipletexdistributions.html}{čż™é‡Ś}.

ĺ¦‚ćžśç”¨ć·ĺ€źĺŠ© Homebrew cask ĺ®‰čŁ…äş† Mac\TeX,
č·¨ç‰ćś¬ĺŤ‡çş§ (Mac\TeX{} çš„ç‰ćś¬ä¸Ž \TeX{} Live äżťćŚä¸€č‡´), ĺŹŻĺś¨\textsf{ç»ç«Ż}ĺ€źĺŠ© Homebrew ĺ®Ść:
\begin{lstlisting}[language=bash]
  brew update
  brew upgrade mactex
\end{lstlisting}

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

ĺŤ‡çş§ĺ®ŹĺŚ…äľťć—§ĺŹŻä»Ąä˝żç”¨ \texttt{tlmgr}.
ä˝żç”¨ć–ąćł•ä¸Ž \ref{sec:ubuntu:update}~čŠ‚ç±»äĽĽ, čż™é‡Śä¸Ťĺ†Ťé‡Ťĺ¤Ť.
ä¸€č¬ćťĄčŻ´, äąźéś€č¦ä˝żç”¨ \texttt{sudo} čŽ·ĺŹ–ç®ˇç†ĺ‘ćťé™ĺŽć‰Ťč˝ĺ®Śćĺ®‰čŁ….

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

ĺ®‰čŁ… CTAN ä¸­çš„ĺ®ŹĺŚ…ć–ąćł•ä¸Ž \ref{sec:ubuntu:installpackage}~čŠ‚ä¸€č‡´.

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

č°ĺ‡şĺ®ŹĺŚ…ć‰‹ĺ†Ść–ąćł•ä¸Ž \ref{sec:ubuntu:texdoc}~čŠ‚ä¸€č‡´.

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

ĺ‡č®ľĺ·˛ç»Źç”¨ TextEdit.app ć–ĺ…¶ä»–ć–‡ćś¬çĽ–čľ‘ĺ™¨çĽ–ĺ†™ä»Ąä¸‹ç¤şäľ‹ \texttt{main.tex}%
\footnote{ćł¨ć„Źĺ»şç«‹ćś€ĺ°Źç¤şäľ‹ĺ‰Ťĺ…çˇ®ĺ®šĺ·Ąä˝śč·Żĺľ„},
ĺ†…ĺ®ąä¸ş
\begin{lstlisting}[language = {[LaTeX]TeX}]
  \documentclass{article}
  \begin{document}
    Hello \LaTeX{} World!
  \end{document}
\end{lstlisting}
ćŽĄä¸‹ćťĄĺś¨\textsf{ç»ç«Ż}ä¸­ć‰§čˇŚ
\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]{ctexart}
  \begin{document}
    ä˝&nbsp;ĺĄ˝ \LaTeX{} ä¸–ç•ŚďĽ
  \end{document}
\end{lstlisting}
äżťĺ­ĺą¶é€€ĺ‡ş.
ćŽĄä¸‹ćťĄĺś¨\textsf{ç»ç«Ż}ä¸­čż›ĺ…Ąĺ·Ąä˝śč·Żĺľ„,
ć‰§čˇŚ
\begin{lstlisting}[language=bash]
  xelatex main
\end{lstlisting}
ç­‰ĺľ…çł»ç»źĺ®ŚćçĽ–čŻ‘čż‡ç¨‹.
\texttt{xelatex} ĺŹŻč°ç”¨çł»ç»źĺ­—ä˝“,
ä¸şçł»ç»źĺ®‰čŁ…ĺ­—ä˝“çš„ć–ąćł•čŻ·ĺŹ‚č€
\href{https://support.apple.com/en-us/HT201749}{How to install and remove fonts on your Mac}.
ĺ®‰čŁ…ĺ®ŚćĺŽ, ĺ·ć–°ĺ­—ä˝“çĽ“ĺ­.
ćł¨ć„Źĺ°ć­¤ć—¶ \texttt{xelatex} ĺŹŞč˝é€ščż‡ć–‡ä»¶ĺŤćťĄč°ç”¨ĺŹ‘čˇŚç‰é˘„čŁ…çš„ĺ­—ä˝“,
č§Łĺ†łć­¤é—®é˘çš„ć–ąćł•čŻ·ĺŹ‚č€%
\href{https://zhuanlan.zhihu.com/p/59774395}{ć…•ĺ­çš„ć–‡ç«&nbsp;}.

çĽ–čŻ‘ĺ‘˝ä»¤çš„ç›¸ĺ…łĺŹ‚ć•°, čż™é‡Śä¸Ťĺ†Ťčµčż°.
</pre></body></html>