مطاط:استخدام الحزمة Minted - كيف أجعلها تلتف حول النص (فواصل الأسطر = صحيح)
سؤال
أنا أستخدم 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}
المحلول
لسوء الحظ، لا يوجد حل في الداخل minted
في الوقت الراهن أو في المستقبل المنظور، آسف.تنفيذ breaklines
الميزة صعبة للغاية.استخدام listings
بدلا من ذلك قد يكون الحل الأفضل هنا.
النعناع لديه الآن breaklines
خيار.
نصائح أخرى
يقوم 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}
هناك أيضًا العديد من الخيارات ذات الصلة للتحكم في كيفية الإشارة إلى وجود فاصل أسطر في الإخراج.انظر القسم 6.3 في سكت توثيق.
يجب عليك إلقاء نظرة على texments
كما هو الحال بالنسبة لاستخدام أداة تمييز Pygments في LaTeX.http://www.ctan.org/tex-archive/macros/latex/contrib/texments/