36

我用它Pygments做很多事情,我也想在我的乳胶报告中使用它。我找到了Minted与 Pygments 交互的包,但是一些注释和一些代码溢出了右边距。我过去使用过 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}
4

3 回答 3

36

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

Minted 现在有一个breaklines选项。

于 2010-01-31T11:33:50.530 回答
18

breaklines如果您给它选项,Minted 2.0(刚刚发布)会换行:

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

于 2015-02-10T01:14:40.207 回答
2

您应该看看texments在 LaTeX 中使用 Pygments 荧光笔的原样。 http://www.ctan.org/tex-archive/macros/latex/contrib/texments/

于 2010-01-12T20:04:00.463 回答