4

Obviously, the caption is not beautifully placed; it needs more space between the caption text and the frame/listing itself.

How can I do that?

I am using the IEEEtran document class and the package listings, if this is important. The related code is

\documentclass[10pt, conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{listings}
\begin{document}
\lstset{basicstyle=\normalsize\ttfamily, breaklines=true, xleftmargin=2em, frame=single, framexleftmargin=15pt} 
\begin{lstlisting}[caption={Search-based change access}, label={lst:query}]
<url>/changes/?q=change:<change_id>&o=LABELS&o=DETAILED_LABELS&o=DETAILED_ACCOUNTS&o=REVIEWER_UPDATES&o=MESSAGES
\end{lstlisting}    
\end{document}

enter image description here

  • Sure, documentclass is important. How is the listing appearing there? Magic? Which package are you using? Do you use it properly? A minimal working example would be needed to tell. – Johannes_B Jan 12 at 17:59
  • Sorry, my bad. I added a minimal example. – Michael Dorner Jan 12 at 18:02
  • Usually takes people about half an hour to post a minimal working example. I guess usually they take the time to read what it is and then try to create it. Sorry. – Johannes_B Jan 12 at 18:03
  • Is this not sufficient? – Michael Dorner Jan 12 at 18:04
  • Sorry, i have seen just three lines there. Should be ok. – Johannes_B Jan 12 at 18:06
5

The caption package cooperates with listings:

\documentclass[10pt, conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{listings}
\usepackage{caption}

\begin{document}

\lstset{basicstyle=\normalsize\ttfamily, breaklines=true, xleftmargin=2em, frame=single, framexleftmargin=15pt, belowcaptionskip=8pt}
\begin{lstlisting}[caption={Search-based change access}, label={lst:query}]
<url>/changes/?q=change:<change_id>&o=LABELS&o=DETAILED_LABELS&o=DETAILED_ACCOUNTS&o=REVIEWER_UPDATES&o=MESSAGES
\end{lstlisting}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.