2010-01-12 23 views
21

我使用Pygments做了很多事情,我也想在我的乳膠報告中使用它。我發現與Pygments交互的包Minted,但一些註釋和一些代碼溢出了右邊距。過去我使用過lstlistings'breaklines=true,但是我沒有看到使用Minted軟件包獲得該功能的方法,有什麼想法?乳膠:使用鑄造包裝 - 我如何使它包裝文本(linebreaks = true)


\documentclass[10pt]{article} 
\usepackage{fancyvrb} 
\usepackage{minted} 

\begin{document} 
\begin{minted}[mathescape, 
linenos, 
numbersep=5pt, 
frame=single, 
numbersep=5pt, 
xleftmargin=0, 
]{python} 
class Run(BaseModel): 
""" 
Run: unique Tool and multiple Inputs 
Status: 
    Running => jobs are pending or runing and not all jobs have been completed 
    Paused => workers querying for 'Running' Runs won't get this Run until we change status again 
    Done => all jobs have completed and have a result_status = 'Done' 
    Incomplete => No results (inputs) have been associated with the Run 
""" 
name = models.CharField(max_length = 150, 
    unique=True) 
tool = models.ForeignKey('Tool') 
tags = models.ManyToManyField(RunTag, related_name="model_set") 
\end{minted} 
\end{document} 

回答

17

不幸的是,在目前或在可預見的將來,minted目前沒有解決方案,對不起。實現breaklines功能相當困難。使用listings取而代之可能是您的最佳解決方案。

鑄造現在有breaklines選項。

+0

謝謝您的明確答案康拉德。 儘管如此,我對所製作的結果非常滿意,因此我不必再仔細檢查輸出結果。 – Paddie

+1

您目前是否有任何活動在minted中實施'breaklines'功能? – eckes

+1

我只想重複@eckes問題 –

9

鑄造2.0(剛剛發佈)做行,如果你給它breaklines選項打破:

\documentclass[10pt]{article} 
\usepackage{fancyvrb} 
\usepackage{minted} 

\begin{document} 
\begin{minted}[% 
breaklines, 
mathescape, 
linenos, 
numbersep=5pt, 
frame=single, 
numbersep=5pt, 
xleftmargin=0pt, 
]{python} 
class Run(BaseModel): 
"'' 
Run: unique Tool and multiple Inputs 
Status: 
    Running => jobs are pending or runing and not all jobs have been completed 
    Paused => workers querying for 'Running' Runs won't get this Run until we change status again 
    Done => all jobs have completed and have a result_status = 'Done' 
    Incomplete => No results (inputs) have been associated with the Run 
"'' 
name = models.CharField(max_length = 150, 
    unique=True) 
tool = models.ForeignKey('Tool') 
tags = models.ManyToManyField(RunTag, related_name=''model_set'') 
\end{minted} 
\end{document} 

也有各種相關的選項來控制如何換行的情況下輸出指示。請參閱minted文檔中的第6.3節。