BookML test: lstlisting user guide

Copyright 1996–2004, Carsten Heinz
Copyright 2006–2007, Brooks Moses
Copyright 2013–, Jobst Hoffmann

BookML

v0.31.9

0.8.8 (perl)

2018/12/01

1.2 Typesetting listings

var i:integer;, var i:integer;

1 for i:=maxint to 0 do
2 begin
3 { do nothing }
4 end;
5
6 Write(’Case␣insensitive␣’);
7 WritE(’Pascal␣keywords.’);
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write(’Case␣insensitive␣’);
WritE(’Pascal␣keywords.’);
1 for i:=maxint to 0 do
2 begin
3 { do nothing }
4 end;
5
6 Write(’Case␣insensitive␣’);
7 WritE(’Pascal␣keywords.’);
2 begin
3 { do nothing }
4 end;
2 begin
3 { do nothing }
4 end;
2 begin
3 { do nothing }
4 end;
2 begin
3 { do nothing }
4 end;
1 # -*- mode: Perl -*-
2 # /=====================================================================\ #
3 # | listings | #
4 # | Implementation for LaTeXML | #

1.3 Figure out the appearance

1 for i:=maxint to 0 do
2 begin
3 { do nothing }
4 end;
5
6 Write(’Case insensitive ’);
7 WritE(’Pascal keywords.’);

1.4 Seduce to use

1 for i:=maxint to 0 do
begin
3 { do nothing }
end;
5
Write(’Case␣insensitive␣’);
7 WritE(’Pascal␣keywords.’);
Listing 1: A floating example
1 for i:=maxint to 0 do
2 begin
3 { do nothing }
4 end;
5
6 Write(’Case␣insensitive␣’);
7 WritE(’Pascal␣keywords.’);
1 if (i≤\leq0) then i ←\leftarrow 1;
2 if (i≥\geq0) then i ←\leftarrow 0;
3 if (i≠\neq0) then i ←\leftarrow 0;

2.5 Special characters

1 123456789
2 { one tabulator }
3 { two tabs }
4 123 { 123 + two tabs }
1 ␣␣␣␣for␣i←\leftarrowmaxint␣to␣0␣do
2 ␣␣␣␣begin
3 ␣␣␣␣␣␣␣␣{␣do␣nothing␣}
4 ␣␣␣␣end;

2.6 Line numbers

for i←\leftarrowmaxint to 0 do
101 begin
{ do nothing }
103 end;
Write(’Case␣insensitive␣’);
5 WritE(’Pascal␣keywords.’);
1 for i←\leftarrowmaxint to 0 do
begin
3 { do nothing }
end;
5 Write(’Case␣insensitive␣’);
WritE(’Pascal␣keywords.’);
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int main(int argc,char* argv[]){
6 int i;
7 int limit;
10 if ( argc > 1 ) {
11 limit = atoi(argv[1]);
12 } else {
13 limit = 100;
14 }
17 for (i = 1;i ≤\leq limit;i++) {
18 printf(”Line␣no.␣%3.0d\n”, i);
19 }
21 return 0;
22 }
1 Line no. 1
2 Line no. 2
6 Line no. 6
7 Line no. 7

2.7 Layout elements

1 for i←\leftarrowmaxint to 0 do
2 begin
3 { do nothing }
4 end;
1 for i←\leftarrowmaxint to 0 do
2 begin
3 { do nothing }
4 end;
1 for i←\leftarrowmaxint to 0 do
2 begin
3 { do nothing }
4 end;
Listing 2: Useless code
1 for i←\leftarrowmaxint to 0 do
2 begin
3 { do nothing }
4 end;
‘Caption’ without label
1 for i←\leftarrowmaxint to 0 do
2 begin
3 { do nothing }
4 end;
1 for i←\leftarrowmaxint to 0 do
2 begin
3 j←\leftarrowsquare(root(i));
4 end;

2.8 Emphasize identifiers

1 for i←\leftarrowmaxint to 0 do
2 begin
3 j←\leftarrowsquare(root(i));
4 end;
1 for i←\leftarrowmaxint to 0 do
2 begin
3 j←\leftarrowsquare(root(i));
4 end;

2.9 Indexing

1 for i←\leftarrowmaxint to 0 do
2 begin
3 j←\leftarrowsquare(root(i));
4 end;