
我正在嘗試讓 minted 套件在 macOS 上使用簡單的範例程式碼 (java):
\documentclass{article}
\usepackage{minted}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{minted}[frame=single,linenos,mathescape]{java}
public class Fibonacci {
// The golden ratio $\phi = \frac{1 + \sqrt{5}}{2}$.
public static final double PHI = (1.0 + Math.sqrt(5.0)) / 2.0;
public static double fibonacci(long n) {
if (n < 0) throw new IllegalArgumentException();
return Math.floor(Math.pow(PHI, n) / Math.sqrt(5.0) + 0.5);
}
}
\end{minted}
\end{document}
我正在使用帶有標準 LaTeX 編譯器的 TexShop。我的輸出看起來很奇怪並且根本沒有突出顯示。添加了一些奇怪的字符,當從終端使用它時,我也在 pygmentize 輸出 .tex 檔案中的 \PY 命令中獲得這些字符。使用直接使用 pygmentize 建立的 .tex 檔案提供與在 Latex 中使用 minted 相同的輸出。
我究竟做錯了什麼? 5個月前它運作良好。