Latex:使用Minted包 - 如何使其包装文本(linebreaks = true)

时间:2010-01-12 18:33:12

标签: syntax latex pygments

我使用Pygments做了很多事情,我也想在乳胶报告中使用它。我找到了与Pygments交互的包Minted,但是一些注释和一些代码溢出了正确的边缘。我过去曾使用过lstlistings breaklines=true,但是我没有看到使用Minted包获得该功能的方法,任何想法?


\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}

3 个答案:

答案 0 :(得分:19)

不幸的是,目前minted内或可预见的未来都没有解决方案,抱歉。实施breaklines功能非常困难。在这里使用listings可能是您最好的解决方案。

现在有一个breaklines选项。

答案 1 :(得分:11)

Minted 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节。

答案 2 :(得分:2)

你应该看一下texments,就像在LaTeX中使用Pygments荧光笔一样。 http://www.ctan.org/tex-archive/macros/latex/contrib/texments/