\documentclass{article} \usepackage{xcolor} \usepackage{listings} \definecolor{darkgreen}{cmyk}{.61,0,.61,.18} % Look in the documentation of the listings package for more options \lstset{ language=matlab, basicstyle=\ttfamily, caption=\lstname, % Uses the filename as the caption backgroundcolor=\color[rgb]{0.9,0.9,0.9}, frame=lines, keywordstyle=\color{blue}, % blue is a built-in color t commentstyle=\color{darkgreen}, % darkgreen is a color I defined above numbers=left, breaklines=true} \title{name of the assignment} \author{your name here} \begin{document} \maketitle Here is some code that was saved in an external file. This is perfect if you are still working on the code and always want to show the most recent code in your \LaTeX{} file. \lstinputlisting{matlabsample.m} \end{document}