minted:在浮动环境中删除标题和框架之间的空格

minted:在浮动环境中删除标题和框架之间的空格

我正在使用在浮动环境中排版代码列表的minted选项newfloat。不幸的是,在这种情况下,标题与源代码区域的距离很大:

\begin{listing}
\caption{This is a test}
\label{lst:motivation:test}
\begin{minted}[linenos=true,frame=lines]{python}
from time import localtime

activities = {8: 'Sleeping',
              9: 'Commuting',
              17: 'Working',
              18: 'Commuting',
              20: 'Eating',
              22: 'Resting' }

time_now = localtime()
hour = time_now.tm_hour

for activity_time in sorted(activities.keys()):
    if hour < activity_time:
        print activities[activity_time]
        break
else:
    print 'UNKNOWN, AFK OR SLEEPING!'
\end{minted}
\end{listing}

This is a test for \autoref{lst:motivation:test} auto references.

结果是:

空间太大

我怀疑框架周围与环境之间有空隙,minted但我找不到控制它的选项。我发现的唯一可行的办法是在标题中添加负空间,但听起来很难看:

\captionsetup[listing]{position=above,skip=-10pt}

相关内容