仅针对某些浮点数更改 \abovecaptionskip

仅针对某些浮点数更改 \abovecaptionskip

我只想更改包\abovecaptionskip的列表浮点数(图形和标题之间的空间)minted

我怎样才能做到这一点?

答案1

使用包caption及其\captionsetup。因为listing它必须位于组内才能保持本地状态,或者使用新环境mylisting。对于默认figure环境,它可以位于内部,然后默认为本地

\documentclass{article}

\usepackage{minted}
\usepackage{caption}
\newenvironment{mylisting}[1][H]
  {\captionsetup{aboveskip=-0.2\normalbaselineskip}\begin{listing}[#1]}
  {\end{listing}}
\begin{document}

\bgroup
\captionsetup{aboveskip=-0.2\normalbaselineskip}
\begin{listing}[H]
\begin{minted}{c}
for i:=maxint to 0 do
begin
  { do nothing }
end;
\end{minted}
\caption{Example of a listing.}\label{lst:example}
\end{listing}
\egroup

\begin{mylisting}[H]
\begin{minted}{c}
for i:=maxint to 0 do
begin
  { do nothing }
end;
\end{minted}
\caption{Example of a listing.}\label{lst:example}
\end{mylisting}

\begin{figure}[!ht]
\captionsetup{aboveskip=60pt}
\centering
\rule{1cm}{1cm}% placeholder
\caption{A figure}
\end{figure}

\end{document}

相关内容