2010-01-12 24 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节。