-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtestdocument.tex
More file actions
60 lines (51 loc) · 1.53 KB
/
testdocument.tex
File metadata and controls
60 lines (51 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{fullpage}
\usepackage{listings}
\usepackage{color}
\title{Syntax Highlighting in LaTeX with the listings Package test}
\author{writeLaTeX}
\input{hlcolors.tex}
\begin{document}
\maketitle
\section{Java}
\begin{lstlisting}[language=java]
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
for (int i = 0; i < 100; ++i) {
System.out.println(i);
}
}
}
\end{lstlisting}
\section{Python}
% from http://wiki.scipy.org/Numpy_Example_List
\begin{lstlisting}[language=python]
>>> from numpy import *
>>> from numpy.fft import *
>>> signal = array([-2., 8., -6., 4., 1., 0., 3., 5.])
>>> fourier = fft(signal)
>>> N = len(signal)
>>> timestep = 0.1 # if unit=day -> freq unit=cycles/day
>>> freq = fftfreq(N, d=timestep) # freqs corresponding to 'fourier'
>>> freq
array([ 0. , 1.25, 2.5 , 3.75, -5. , -3.75, -2.5 , -1.25])
>>> fftshift(freq) # freqs in ascending order
array([-5. , -3.75, -2.5 , -1.25, 0. , 1.25, 2.5 , 3.75])
\end{lstlisting}
\section{MATLAB/Octave}
% from http://wiki.scipy.org/Numpy_Example_List
\begin{lstlisting}[language=octave]
octave:1> function xdot = f (x, t)
>
> r = 0.25; k = 1.4;
> a = 1.5; b = 0.16; c = 0.9; d = 0.8;
>
> xdot(1) = r*x(1)*(1 - x(1)/k) - a*x(1)*x(2)/(1 + b*x(1));
> xdot(2) = c*a*x(1)*x(2)/(1 + b*x(1)) - d*x(2);
>
> endfunction
\end{lstlisting}
\end{document}