2

I load some code to my document like this: \lstinputlisting{MergeSort.txt}. This works perfectly, however I would like to add a caption in footnotesize to the bottom of the source code (without any tag like 'Listing 1:'). How can I do this?

0

1 Answer 1

4

Use the title key-value option for listings:

enter image description here

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{MergeSort.txt}
This is a merge sort algorithm
\end{filecontents*}

\usepackage{listings}
\lstset{basicstyle=\ttfamily}

\begin{document}

\lstinputlisting[captionpos=b,title={\footnotesize Merge Sort}]{MergeSort.txt}

\end{document}

title positioning is adjusted using captionpos.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .