林使用了很多的东西Pygments,我想在我的乳胶报告中也用这个。我发现它与Pygments来做交互的包Minted,但一些评论和一些代码的溢出右边缘。我已经使用lstlistings'在过去breaklines=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}
有帮助吗?

解决方案

遗憾的是,在目前或在可预见的未来,对不起minted内无解。实施breaklines功能是相当困难的。使用listings反而可能是这里的最佳解决方案。

铸造现在有一个breaklines选项。

其他提示

铸造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}

此外,还有各种相关的选项,以控制如何换行符的存在下,在输出表示。见6.3节所述铸造文档中

您应该看一看texments,因为它是在LaTeX中使用Pygments来做荧光笔。 http://www.ctan.org/tex-archive/macros /胶乳/了contrib / texments /

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top