source-code-listings.tex 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. \documentclass{beamer}
  2. \usepackage{accsupp}
  3. \usepackage{listings} % needed for the inclusion of source code
  4. \usepackage{color} % needed for syntax highlighting
  5. \definecolor{dkgreen}{rgb}{0,0.6,0}
  6. \definecolor{gray}{rgb}{0.5,0.5,0.5}
  7. \definecolor{mauve}{rgb}{0.58,0,0.82}
  8. % this style makes included Java code copyable
  9. \lstdefinestyle{demostyle}{
  10. language=Java,
  11. basicstyle=\small\ttfamily, % needed for "
  12. numbers=left,
  13. stepnumber=1,
  14. %frame=single,
  15. columns=flexible, % needed because of spaces
  16. keepspaces=true, % needed because of spaces
  17. numberstyle=\tiny\noncopynumber, % line numbers shouldn't be copied
  18. keywordstyle=\color{blue}, % keyword style
  19. commentstyle=\color{dkgreen}, % comment style
  20. stringstyle=\color{mauve}, % string literal style
  21. escapeinside={\%*}{*)}, % if you want to add a comment within your code
  22. morekeywords={*,...} % if you want to add more keywords to the set
  23. }
  24. \newcommand{\noncopynumber}[1]{%
  25. \BeginAccSupp{method=escape,ActualText={}}%
  26. #1%
  27. \EndAccSupp{}%
  28. }
  29. \makeatletter
  30. \def\lst@outputspace{{\ifx\lst@bkgcolor\empty\color{white}\else\lst@bkgcolor\fi\lst@visiblespace}}
  31. \makeatother
  32. \begin{document}
  33. \section{Section}
  34. \subsection{MySubSection}
  35. \begin{frame}{Blubtitle}
  36. \lstinputlisting[style=demostyle]{IataCode.java}
  37. \end{frame}
  38. \end{document}