Преглед на файлове

added source code examples

Martin Thoma преди 12 години
родител
ревизия
3e1dba9d8b

+ 18 - 0
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);
+    }
+}

+ 10 - 0
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

+ 43 - 0
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}

+ 18 - 0
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);
+    }
+}

+ 10 - 0
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

+ 13 - 0
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}