Easy way to include code in your latex document and have the syntax coloured correctly
\usepackage{color}
\usepackage{listings}
\lstset{
tabsize=4,
language=matlab,
basicstyle=\scriptsize,
%upquote=true,
aboveskip={1.5\baselineskip},
columns=fixed,
showstringspaces=false,
extendedchars=true,
breaklines=true,
prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
frame=single,
showtabs=false,
showspaces=false,
showstringspaces=false,
identifierstyle=\ttfamily,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.133,0.545,0.133},
stringstyle=\color[rgb]{0.627,0.126,0.941},
language=Java
}
\begin{document}
\lstinputlisting[title=\textbf{Source Code: filename.java}]{filename.java}
\end{document}
very helpful, thanks!
Thank you. Isn’t it strange, though, that there are no default colored modes for any language?