![如何在 MikTeX 和 Windows 7 下使用 minted?](https://rvso.com/image/266431/%E5%A6%82%E4%BD%95%E5%9C%A8%20MikTeX%20%E5%92%8C%20Windows%207%20%E4%B8%8B%E4%BD%BF%E7%94%A8%20minted%EF%BC%9F.png)
根據minted
文件:
Windows 支援目前還很粗略/未經測試。有兩個複雜之處:安裝和使用......
這個問題尋求一步一步的闡述
如何minted
在 Windows 下設定使用 MikTeX?
答案1
minted
使用Pythonpygments
庫,所以你需要:
- 安裝
Python
,選擇你喜歡的版本:x64
或者x86
,最好選擇2.7.5
版本。 Python
添加PATH
:- 按住Win並按下Pause。
- 點選
Advanced System Settings
。 - 點選
Environment Variables
。 - 附加
;C:\Python27
到PATH
變數。
- 安裝
python-pip
。 - 加到
;C:\Python27\Scripts
變數PATH
。 pip install pygments
安裝Pygments
(如果您已安裝,則應指定Perl
完整路徑,因為還有一個同名的二進位)。pip
Perl
啟用
-shell-escape
選項進行編譯:\documentclass{article} \usepackage{minted} \begin{document} \begin{minted}[mathescape, linenos, numbersep=5pt, gobble=2, frame=lines, framesep=2mm]{csharp} string title = "This is a Unicode π in the sky" /* Defined as $\pi=\lim_{n\to\infty}\frac{P_n}{d}$ where $P$ is the perimeter of an $n$-sided regular polygon circumscribing a circle of diameter $d$. */ const double pi = 3.1415926535 \end{minted} \end{document}
結果應該如下圖所示:
答案2
安裝Python對於窗戶。然後安裝設定工具。這應該在您的目錄資料夾中添加easy_install.exe
檔案(例如: 在我的電腦中。對您來說可能會有所不同。)Scripts
python
C:\Python26\Scripts\
C:\Python26\Scripts
使用使用者變數新增至您的系統路徑。您可能希望使用使用者友好的編輯器:路徑編輯器以此目的。
現在打開互聯網,轉到命令提示字元並輸入easy_install pygments
。
現在您可能需要重新啟動電腦。就這樣吧。嘗試這個測試檔案:
\documentclass{article}
\usepackage{amsmath}
\usepackage{minted} % loads fancyvrb
\newenvironment{eqnexample}
{\VerbatimOut{\jobname.tmp}}
{\endVerbatimOut
\inputminted{latex}{\jobname.tmp}
\input{\jobname.tmp}}
\begin{document}
\begin{eqnexample}
\begin{align}
d &= \sqrt{ (x'-x)^2 }
\\
e &= 0
\end{align}
\end{eqnexample}
\begin{eqnexample}
\begin{multline}
d = \sqrt{ (x'-x)^2 } \\
= f(x,x')
\end{multline}
\end{eqnexample}
\end{document}