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

Pad*_*die 27 syntax latex pygments

我使用Pygments了很多东西,我也想在乳胶报告中使用它.我找到了Minted与Pygments交互的包,但是一些注释和一些代码溢出了正确的边缘.我breaklines=true过去曾使用过lstlistings ,但是我没有看到使用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}
Run Code Online (Sandbox Code Playgroud)

Kon*_*lph 20

不幸的是,目前还没有解决方案minted,或者在可预见的未来,抱歉.实现该breaklines功能非常困难.listings相反,使用可能是您最好的解决方案.

现在有一个breaklines选项.

  • @Raubi我不再是"铸造"的维护者,因为我缺乏时间和LaTeX技能.它目前由[Geoffrey Poore]开发(https://github.com/gpoore/minted).他**意图实现此功能,但我不知道时间表.[有一个解决方案,但是](http://tex.stackexchange.com/a/112573/42),但它需要一些摆弄. (3认同)
  • `breaklines`现在实施了. (3认同)

jol*_*son 12

如果您给它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}
Run Code Online (Sandbox Code Playgroud)

还有各种相关选项来控制如何在输出中指示换行符的存在.参见铸造文档中的第6.3节.