/ Published in: LaTeX
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
\author{Jonathan Bunde-Pedersen} \documentclass[12pt]{article} \usepackage{color} \usepackage{fancyvrb} \usepackage{listings} % include the lines below to use a nicer fixed-width font than the default one \setmonofont[Scale=0.8]{Consolas} \lstset{fancyvrb=true} \lstset{ basicstyle=\small\tt, keywordstyle=\color{blue}, identifierstyle=, commentstyle=\color{green}, stringstyle=\color{red}, showstringspaces=false, tabsize=3, numbers=left, captionpos=b, numberstyle=\tiny %stepnumber=4 } \begin{document} \section{Some nice Java code} \begin{figure}[h] \lstset{language=java,caption=Nicely formatted code.,label=lst:nicecode} \begin{lstlisting} public class Whatever { public static void main(String[] args) { // whatever System.out.println("Hello, world!"); } } \end{lstlisting} \end{figure} \end{document}