在内部 minted 环境中,最后一行代码和框架规则之间存在 vspace。如何去除它?与 相比framed
,framed 在代码和底部规则之间没有空格。
以下是 MWE:
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}[linenos=false,numberblanklines=true,showspaces=false,breaklines=true,frame=lines,framesep=8pt,framerule=0.3pt]{java}
globalMemStoreLimitLowMarkPercent * globalMemStoreSize
\end{minted}
\begin{minted}[linenos=false,numberblanklines=true,showspaces=false,breaklines=true,frame=lines,framesep=0pt,framerule=0.3pt]{java}
globalMemStoreLimitLowMarkPercent * globalMemStoreSize
\end{minted}
\FrameSep=0em
\begin{framed}
globalMemStoreLimitLowMarkPercent * globalMemStoreSize
\end{framed}
\end{document}
答案1
谢谢@Tom的建议。我尝试将tcolorbox
和结合起来minted
,现在我的问题已经解决了。这是我的MWE:
\documentclass{book}
\usepackage[chapter]{minted}
\usepackage{tcolorbox}
\usepackage{lipsum}
\tcbuselibrary{listings,minted,skins,breakable}
\AtBeginDocument{%
% args: options, language, caption, label, codes block
\newtcblisting[blend into=listings,list type=lstlisting]{mlisting}[4][]{
enhanced,
listing engine=minted,
minted style=manni,
minted language=#2,
minted options={frame=none,fontsize=\small,
linenos=true,numberblanklines=false,numbersep=5pt,
baselinestretch=1.2,breaklines,breakanywhere,autogobble,mathescape,#1},
listing only,
listing remove caption=false,
size=title,breakable,
frame hidden,boxrule=0pt,
arc=0pt,outer arc=0pt,
boxsep=0pt,before skip=10pt,after skip=10pt,
top=2pt,bottom=2pt,left=10pt,right=10pt,
colback=yellow!5,
overlay={\begin{tcbclipinterior}
\path[draw=black!90,line width=0.4pt,line cap=round]
(interior.north west)--(interior.north east)
(interior.south west)--(interior.south east);
\end{tcbclipinterior}},
coltitle=black,
attach boxed title to top center={yshift=2pt},
boxed title style={empty,size=minimal,colback=white},
fonttitle=\small,
title={#3}, label={#4}
}
}
\begin{document}
\lstlistoflistings
\clearpage
\chapter{Listing test}
\begin{mlisting}[]{java}{Java example}{lst:lst1}
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
\end{mlisting}
\lipsum[1]
\begin{mlisting}[linenos=false]{python}{python example}{lst:lst2}
def _merge():
while left and right:
yield (left if left[0] <= right[0] else right).pop(0)
yield from left
yield from right
return list(_merge())
\end{mlisting}
\begin{mlisting}[]{java}{Java example}{lst:lst3}
// some code here.
\end{mlisting}
\end{document}