Skip to content

Commit

Permalink
add and close #36 by @tobiasbueschel. ref #70
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Mar 2, 2018
1 parent 28f7d2d commit 66a9d31
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/11_chapter_3.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ if mood == 'happy':
print("I am a happy robot")
```

Alternatively, you can also use LaTeX to create a code block as shown in the Java example below:
\lstinputlisting[style=javaCodeStyle, caption=Main.java]{source/code/HelloWorld.java}

If you use `javaCodeStyle` as defined in the `preamble.tex`, it is best to keep the maximum line length in the source code at 80 characters.

### Subsection 2

This is the second part of the methodology. Proin tincidunt odio non sem mollis tristique. Fusce pharetra accumsan volutpat. In nec mauris vel orci rutrum dapibus nec ac nibh. Praesent malesuada sagittis nulla, eget commodo mauris ultricies eget. Suspendisse iaculis finibus ligula.
Expand Down
9 changes: 9 additions & 0 deletions source/code/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Hello, world - example in Java.
*/
public class Main{
// says hello to the world
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
34 changes: 34 additions & 0 deletions style/preamble.tex
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,40 @@
%Following line controls size of figure legends
% \setsansfont[Scale=1.2]{Optima Regular}

% CODE BLOCKS
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{color}

% JAVA CODE BLOCKS
\definecolor{backcolour}{RGB}{242,242,242}
\definecolor{javared}{rgb}{0.6,0,0}
\definecolor{javagreen}{rgb}{0.25,0.5,0.35}
\definecolor{javapurple}{rgb}{0.5,0,0.35}
\definecolor{javadocblue}{rgb}{0.25,0.35,0.75}

\lstdefinestyle{javaCodeStyle}{
language=Java, % the language of the code
backgroundcolor=\color{backcolour}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
basicstyle=\fontsize{10}{8}\sffamily,
breakatwhitespace=false,
breaklines=true,
keywordstyle=\color{javapurple}\bfseries,
stringstyle=\color{javared},
commentstyle=\color{javagreen},
morecomment=[s][\color{javadocblue}]{/**}{*/},
captionpos=t, % sets the caption-position to bottom
frame=single, % adds a frame around the code
numbers=left,
numbersep=10pt, % margin between number and code block
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
columns=fullflexible,
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false, % underline spaces within strings only
showtabs=false, % show tabs within strings adding particular underscores
tabsize=2 % sets default tabsize to 2 spaces
}

%Attempt to set math size
%First size must match the text size in the document or command will not work
%\DeclareMathSizes{display size}{text size}{script size}{scriptscript size}.
Expand Down

0 comments on commit 66a9d31

Please sign in to comment.