Is there an option to break line in an lstlisting's caption? For example:

\begin{lstlisting}[frame=single, caption=uppertext\\lowertext)]

I've tried with \\ and some other solutions, but any of them works.


You can set the caption using a tabular. However, also set the optional caption (for the \lstlistoflistings) without the line-breaking tabular:

enter image description here





    frame = single, 
    caption = {[upper/lower text]%
                 upper text \\
                 lower text \\[.5\normalbaselineskip]
Hello world


Due to the frame, some vertical adjustment is needed (in the form of \\[.5\normalbaselineskip]).

| improve this answer | |

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.