Latex:使用 Minted 包 - 如何让它包裹文本(linebreaks=true)
我使用 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}
Im using the Pygments
for a lot of things, and I'd like to also use this in my latex report. I found the package Minted
which interacts with Pygments, but some of the comments and some of the code overflows the right margin. I have used lstlistings' breaklines=true
in the past, but I don't see a way to get that functionality using the Minted package, any ideas?
\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}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不幸的是,目前或在可预见的将来,minted
内没有解决方案,抱歉。实现断线功能相当困难。使用listings
可能是您最好的解决方案。Minted 现在有一个
breaklines
选项。Unfortunately, there’s no solution withinminted
at the moment or for the foreseeable future, sorry. Implementing thebreaklines
feature is quite difficult. Usinglistings
instead may be your best solution here.Minted now has a
breaklines
option.如果您给 Minted 2.0(刚刚发布)提供
breaklines
选项,它就会进行换行:还有各种相关选项来控制如何在输出中指示换行符的存在。请参阅 minted 文档中的第 6.3 节。
Minted 2.0 (just released) does line breaking if you give it the
breaklines
option:There are also various related options to control how the presence of a line break is indicated in the output. See section 6.3 in the minted documentation.
你应该看看
texments
,因为它是在 LaTeX 中使用 Pygments 荧光笔的。http://www.ctan.org/tex-archive/macros /latex/contrib/texments/
You should have a look at
texments
as it is for using the Pygments highlighter in LaTeX.http://www.ctan.org/tex-archive/macros/latex/contrib/texments/