我使用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}
答案 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/