\documentclass{article}

\usepackage{listings}
\lstset{
  frame=single,
  basicstyle=\small\ttfamily,
  showstringspaces=false
}

\pagestyle{empty}

\begin{document}

\lstset{language=TeX}
\lstinputlisting[
  caption={Source for this \LaTeX{} file\label{lst:example}}
]{listings-example.tex}

\end{document}
