그림 안에 줄 바꿈을 나열할 때 캡션의 추가 공백을 어떻게 제거할 수 있나요?

그림 안에 줄 바꿈을 나열할 때 캡션의 추가 공백을 어떻게 제거할 수 있나요?

listing나는 그림 안에 감싸고 싶다 . 하지만 그렇게 하면 캡션 사이에 공백이 많이 생깁니다. 그림 안에 줄바꿈을 나열할 때 그림 캡션의 추가 공백을 어떻게 제거할 수 있습니까?

다음 코드가 있습니다.기원:

\expandafter\def\csname [email protected]\endcsname{}
\documentclass[10pt,journal,compsoc]{IEEEtran}
\PassOptionsToPackage{table}{xcolor}
\ifCLASSOPTIONcompsoc\usepackage[nocompress]{cite}
\else
    \usepackage{cite}
\fi
\ifCLASSINFOpdf\else\fi
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage[english]{babel}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{listings, xcolor}

\begin{document}
\section{Introduction}
hello world hello world hello world hello world
\begin{figure}[htp]
        \lstinputlisting[frame=tlrb, rulecolor=\color{black}]{hello.sol}
        \caption{hello world.}
\end{figure}
hello world hello world hello world hello world
\end{document}

hello.sol:

function hello() public returns (bool) {
    uint256 amount = 100
    return amount * 100
    return true;
}

산출:

여기에 이미지 설명을 입력하세요

여기에서 캡션의 글꼴이 더 작고 캡션의 위쪽과 아래쪽에 공백이 많이 생성된 것을 볼 수 있습니다. 그것들을 제거하는 것이 가능합니까?

내부에 캡션이 있으면 캡션 으로 listing대체할 수 있으면 나에게도 효과적입니다.ListingFigure

답변1

MWE는 외부 파일에 의존해서는 안 됩니다. 가능하다면 복사하여 붙여넣을 수 있는 독립형 코드를 제공해 주세요.

그러나 가능한 해결책은 listings그림에 의존하는 대신 의 캡션 기능을 사용하는 것입니다. figure환경과 명령을 제거한 \caption후 다음을 수행하십시오.

\lstinputlisting[caption={hello world.}, captionpos=b, frame=tlrb, rulecolor=\color{black}]{hello.sol}

관련 정보