2

Minted用來增添美感代碼在乳膠,像:崇高文本構建乳膠,問題與鑄造包

\documentclass{article} 
\usepackage{minted} 
\begin{document} 
\begin{minted}{c} 
int main() { 
    printf("hello, world"); 
    return 0; 
} 
\end{minted} 
\end{document} 

我已經安裝了它,如果我打電話,在命令行正常工作:

pdflatex -shell-escape minimal.tex 

但是我用崇高的文本構建系統,使PDF,這裏是構建腳本:

{ 
    "cmd": ["/Library/TeX/texbin/pdflatex","-shell-escape","$file"], 
    "selector": "text.tex.latex" 
} 

由於某些原因,當我點擊Ctrl+B時,它不能像終端中那樣工作。在輸出面板中,我看到:

This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex) 
\write18 enabled. 
entering extended mode 
(/Users/user/Downloads/minted/minimal.tex 
LaTeX2e <2016/03/31> 
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded. 
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls 
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class 
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size10.clo)) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/minted/minted.sty 
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/oberdiek/kvoptions.sty 
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty) 
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty 
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty) 
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/etexcmds.sty 
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ifluatex.sty)))) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty 
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix 
<2008/02/07> (tvz)) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/float/float.sty) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/ifthen.sty) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/tools/calc.sty) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/ifplatform/ifplatform.sty 
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty 
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ifpdf.sty)) 
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/catchfile.sty) 
(./minimal.w18)) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/etoolbox/etoolbox.sty) 
(/usr/local/texlive/2016/texmf-dist/tex/generic/xstring/xstring.sty 
(/usr/local/texlive/2016/texmf-dist/tex/generic/xstring/xstring.tex)) 
(/usr/local/texlive/2016/texmf-dist/tex/latex/lineno/lineno.sty)) 
(./_minted-minimal/default.pygstyle)system returned with code 256 


! Package minted Error: You must have `pygmentize' installed to use this packag 
e. 

See the minted package documentation for explanation. 
Type H <return> for immediate help. 
...            

l.3 \begin{document} 

? 

爲什麼pygmentize未通過Sublime Text找到?

回答

2

就像我喜歡OS X一樣 - 這整個路徑的故事只是一個痛苦,至少對我來說,似乎它在每個主要版本中都會再次發生變化。現在,在啓動Sublime Text時,它繼承$PATH變量(它基本上告訴Sublime Text它應該從launchctl工具中尋找外部程序,如pdflatexpygmentize) - 而不是從shell。因此,即使在shell中一切正常工作,它也不會從Sublime Text(或大多數其他編輯器)工作。

您可以嘗試自己修復此問題,如this question on AskDifferent.SE中所述。這具有「修復」所有應用程序的路徑的優點,即使您切換到另一個編輯器。要做到這一點,你必須添加以下到您.bash_profile

export PATH=some_path:another_path 
launchctl setenv PATH $PATH 

this answer

注意到已經採取,你可能不會需要的第一線,如果一切都在工作終奌站。設置所有路徑後,請確保撥打launchctl

另一種可能性,如果您更喜歡Sublime Text方式,則使用SublimeFixMacPath plugin作爲Sublime Text 2或3,它將添加從shell到Sublime Text路徑的所有路徑。這樣,任何在shell中工作的東西也可以在Sublime Text中使用。