From 3e1dba9d8b37a44fb6139fe2c0d23ac8a5dd3c0b Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 18 Nov 2012 14:04:10 +0100 Subject: [PATCH] added source code examples --- documents/source-code-listings/IataCode.java | 18 ++++++++ documents/source-code-listings/Makefile | 10 +++++ .../source-code-listings.tex | 43 +++++++++++++++++++ documents/source-code-minted/IataCode.java | 18 ++++++++ documents/source-code-minted/Makefile | 10 +++++ .../minted-code-inclusion.tex | 13 ++++++ 6 files changed, 112 insertions(+) create mode 100644 documents/source-code-listings/IataCode.java create mode 100644 documents/source-code-listings/Makefile create mode 100644 documents/source-code-listings/source-code-listings.tex create mode 100644 documents/source-code-minted/IataCode.java create mode 100644 documents/source-code-minted/Makefile create mode 100644 documents/source-code-minted/minted-code-inclusion.tex diff --git a/documents/source-code-listings/IataCode.java b/documents/source-code-listings/IataCode.java new file mode 100644 index 0000000..7531cc1 --- /dev/null +++ b/documents/source-code-listings/IataCode.java @@ -0,0 +1,18 @@ +public class IataCode { + public static void printIATACodes(String[] myArray) { + for (int i = 0; i < myArray.length; i++) { + System.out.println(myArray[i]); + } + } + + public static void main(String[] args) { + String[] iataCodes = new String[4]; + // Flughafen Munchen + iataCodes[0] = "MUC"; + // Flughafen Berlin Brandenburg + iataCodes[1] = "BER"; + // Flughafen Augsburg + iataCodes[2] = "AGB"; + printIATACodes(iataCodes); + } +} diff --git a/documents/source-code-listings/Makefile b/documents/source-code-listings/Makefile new file mode 100644 index 0000000..6d8119b --- /dev/null +++ b/documents/source-code-listings/Makefile @@ -0,0 +1,10 @@ +SOURCE = source-code-listings + +make: + #latexmk -pdf -pdflatex="pdflatex -interactive=nonstopmode" -use-make $(SOURCE).tex + pdflatex -shell-escape $(SOURCE).tex -output-format=pdf #shellescape wird fürs logo benötigt + pdflatex -shell-escape $(SOURCE).tex -output-format=pdf # nochmaliges ausführen wegen Inhaltsverzeichnissen + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.out *.glo *.glg *.gls *.ist *.xdy *.1 *.toc *.snm *.nav *.vrb *.fls *.fdb_latexmk *.pyg diff --git a/documents/source-code-listings/source-code-listings.tex b/documents/source-code-listings/source-code-listings.tex new file mode 100644 index 0000000..709733c --- /dev/null +++ b/documents/source-code-listings/source-code-listings.tex @@ -0,0 +1,43 @@ +\documentclass{beamer} +\usepackage{accsupp} +\usepackage{listings} % needed for the inclusion of source code +\usepackage{color} % needed for syntax highlighting + +\definecolor{dkgreen}{rgb}{0,0.6,0} +\definecolor{gray}{rgb}{0.5,0.5,0.5} +\definecolor{mauve}{rgb}{0.58,0,0.82} + +% this style makes included Java code copyable +\lstdefinestyle{demostyle}{ + language=Java, + basicstyle=\small\ttfamily, % needed for " + numbers=left, + stepnumber=1, + %frame=single, + columns=flexible, % needed because of spaces + keepspaces=true, % needed because of spaces + numberstyle=\tiny\noncopynumber, % line numbers shouldn't be copied + keywordstyle=\color{blue}, % keyword style + commentstyle=\color{dkgreen}, % comment style + stringstyle=\color{mauve}, % string literal style + escapeinside={\%*}{*)}, % if you want to add a comment within your code + morekeywords={*,...} % if you want to add more keywords to the set +} + +\newcommand{\noncopynumber}[1]{% + \BeginAccSupp{method=escape,ActualText={}}% + #1% + \EndAccSupp{}% +} + +\makeatletter +\def\lst@outputspace{{\ifx\lst@bkgcolor\empty\color{white}\else\lst@bkgcolor\fi\lst@visiblespace}} +\makeatother + +\begin{document} + \section{Section} + \subsection{MySubSection} + \begin{frame}{Blubtitle} + \lstinputlisting[style=demostyle]{IataCode.java} + \end{frame} +\end{document} diff --git a/documents/source-code-minted/IataCode.java b/documents/source-code-minted/IataCode.java new file mode 100644 index 0000000..06dfe9d --- /dev/null +++ b/documents/source-code-minted/IataCode.java @@ -0,0 +1,18 @@ +public class IataCode { + public static void printIATACodes(String[] myArray) { + for (int i = 0; i < myArray.length; i++) { + System.out.println(myArray[i]); + } + } + + public static void main(String[] args) { + String[] iataCodes = new String[4]; + // Flughafen München + iataCodes[0] = "MUC"; + // Flughafen Berlin Brandenburg + iataCodes[1] = "BER"; + // Flughafen Augsburg + iataCodes[2] = "AGB"; + printIATACodes(iataCodes); + } +} diff --git a/documents/source-code-minted/Makefile b/documents/source-code-minted/Makefile new file mode 100644 index 0000000..9c68868 --- /dev/null +++ b/documents/source-code-minted/Makefile @@ -0,0 +1,10 @@ +SOURCE = minted-code-inclusion + +make: + #latexmk -pdf -pdflatex="pdflatex -interactive=nonstopmode" -use-make $(SOURCE).tex + pdflatex -shell-escape $(SOURCE).tex -output-format=pdf #shellescape wird fürs logo benötigt + pdflatex -shell-escape $(SOURCE).tex -output-format=pdf # nochmaliges ausführen wegen Inhaltsverzeichnissen + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.out *.glo *.glg *.gls *.ist *.xdy *.1 *.toc *.snm *.nav *.vrb *.fls *.fdb_latexmk *.pyg diff --git a/documents/source-code-minted/minted-code-inclusion.tex b/documents/source-code-minted/minted-code-inclusion.tex new file mode 100644 index 0000000..455cc6b --- /dev/null +++ b/documents/source-code-minted/minted-code-inclusion.tex @@ -0,0 +1,13 @@ +\documentclass{beamer} +\usepackage[utf8]{inputenc} % this is needed for german umlauts +\usepackage[ngerman]{babel} % this is needed for german umlauts +\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf +\usepackage{minted} % needed for the inclusion of source code + +\begin{document} + \section{Section} + \subsection{MySubSection} + \begin{frame}{Blubtitle} + \inputminted[linenos=true, numbersep=5pt, tabsize=4, fontsize=\small]{java}{IataCode.java} + \end{frame} +\end{document}