46

When I use a simple caption, tex puts it above the listing

\begin{lstlisting}[caption={My Caption}]
\end{lstlisting}

enter image description here

If I use \captionof, caption goes below the listing, but paragraph for next line doesn't work.

\begin{lstlisting}
Listing example
\end{lstlisting}
\captionof{lstlisting}{My caption}

Next line, Next line, Next line, Next line.

enter image description here

As you see, there is not a paragraph.

  • 1
    listings has an option to change the position of the caption. Look in the documentation, sec 5.7 Captions. – Ulrike Fischer Apr 10 '16 at 12:20
  • Can you send me the link? – Rostislav Shtanko Apr 10 '16 at 12:24
  • Use texdoc listings, or search in the doc-folder of your texsystem. – Ulrike Fischer Apr 10 '16 at 12:30
  • 4
    I'm voting to close this question as off-topic because the topic could be solved by comments (and the O.P. was able to find it too) – user31729 Apr 20 '16 at 21:52
  • 5
    @ChristianHupfer how is this off-topic? self answering questions is absolutely encouraged, and this is a valid question. Only problem is that the answer is edited in instead of being posted as answer... – TheFlow0360 Jul 5 '17 at 12:58
52

[Answer from OP, originally edited into question]

I found a solution.

\begin{lstlisting}[caption={My Caption},captionpos=b]

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.