Posted By

jonathanbp on 01/25/10


Tagged

textmate java code LaTeX


Versions (?)

latex source code formatting


 / Published in: LaTeX
 

  1. \title{Nice Code}
  2. \author{Jonathan Bunde-Pedersen}
  3.  
  4. \documentclass[12pt]{article}
  5.  
  6. \usepackage{color}
  7. \usepackage{fancyvrb}
  8. \usepackage{listings}
  9.  
  10. % include the lines below to use a nicer fixed-width font than the default one
  11. \usepackage{fontspec}
  12. \setmonofont[Scale=0.8]{Consolas}
  13.  
  14. \lstset{fancyvrb=true}
  15. \lstset{
  16. basicstyle=\small\tt,
  17. keywordstyle=\color{blue},
  18. identifierstyle=,
  19. commentstyle=\color{green},
  20. stringstyle=\color{red},
  21. showstringspaces=false,
  22. tabsize=3,
  23. numbers=left,
  24. captionpos=b,
  25. numberstyle=\tiny
  26. %stepnumber=4
  27. }
  28.  
  29. \begin{document}
  30. \maketitle
  31.  
  32. \section{Some nice Java code}
  33.  
  34. \begin{figure}[h]
  35. \lstset{language=java,caption=Nicely formatted code.,label=lst:nicecode}
  36. \begin{lstlisting}
  37. public class Whatever {
  38. public static void main(String[] args) {
  39. // whatever
  40. System.out.println("Hello, world!");
  41. }
  42. }
  43. \end{lstlisting}
  44. \end{figure}
  45.  
  46.  
  47. \end{document}

Report this snippet  

You need to login to post a comment.