-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpseudocode.tex
More file actions
102 lines (89 loc) · 2.09 KB
/
pseudocode.tex
File metadata and controls
102 lines (89 loc) · 2.09 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{pseudocode}
\usepackage{xcolor}
\usepackage[margin=2.5cm]{geometry}
\lstnewenvironment{pseudo}
{\lstset{language=pseudocode,
tabsize=4,
columns=flexible,
basicstyle=\sffamily\small,
xleftmargin=1cm,
xrightmargin=1cm,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.133,0.545,0.133}\emph,
stringstyle=\color[rgb]{0.627,0.126,0.941},
}
}{}
\lstnewenvironment{pseudofr}
{\lstset{language=pseudocodefr,
tabsize=4,
columns=flexible,
basicstyle=\sffamily\small,
xleftmargin=1cm,
xrightmargin=1cm,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.133,0.545,0.133}\emph,
stringstyle=\color[rgb]{0.627,0.126,0.941},
}
}{}
\lstnewenvironment{tex}
{\lstset{language=tex,
tabsize=4,
basicstyle=\ttfamily\small,
xleftmargin=1cm,
xrightmargin=1cm,
}
}{}
\date{2018/11/01}
\title{The \textbf{pseudocode} package}
\author{Guillaume J. Laurent}
\begin{document}
\maketitle
The \textbf{pseudocode} package defines additional languages using listings package for writing algorithms in a natural way (in english or in french).
\bigskip
The following \LaTeX{} code:
\begin{tex}
\begin{pseudo}
Function integer greatestCommonDivisor(integer a, integer b)
begin
while (a <> b) do
if a > b
a := a - b
else
b <- b - a
endif
endwhile
return a
end
\end{pseudo}
\end{tex}
produces:
\begin{pseudo}
Function integer greatestCommonDivisor(integer a, integer b)
begin
while (a <> b) do
if a > b
a := a - b
else
b <- b - a
endif
endwhile
return a
end
\end{pseudo}
Same example but written french:
\begin{pseudofr}
Fonction entier plusGrandCommunDiviseur(entier a, entier b )
Début
tant que ( a != b ) faire
si ( a > b )
a := a - b
sinon
b <- b - a
finsi
fintantque
retourner a
Fin
\end{pseudofr}
\end{document}