CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
2
2 The IntPic package main function
3
4
This chapter consists of two sections, the first of which decribes the main
5
function of the package. The second one can be thought just as an example to
6
produce a table where the integers appear ordered in a non standard way.
7
8
9
2.1 The main function
10
11
The function IP_TikzArrayOfIntegers (2.1-1) is the main function of the
12
IntPic package. It aims to produce tikz code for displaying arrays of
13
integers.
14
15
16
2.1-1 Tikz code for arrays of integers
17
18
IP_TikzArrayOfIntegers( arg )  function
19
20
The arguments (at most 3) are:
21
22
1 (optional)
23
24
 a table of integers. In this case, the length of the rows is the
25
maximum of the lengths of the sublists in the table, or
26
27
 a list of integers and, optionally, an integer which indicates
28
the length of the rows; when the length of the rows is not
29
indicated, a compromise between the width and the height is
30
tried.
31
32
2 a record of options. One of the fields of this record, named
33
highlights, is an array whose entries are the numbers to be
34
highlighted: one color per sublist. See details and other options in
35
ChapterĀ 5.
36
37
When no list nor table is present, the smallest range containing all the
38
integers to be highlighted is taken.
39
40
 Example 
41
gap> rg := [81..89];;
42
gap> len := 10;;
43
gap> arr := [Filtered(rg,IsPrime),Filtered(rg,u->(u mod 2)=0),
44
>  Filtered(rg,u->(u mod 3)=0)];;
45
gap> tkz := IP_TikzArrayOfIntegers(rg,len,rec(highlights:=arr));;
46

47
48
The aspect of the string tkz produced is not very appealing. We show it
49
once, by asking it exlicitly in the next example. In the forthcomming
50
examples we keep using two semicolons to avoid showing this kind of strings.
51
52
 The tkz string 
53
gap> tkz;
54
"%tikz\n\\begin{tikzpicture}[every node/.style={draw,scale=1pt,\nminimum width\
55
=20pt,inner sep=3pt,\nline width=1pt,draw=black}]\n\\matrix[row sep=2pt,column\
56
 sep=2pt]\n{\\node[fill=-red]{86};&\n\\node[fill=green]{87};&\n\\node[fill=-re\
57
d]{88};&\n\\node[fill=red]{89};\\\\\n\\node[fill=green]{81};&\n\\node[fill=-re\
58
d]{82};&\n\\node[fill=red]{83};&\n\\node[left color=-red,right color=green]{84\
59
};&\n\\node[]{85};\\\\\n};\n\\end{tikzpicture}\n"
60

61
62
This string can be used at the users wish. In particular, it can be sent to
63
the standard output using the command Print (Reference: Print).
64
65
 The tikz code 
66
gap> Print(tkz);
67
%tikz
68
\begin{tikzpicture}[every node/.style={draw,scale=1pt,
69
minimum width=20pt,inner sep=3pt,
70
line width=1pt,draw=black}]
71
\matrix[row sep=2pt,column sep=2pt]
72
{\node[fill=-red]{86};&
73
\node[fill=green]{87};&
74
\node[fill=-red]{88};&
75
\node[fill=red]{89};\\
76
\node[fill=green]{81};&
77
\node[fill=-red]{82};&
78
\node[fill=red]{83};&
79
\node[left color=-red,right color=green]{84};&
80
\node[]{85};\\
81
};
82
\end{tikzpicture}
83

84
85
It can now be copied and pasted in a LaTeX document (having the appropriate
86
packages in the preamble). See Chapter 4 for details and alternatives.
87
88
The next function uses the previous one, but is called with a simpler
89
argument. It will hopefully be useful for simple drawings. The length of
90
each row and the umber of columns varies. A compromise based on some
91
experiments has been established in order to obtain not too large nor too
92
high images.
93
94
95
2.1-2 Tikz code for arrays, in a simplified way
96
97
IP_SimpleTikzArrayOfIntegers( arg )  function
98
99
The argument is either a list of integers or a matrix of integers. The
100
integers involved are embeded in a range rg of minimum length and
101
highlighted by using the list of default colors.
102
103
 Example 
104
gap> d := DivisorsInt(30);
105
[ 1, 2, 3, 5, 6, 10, 15, 30 ]
106
gap> IP_SimpleTikzArrayOfIntegers(d);;
107

108
109
 Example 
110
gap> d30 := DivisorsInt(30);
111
[ 1, 2, 3, 5, 6, 10, 15, 30 ]
112
gap> d40 := DivisorsInt(40);
113
[ 1, 2, 4, 5, 8, 10, 20, 40 ]
114
gap> tkz := IP_SimpleTikzArrayOfIntegers([d30,d40]);;
115

116
117
118
2.2 Producing tables
119
120
When the user is interested in tables of a certain kind, it may be a good
121
idea to write some code to produce these tables. The following function
122
(whose code is part of the file ip_tables.gi in the gap folder of this
123
package) is convenient to deal with numerical semigroups with two generators
124
and has been used to produce the images contained in [DFGSL14].
125
126
2.2-1 IP_TableWithModularOrder
127
128
IP_TableWithModularOrder( o, a, b, depth, height, rep, pos )  function
129
130
The arguments rep and pos are booleans (true or false). When rep is true
131
there is some repetition: the last column is equal to the first, but pushed
132
down some rows. When pos is true, no rows below 0 are considered,
133
(contradicting depth, if needed).
134
135
The first five arguments arguments o, a, b,depth and height are integers.
136
What they represent is described in what follows. There is assigned some
137
kind of a referential on the constructed table and the fist argument, o,
138
stands for the origin. A table with b columns (b+1 columns when rep is true)
139
is constructed as follows. The row containing the origin is
140
141
 o+ [0..b-1]*a, if rep is false, or
142
143
 o+ [0..b]*a, if rep is true
144
145
The remaining rows are obtained by adding b (the upper ones) or subtracting
146
b (the others) to these rows.
147
148
Note: when a < b are co-prime, this construction provides a representation
149
of the integers as an array.
150
151
 Example 
152
gap> a := 8;; b := 19;; 
153
gap> ns := NumericalSemigroup(a,b);;
154
gap> c := ConductorOfNumericalSemigroup(ns);;
155
gap> origin := 2*c-1;
156
251
157
gap> ground := [origin..origin+b-1];;
158
gap> 
159
gap> height:=2;;
160
gap> depth:=8;;
161
gap>  xaxis := [origin];;
162
gap>  for n in [1..b-1] do
163
>  Add(xaxis, origin+n*a);
164
>  od;
165
gap>  yaxis := [];;
166
gap>  for n in [-depth..height] do
167
>  Add(yaxis, origin+n*b);
168
>  od;
169
gap> 
170
gap> table := IP_TableWithModularOrder(origin,a,b,depth,height,false,false);;
171
gap> arr := [xaxis,yaxis,ground];
172
[ [ 251, 259, 267, 275, 283, 291, 299, 307, 315, 323, 331, 339, 347, 355, 
173
 363, 371, 379, 387, 395 ], 
174
 [ 99, 118, 137, 156, 175, 194, 213, 232, 251, 270, 289 ], [ 251 .. 269 ] ]
175
gap> tkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr));;
176

177
178
The next picture is obtained in the same way. The information that only the
179
shape has interest is given by including the option shape_only:=" ". The
180
variable tkz should be defined in a similar manner to the following one.
181
182
 Example 
183
gap> tkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr,shape_only:=" ",
184
>  cell_width := "6",colsep:="1",rowsep:="1",inner_sep:="2",
185
>  line_color:="black!20"));;
186

187
188
Next, a minimum of changes, just to illustrate the effect of rep and pos.
189
190
 Example 
191
gap> table := IP_TableWithModularOrder(origin,a,b,depth,50,true,true);;
192
gap> tkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr));;
193

194
195
196