Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
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
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1X4 [33X[0;0YVisualization of the pictures created[133X[101X23[33X[0;0YThis chapter describes two easy ways to visualize the images created by4using the [5XIntPic[105X package. Both require LaTeX and some LaTeX packages, such5as [5XTikz[105X and [5Xpgf[105X, to be installed and working. One of the ways we will6describe is almost completely automatic. It makes use of the function7[10XSplash[110X, borrowed from the [5XViz[105X package. The other is not so automatic but has8the advantage of not requiring other packages, besides the LaTeX ones, and9should work in any operation system.[133X101112[1X4.1 [33X[0;0YViewing using [5XViz[105X[101X[1X[133X[101X1314[33X[0;0YProducing and displaying a picture from a [10Xtikz[110X string [3Xtkz[103X may me achieved in15a simple way. (Warning: extenvive tests have only been done with Linux.) One16just have to type the following:[133X1718[4X[32X IP\_Splash [32X[104X19[4XIP_Splash(tkz);[104X20[4X[32X[104X2122[33X[0;0YA picture is popped up after this use of the function [10XIP_Splash[110X.. To see the23name of the temporary directory created to perform the computations, and24thus being able to copy the files involved to any other place, one should25set the info level [10XInfoViz[110X to [22X1[122X or more. The following example illustrates26this and the use of some options of the function [10XIP_Splash[110X. For instance,27the [10Xpdf[110X viewer can be changed.[133X2829[4X[32X infoviz: temporary directory [32X[104X30[4Xgap> SetInfoLevel(InfoViz,1);[104X31[4Xgap> IP_Splash(tkz,rec(viewer:="okular")); [104X32[4X#I The temporary directory used is: /tmp/tmJcpphI/[104X33[4X[32X[104X3435[33X[0;0YThe temporary directory /tmp/tmJcpphI/ contains the file and vizpicture.tex.36The file vizpicture.tex is the LaTeX document to be processed. Other files,37namely the [10Xvizpicture.pdf[110X are created by the [10Xpdflatex[110X command that is called38by the [10XIP_Splash[110X function.[133X3940[33X[0;0Y[10XWarning:[110X In the case of large pictures, it may happen the LaTeX memory being41exceeded. In this case, no image is produced and the user is not warned.[133X424344[1X4.2 [33X[0;0YViewing without using [5XViz[105X[101X[1X[133X[101X4546[33X[0;0YThis section describes a way to visualize images without sing [5XViz[105X. Besides47being useful in the case of not having a working copy of [5XViz[105X, it is rather48convenient when the decision of where to save the pictures is made. In this49case, you may start your gap session in the desired place, the working50directory. Furthermore, if your intention is, for instance, to include the51images in a document, you may just decide the name for the file containing52the [10Xtikz[110X code and let your document input it. The glogal variables53[10XIP_Preamble[110X and [10XClosing[110X can be used to pruduce a complete LaTeX document54rather than only the [10Xtizk[110X code for the picture. The document may then be55processed by using [10Xpdflatex[110X and the picture viewed by using some [10Xpdf[110X viewer.56The [10Xpdf[110X produced can be included in a LaTeX document instead of the [10Xtizk[110X57code. In the later case, the code is processed each time the document is58processed, which should perhaps be avoided in the case of large images.[133X5960[33X[0;0YNote the use of the [10Xpreview[110X package, which is used to produce the complete61picture without having to pay attention to the paper size nor to crop the62image. It is useful for viewing purposes and also to include the [10Xpdf[110X file63produced in a LaTeX document to be processed with [10Xpdflatex[110X.[133X6465[4X[32X Preamble [32X[104X66[4Xgap> Print(IP_Preamble);[104X67[4X\documentclass{minimal}[104X68[4X\usepackage{amsmath}[104X69[4X\usepackage[active,tightpage]{preview}[104X70[4X\setlength\PreviewBorder{1pt}[104X71[4X\usepackage{pgf}[104X72[4X\usepackage{tikz}[104X73[4X\usepgfmodule{plot}[104X74[4X\usepgflibrary{plothandlers}[104X75[4X\usetikzlibrary{shapes.geometric}[104X76[4X\usetikzlibrary{shadings}[104X77[4X\begin{document}[104X78[4X\begin{preview}[104X79[4X[32X[104X8081[4X[32X Closing [32X[104X82[4Xgap> Print(IP_Closing);[104X83[4X\end{preview}[104X84[4X\end{document}[104X85[4X[32X[104X868788[1X4.2-1 [33X[0;0YA complete example[133X[101X8990[33X[0;0YAdmit you want to produce a document which contains the picture91corresponding to the [10Xtikz[110X code obtained through the instructions[133X9293[4X[32X instructions to obtain some tikz code [32X[104X94[4Xarr := [[1,2,3,4,5,6],[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]];;[104X95[4Xtkz := IP_TikzArrayOfIntegers([1..10],5,rec(highlights:=arr));;[104X96[4X[32X[104X9798[33X[0;0YThe picture is: The elements of the set [22X[1,2,3,4,5,6][122X are highlighted using99the first color (red); those of the set [22X[1,2,3,4,5][122X are highlighted using100the second color (green); those of the set [22X[1,2,3,4][122X are highlighted using101the third color (blue); those of the set [22X[1,2,3][122X are highlighted using the102fourth color (cyan); those of the set [22X[1,2][122X are highlighted using the fifth103color (magenta); those of the set [22X[1][122X is highlighted using the sixth color104(yellow).[133X105106[33X[0;0YLet us explain how the six colors used for the cell containing [22X1[122X are107distributed: upper left corner -- red; upper right corner -- green; lower108left corner -- blue; lower right corner -- cyan; the number -- magenta; the109border -- yellow.[133X110111[33X[0;0YThe colors of the cell containing [22X2[122X and [22X3[122X are distributed in a similar way.[133X112113[33X[0;0YThe colors of the cell containing [22X4[122X: left -- red; middle -- blue; right --114green.[133X115116[33X[0;0YAfter the session listed below, the files [10Xtikz_pic_for_complete_document.tex[110X117and [10Xpic_for_complete_document.tex[110X have been created in the current directory118(that is, the one where the [5XGAP[105X session has started). For other directories,119complete paths may have to be given.[133X120121[4X[32X the GAP session [32X[104X122[4Xgap> tikzfile := "tikz_pic_for_complete_document.tex";;[104X123[4Xgap> file := "pic_for_complete_document.tex";;[104X124[4Xgap> [104X125[4Xgap> arr := [[1,2,3,4,5,6],[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]];;[104X126[4Xgap> tkz := IP_TikzArrayOfIntegers([1..10],5,rec(highlights:=arr));;[104X127[4Xgap> [104X128[4Xgap> FileString(tikzfile,tkz);[104X129[4X642[104X130[4Xgap> FileString(file,Concatenation(IP_Preamble,tkz,IP_Closing));[104X131[4X961[104X132[4X[32X[104X133134[33X[0;0YExecuting something like[133X135136[4X[32X the pdf and the jpg of the picture [32X[104X137[4Xpdflatex pic_for_complete_document.tex[104X138[4Xconvert pic_for_complete_document.pdf pic_for_complete_document.jpg[104X139[4X[32X[104X140141[33X[0;0Ythe [10Xpdf[110X and the [10Xjpg[110X formats of the image have been created. The [10Xjpg[110X format142is usefull to be included into an html document, for instance.[133X143144[33X[0;0YNote that the tikz code has been saved into the file145[10Xtikz_pic_for_complete_document.tex[110X. A complete example of a LaTeX document146follows.[133X147148[4X[32X a LaTeX document [32X[104X149[4X\documentclass{article}[104X150[4X\usepackage{amsmath}[104X151[4X%\usepackage[active,tightpage]{preview}[104X152[4X%\setlength\PreviewBorder{1pt}[104X153[4X\usepackage{pgf}[104X154[4X\usepackage{tikz}[104X155[4X\usepgfmodule{plot}[104X156[4X\usepgflibrary{plothandlers}[104X157[4X\usetikzlibrary{shapes.geometric}[104X158[4X\usetikzlibrary{shadings}[104X159[4X\usepackage{graphicx}[104X160[4X\author{Author}[104X161[4X\title{How to include images in a \LaTeX\ document}[104X162[4X\date{June, 2013}[104X163[4X\begin{document}[104X164[4X%\begin{preview}[104X165[4X\maketitle[104X166[4XUsing the pdf file:[104X167[4X[104X168[4X\begin{center}[104X169[4X \includegraphics[width=0.80\textwidth]{../images/pic_for_complete_document.pdf}[104X170[4X\end{center}[104X171[4X[104X172[4XUsing the PGF/TikZ code:[104X173[4X[104X174[4X\begin{center}[104X175[4X\input{../images/tikz_pic_for_complete_document.tex}[104X176[4X\end{center}[104X177[4XIf you want to scale this immage, please chang the ``scale'' in the file[104X178[4X\textt{tikz_pic_for_complete_document.tex} [104X179[4X%\end{preview}[104X180[4X\end{document}[104X181[4X[32X[104X182183[33X[0;0YThe output, after processing with [10Xpdflatex[110X is as follows:[133X184185186[1X4.3 [33X[0;0YOther examples of use of the [5XIntPic[105X[101X[1X package[133X[101X187188189[1X4.3-1 [33X[0;0YVaria[133X[101X190191[33X[0;0YThe following example shows how to produce [10Xtikz[110X code for a picture192containing the odd integers from [22X801[122X to [22X999[122X. Each line (except the highest)193contains [22X15[122X cells.[133X194195[4X[32X Example [32X[104X196[4X[25Xgap>[125X [27Xrg := Filtered([801..889],u->(u mod 2)<>0);;[127X[104X197[4X[25Xgap>[125X [27Xflen := 15;;[127X[104X198[4X[25Xgap>[125X [27Xtwins := Filtered(Primes, p -> p + 2 in Primes);;[127X[104X199[4X[25Xgap>[125X [27Xarr := [Primes,Union(twins,twins+2),Filtered(rg,u->(u mod 3)=0)];;[127X[104X200[4X[25Xgap>[125X [27Xtkz := IP_TikzArrayOfIntegers(rg,flen,rec(highlights:=arr));;[127X[104X201[4X[32X[104X202203[33X[0;0YThe picture obtained highlights the primes, the twin primes and the204multiples of [22X3[122X. As the twins are also primes, a gradient is used to205highlight them. In this example the default list of colors is used. The same206computations, but defining other color lists.[133X207208[4X[32X Example [32X[104X209[4X[25Xgap>[125X [27Xcls := IP_ColorsCompRedTones;;[127X[104X210[4X[25Xgap>[125X [27Xrg := Filtered([801..889],u->(u mod 2)<>0);;[127X[104X211[4X[25Xgap>[125X [27Xflen := 15;;[127X[104X212[4X[25Xgap>[125X [27Xtwins := Filtered(Primes, p -> p + 2 in Primes);;[127X[104X213[4X[25Xgap>[125X [27Xarr := [Primes,Union(twins,twins+2),Filtered(rg,u->(u mod 3)=0)];;[127X[104X214[4X[25Xgap>[125X [27Xtkz := IP_TikzArrayOfIntegers(rg,flen,rec(colors := cls,highlights:=arr));;[127X[104X215[4X[32X[104X216217[4X[32X Example [32X[104X218[4X[25Xgap>[125X [27Xcls := IP_ColorsDGrayTones;;[127X[104X219[4X[25Xgap>[125X [27Xrg := Filtered([801..889],u->(u mod 2)<>0);;[127X[104X220[4X[25Xgap>[125X [27Xflen := 15;;[127X[104X221[4X[25Xgap>[125X [27Xtwins := Filtered(Primes, p -> p + 2 in Primes);;[127X[104X222[4X[25Xgap>[125X [27Xarr := [Primes,Union(twins,twins+2),Filtered(rg,u->(u mod 3)=0)];;[127X[104X223[4X[25Xgap>[125X [27Xtkz := IP_TikzArrayOfIntegers(rg,flen,rec(colors := cls,highlights:=arr));;[127X[104X224[4X[32X[104X225226[4X[32X Example [32X[104X227[4X[25Xgap>[125X [27Xcls := ["blue","-blue","black"];;[127X[104X228[4X[25Xgap>[125X [27Xrg := Filtered([801..889],u->(u mod 2)<>0);;[127X[104X229[4X[25Xgap>[125X [27Xflen := 15;;[127X[104X230[4X[25Xgap>[125X [27Xtwins := Filtered(Primes, p -> p + 2 in Primes);;[127X[104X231[4X[25Xgap>[125X [27Xarr := [Primes,Union(twins,twins+2),Filtered(rg,u->(u mod 3)=0)];;[127X[104X232[4X[25Xgap>[125X [27Xtkz := IP_TikzArrayOfIntegers(rg,flen,rec( colors := cls,highlights:=arr));;[127X[104X233[4X[32X[104X234235[33X[0;0YThe following example uses the [5XNumericalSgps[105X package.[133X236237[4X[32X Example [32X[104X238[4X[25Xgap>[125X [27X#LoadPackage("numericalsgps");[127X[104X239[4X[25Xgap>[125X [27X[127X[104X240[4X[25Xgap>[125X [27Xns := NumericalSemigroup(11,19,30,42,59);;[127X[104X241[4X[25Xgap>[125X [27Xcls := ShuffleIP_Colors([IP_ColorsGreenTones,IP_ColorsCompBlueTones]);;[127X[104X242[4X[25Xgap>[125X [27Xflen := 20;;[127X[104X243[4X[25Xgap>[125X [27X#some notable elements[127X[104X244[4X[25Xgap>[125X [27Xarr := [SmallElementsOfNumericalSemigroup(ns),[127X[104X245[4X[25X>[125X [27X GapsOfNumericalSemigroup(ns),[127X[104X246[4X[25X>[125X [27X MinimalGeneratingSystemOfNumericalSemigroup(ns),[127X[104X247[4X[25X>[125X [27X FundamentalGapsOfNumericalSemigroup(ns),[127X[104X248[4X[25X>[125X [27X [ConductorOfNumericalSemigroup(ns)],[127X[104X249[4X[25X>[125X [27X PseudoFrobeniusOfNumericalSemigroup(ns)];;[127X[104X250[4X[25Xgap>[125X [27X[127X[104X251[4X[25Xgap>[125X [27Xtkz := IP_TikzArrayOfIntegers(flen,rec(colors := cls,highlights:=arr));;[127X[104X252[4X[32X[104X253254[33X[0;0YUsing the default colors[133X255256257[1X4.3-2 [33X[0;0YThe banner[133X[101X258259[33X[0;0YThe code in the following example has been used to produce one possible260banner for the homepage of the [5XIntPic[105X package. It is a nice picture that261gives an idea about the primes less than [22X10000[122X. Of course, other ranges262could have been chosen. I warn the user that pictures involving a large263amount of data may face the problem of exceeding TeX capacity...[133X264265[4X[32X Example [32X[104X266[4X[25Xgap>[125X [27Xrow_length := 200;; # the legth of each row[127X[104X267[4X[25Xgap>[125X [27Xcolumns := 50;; # the number of colums[127X[104X268[4X[25Xgap>[125X [27Xn := row_length*columns;[127X[104X269[4X[28X10000[128X[104X270[4X[25Xgap>[125X [27X[127X[104X271[4X[25Xgap>[125X [27X##compute the primes less than n[127X[104X272[4X[25Xgap>[125X [27X# Primes is a GAP variable representing the list of primes less than 1000[127X[104X273[4X[25Xgap>[125X [27Xmp := Maximum(Primes);[127X[104X274[4X[28X997[128X[104X275[4X[25Xgap>[125X [27Xnewprimes := [];;[127X[104X276[4X[25Xgap>[125X [27Xwhile mp < n do[127X[104X277[4X[25X>[125X [27X mp := NextPrimeInt(mp);[127X[104X278[4X[25X>[125X [27X Add(newprimes, mp);[127X[104X279[4X[25X>[125X [27Xod;[127X[104X280[4X[25Xgap>[125X [27Xsmall_primes := Union(Primes, newprimes);;[127X[104X281[4X[25Xgap>[125X [27X##compute the first element of each pair of twin primes less than n[127X[104X282[4X[25Xgap>[125X [27Xtwins := Filtered(small_primes, p -> IsPrime(p+2));;[127X[104X283[4X[25Xgap>[125X [27X[127X[104X284[4X[25Xgap>[125X [27Xrg := [1..n];;[127X[104X285[4X[25Xgap>[125X [27X[127X[104X286[4X[25Xgap>[125X [27Xarr := [Intersection(small_primes,rg),[],[], [127X[104X287[4X[25X>[125X [27X Intersection(Union(twins,twins+2),rg),[],[],[],[],[],[],[],[127X[104X288[4X[25X>[125X [27X [],[],[],[],[],[],Difference(rg,small_primes)];;[127X[104X289[4X[25Xgap>[125X [27X[127X[104X290[4X[25Xgap>[125X [27Xtkz:=IP_TikzArrayOfIntegers([1..n],row_length,rec(highlights:=arr,[127X[104X291[4X[25X>[125X [27X cell_width := "6",colsep:="0",rowsep:="0",inner_sep:="2",[127X[104X292[4X[25X>[125X [27X shape_only:=" ",line_width:="0",line_color:="black!20" ));;[127X[104X293[4X[32X[104X294295296297