summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/support/ketcindy/source/ketmanual/KeTCindyguideE.tex
blob: 8ba5ed7707b40c3c46825259b52e6766c57f3e7b (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
\documentclass[papersize,a4paper,12pt]{article}
\usepackage{ketpic,ketlayer}
\usepackage{amsmath,amssymb}
% \usepackage{amsmath,newtxmath}
%\usepackage[dvipdfmx]{graphicx,color}
\usepackage{graphicx,color}
\usepackage{wrapfig}
%\usepackage[dvipdfmx,bookmarks=false,colorlinks=true,linkcolor=blue]{hyperref}
\usepackage[bookmarks=false,colorlinks=true,linkcolor=blue]{hyperref}
\setmargin{20}{20}{15}{25}
\usepackage{setspace}
\usepackage{comment}
\usepackage{bm,enumerate}
\usepackage{pict2e}

%\newcommand{\cmd}[1]{
%\begin{center}{\bf\large #1}\end{center}
%\hypertarget{#1}{}
%}

\newenvironment{cmd}[2]{
\hypertarget{#2}{}
\begin{center}{\bf\large #1}\end{center}
\begin{description}
}{
\end{description}
\begin{flushright} \hyperlink{functionlist}{$\Rightarrow$Command List}\end{flushright}
}

% item command for this documentation
\newcommand{\itemket}[1]{
\item[\Ltab{27mm}{#1}]
}


\begin{document}
\title{Guide to \ketcindy}
\author{\ketcindy\ Project Team}
\maketitle

\begin{center}  - ver.3.2 -\end{center}

\hypertarget{index}{}
\tableofcontents

\newpage

\section{About \ketcindy}

\subsection{Overview}

\ketcindy\ is a library of Cindyscript 
which is a programming language of Cinderella. 
It converts the data computed 
for generating dynamic graphics on Cinderella 
into \TeX\ graphical codes. 
Synchronized use of 
interactive graphics capabilities of Cinderella 
and well-structured programming capabilities of Cindyscript 
enables ordinary \TeX\ users to efficiently embed 
high-quality graphics into \TeX\ documents. 
Moreover, the collaborative use of \ketcindy\ 
and other software such as R, Maxima and C 
has been enabled.

\begin{center}
\input{Fig/concept}
\end{center}

Firstly, dynamic figure is generated on Cinderella. 
Secondly, \ketcindy\ generates 
a source file of R and makes R execute it 
for the generation of \TeX\ graphical codes. 
Thirdly, those codes are formatted into 
\TeX\ file which is input in the targetting \TeX\ document 
via the command \verb|\input|. 
Finally, usual compilation procedure of \TeX\ results in 
the generation of final PDF output 
including the corresponding figure. 
A batch file \verb|kc.bat| for Windows 
or a shell file \verb|kc.sh| for Mac or Linux 
is generated via \ketcindy\ 
in order to batch-process all the steps 
from the second to the last. 
Also by using these files, 
collaboration of Cinderella and other software 
as shown in the schematic diagram above 
is processed. 

Summarizingly, specific steps to generate a \TeX\ figure 
are listed as follows.

\begin{enumerate}[(1)]
\item 
Generate the needed geometric elements 
on the Euclidean view of Cinderella 
using its drawing tools. 
These elements can be moved interactively. 

\hspace{30mm}\includegraphics[bb=0.00 0.00 408.02 347.02,width=6cm]{Fig/incenter01.pdf}

\item 
Input the \ketcindy\ codes into Cindyscript editor 
to specify the graphical elements to be displayed 
in \TeX\ final output. 
Also \ketcindy\ codes are used 
to generate supplementary graphical elements 
and handle them. 

\hspace{10mm}\includegraphics[bb=0.00 0.00 811.04 257.01,width=12cm]{Fig/incenter02E.pdf}

In this stage, the programming capabilities 
inherently implemented to Cindyscript can be used simultaneously. 
Execute the whole program by clicking the "Run" button. 
For more details, see section 3. 

\item 
Click the button named \verb|Figures| in Euclidean view 
to automatically generate the following files 
in the folder named "fig". 
Here, "incenter" is the name specified 
via the command \verb|Setfiles("incenter")| 
in step (2). 

\begin{tabbing}
12\=1234567897890123456\=\kill

 \> \verb|kc|.sh or \verb|kc.bat| \> shell script file(Mac) or batch file(Windows) \\
 \> \verb|incenter.r| \> \\
 \> \verb|incenter.tex| \> \TeX\ file composed of graphical codes\\
 \> \verb|incentermain.aux| \> \\
 \> \verb|incentermain.log| \> \\
 \> \verb|incentermain.pdf| \> PDF file to display the resulting graphical image\\
 \> \verb|incentermain.tex| \> \TeX\ file temporarily used to generate 
the file \verb|incentermain.pdf|
\end{tabbing}

Subsequently, the file \verb|incentermain.pdf| 
is automatically displayed as shown below. 

\hspace{30mm}\includegraphics[bb=0.00 0.00 348.02 284.51,width=6cm]{Fig/incenter03.pdf}

We can manipulate this final output 
by modifying the inputs in steps (1) and (2) 
before processing the step (3) again. 

\vspace{\baselineskip}
\item  
Using \ketpic\ package of \TeX , 
\verb|incenter.tex| can be read 
into the targetting \TeX\ document 
via the command 
\begin{center}
\verb|\input{incenter}|
\end{center} 
Then the same figure is embedded in the targetting PDF output. 

\end{enumerate}


\newpage

\subsection{Geometric Figures}

Producing geometric figures in the plane is easy. Moreover, we can add hatchings  in some areas, which is better than shading 
for monochrome printing.
The following are the main parts of the script.

\begin{verbatim}
    Listplot([A,B,C,A]);
    Circledata([D,E]);
    Bowdata([B,A],[1,0.5,"Expr=c","da"]); 
    Bowdata([C,B],[1,0.5,"Expr=a","da"]);
    Bowdata([A,C],[1,0.5,"Expr=b","da"]); 
    Hatchdata("2",["oi"],[["crDE"],["sgABCA"]],["dr,0.7",""]); 
    Pointdata("I",D,["size=4"]);
    Letter([A,"sw","A",B,"ne","B",C,"se","C",D,"se","I"]);
\end{verbatim}

\begin{center}
\includegraphics[bb=0.00 0.00 416.00 347.00,height=42mm]{Fig/hatch.pdf}
\hspace{2mm}
\input{Fig/s106bowhatch.tex}
\end{center}


\subsection{Graphs of Functions}
\ketcindy\ can produce graphs of functions with
\begin{verbatim}
    Plotdata("1","x^2","x");
\end{verbatim}
or parametrically with
\begin{verbatim}
    Paramplot("1","[2*cos(t),sin(t)]", "t=[0,2*pi]");
\end{verbatim}
\noindent Here we give an example of the solution curve of a differential equation. The script is:
%\verb|        // data are assigned to the variable de1.|\\
%\verb|        // [0,XMAX] is the range of t.|\\
\begin{verbatim}
    Deqplot("1","y``=-L.x*y`-G.x*y","t=[0,XMAX]",0,[C.y,0]);
    // the equation is y''=-ay'-by (a=L.x, b=G.x).
    // C.y,0 are initial values of y and y' at t=0.
    Expr(M,"e","\displaystyle\frac{d^2 x}{dt^2}+"
           +"+L.x+"\frac{dx}{dt}+"+G.x+"x=0");
\end{verbatim}

Note that points C, G, L  on segments AB, EF, HK are movable, and 
are used to decide the coefficients and the initial value as you can see in the above scripts.
\vspace{3mm}

\begin{center}
\includegraphics[bb=0.00 0.00 385.00 398.00,height=60mm]{Fig/diffeq1.pdf}
\hspace{5mm}
\input{Fig/s210diffeq1.tex}

\end{center}

%\putnotes{35}{53}{\input{fig/s305incanddec.tex}}
%\putnotes{35}{110}{Figure \thefigno\ \ Table}\addtocounter{figno}{1}%
%\putnotes{97}{65}{\input{fig/kumamonthin.tex}}
%\putnotes{97}{59}{%
%\includegraphics[bb=0.00 0.00 183.63 142.07]{fig/figkumamon.pdf}}
%\putnotene{100}{72}{\input{fig/kumamoto.tex}}
%\putnotes{97}{110}{Figure \thefigno\ \ B\'ezier Curve}\addtocounter{figno}{1}%

\subsection{Drawing Tables}
Writing the code for tables to be inserted into the \TeX\ documents is sometimes troublesome.
However, it is not a hard job for \ketcindy\ (see the output in Figure.

\begin{verbatim}
      xLst=apply(1..7,15);
      yLst=[10,10,10,10,80];
      rmvL=apply(1..6,"c"+text(#)+"r4r5");
      rmvL=concat(rmvL,["r2c1c2","r3c1c2"]);
      Tabledata("",xLst,yLst,rmvL);
      Tlistplot(["c1r1","c2r4"]);
      Tlistplot(["c2r1","c1r4"]);
      Putrowexpr(1,"c",
          ["x","0","\cdots","e","\cdots","e\sqrt{e}","\cdots"]);
      Putrowexpr(2,"c",["y`","","+","0","-","-","-"]);
      Putrowexpr(3,"c",["y``","","-","-","-","0","+"]);
      Putrowexpr(4,"c",["y","","","10/e","","15/e\sqrt{e}",""]);
      Putcell("c0r4","c7r5","c","\input{fig/graph}");
\end{verbatim}

\vspace{2mm}

\begin{center}
\input{Fig/s305incanddec.tex}
\end{center}


\newpage

\subsection{Plotting data}
Here we call the data computed 
to generate the graphs of functions and geometric elements 
"Plotting data" which is abbreviated as PD. 
The PD to draw segment is the list of coordinates 
of its two endpoints. 
For example, 
when the coordinates of the points A and B 
are (1, 1) and (3, 2) respectively, 
PD of the segment AB named \verb|Listplot ([A,B])| 
is stored in the form \verb|[[1,1],[3,2]]|. 
Also the PD to draw a curve is the collection of 
those for drawing small segments 
which connect contiguous dividing points of the curve. 
PD are automatically given names via \ketcindy\ 
following the rules below.

\begin{itemize}
\item 
The beginning part of the PD's name 
depends on the kind of the corresponding graphical element. 
For instance, 
\verb|sg| is associated to segments and 
\verb|cr| is associated to circles. 

\item 
When some extra name is specified 
as the first argument in the definition of PD, 
it is added to the beginning part given above. 
For instance, the PD defined below 
is given the name \verb|sg1|. 
\begin{center}
\verb|Listplot("1",[[0,0],[1,2]]);| 
\end{center}

\item 
When the extra name is not needed, 
the names of the points are added 
to the beginning part given above. 
For instance, the PD defined below  
is given the name \verb|sgABC|. 
\begin{center}
\verb|Listplot([A,B,C]);|
\end{center}

\end{itemize}

\noindent 
Once PD are generated, 
their names are displayed on the console view of Cinderella. 
For instance, when the PD named \verb|sgABCA| is generated, 
the corresponding message is displayed as shown below. 

\begin{center}
\includegraphics[bb=0.00 0.00 298.02 115.01,width=6cm]{Fig/pdtoconsole.pdf}
\end{center}
Also the content of PD is displayed 
via the function \verb|println()| of Cindyscript. 
For instance, inputting the command 
\verb|println(sgABCA)| makes the following list displayed. 
\begin{center}
\verb| [[1,3],[-1,0],[3,0],[1,3]] |
\end{center}
This list is composed of the coordinates of the points A, B, and C. 

These names of PD are used 
when the corresponding PD need to be transformed. 
For instance, 
PD to draw the parallel transport of the segment AB 
is generated via the \ketcindy\ command 
\begin{center}
\verb|Translatedata("1","sgAB",[2,3]);|
\end{center}

PD can be generated also 
by using the programming capability of Cindyscript 
which can be subsequently used in \ketcindy .  
For more details, 
see the example of \verb|Listplot()| 
in the command reference. 
Inclusion of too much elements into a single PD 
may cause some error. 
To prevent such error, 
PD should be divided into several PD 
each of which is composed of 200 elements or so. 


\newpage

\section{Cindyscript}

\subsection{Cindyscript editor}

Choose "Cindyscript" in the "Scripting" menu 
or push keybuttons Ctrl+9 (Windows) / Command+9 (Mac), 
then Cindyscript editor opens as shown below. 

\begin{layer}{150}{0}
\putnotese{7}{15}{\includegraphics[bb=0.00 0.00 703.04 425.02,width=14cm]{Fig/slotE.pdf}}
\arrowlineseg[16]{30}{20}{10}{90}
\putnotese{25}{5}{Slots}
\arrowlineseg[16]{50}{20}{10}{100}
\putnotese{42}{5}{Page name}
\arrowlineseg[16]{90}{20}{10}{110}
\putnotese{80}{5}{Font size}
%\arrowlineseg[16]{107}{20}{15}{140}
%\putnotese{80}{5}{描画面を前面に}
\arrowlineseg[16]{135}{20}{10}{110}
\putnotese{125}{5}{Run}
\arrowlineseg[16]{142}{20}{10}{100}
\putnotese{135}{5}{Help}
\putnotese{100}{35}{Text field}
\putnotese{100}{80}{Console}
\end{layer}

\vspace{105mm}

Commands can be input into preferred "slot". 
Specific timing for execution of commands 
is assigned to each slot. 
The slot for current work can be chosen 
only by clicking the corresponding tab in the menu. 
Users can add extra pages to each slot. 
For instance, 
when some initialization other than 
those included in \verb|KETlib| is needed, 
clicking the folder icon of "Initialization" makes a new page open 
in which extra commands can be input. 
The name of each page can be given 
by directly inputting it into the "Page name" column. 
The font size of the scripts can be tuned 
by changing the number in the "Font size" column. 
Frequently used slots are listed below. 

\begin{itemize}

\item 
Draw

The commnds in this slot are executed 
when some change, like movement of point, 
occurs in the Euclidean view. 
In \verb|templatebasic1.cdy|, 
the protoype page named \verb|figure| 
including the \ketcindy\ commnads 
like \verb|Ketinit();| and \verb|Windispg();| 
which are unconditionally necessary 
has been prepared.  
The \ketcindy\ commands for drawing 
should be input into this slot. 

\item 
Initialization 

The definitions of functions 
and the initial values of variables 
are input here. 
The commands in this slot are exected 
only once just after the "Run" button is clicked. 
Thus, the initial data in this slot is changed 
when some modifications are made in other slots. 
In \verb|templatebasic1.cdy|, 
the protoype page named \verb|KETlib| 
including the default setting of \ketcindy\ 
has been prepared. 

\item 
Key Typed

The commnds in this slot are executed 
when some key is pushed. 

\end{itemize}

Clicking "Run" button or pushing the keybuttons Shift+Enter 
makes the whole program be executed. 
The results derived from executing the function \verb|print()| 
and error messages are displayed on the console view 
which is put at the bottom part of Cindyscript editor. 
Each error and its location 
is displayed together with the message 
"WARNING" or "syntax error". 
The outputs displayed on the console 
can be copied to other usual text editors. 

Click the "Help" button, 
then reference manual of Cinderella opens 
as shown below. \\

\includegraphics[bb=0.00 0.00 712.04 577.03,width=14cm]{Fig/CindyhelpE.pdf}


\subsection{Input}

The attribute of each input into Cindyscript 
is specified via the color of the corresponding letters 
as listed below. 

\begin{itemize}
\item 
The functions which are inherently implemented to Cinderella 
are displayed via blue color. 
\item 
The functions which are defined by user, 
including those of \ketcindy , 
are displayed via purple color. 
\item 
The functions which are not yet defined 
are displayed via red color. 
\item 
Strings are displayed via green color. 
\end{itemize}
As in the console view, 
copying and pasting to the other usual editing software 
via pushing the keybuttons Ctrl+C and Ctrl+V 
is accessible. 
Cutting and pasting via Ctrl+X and Ctrl+V 
is also possible. 
Also as in the other editing software, 
preferred strings can be specified 
via dragging mouse 
or pushing the keybutton Shift and moving the sursor. 
Serching for words via pushing Ctrl+F 
has not been enabled. 

The fundamental rule of describing scripts on Cindyscript editor 
are listed below. 
\begin{itemize}
\item 
Upper- and lowercase letters are distinguished. 
Using lowercase letters is preferable. 
\item 
As in \TeX , 
several blanks are regarded as a single blank. 
\item 
A semicolon should be located at the end of each row. 
Starting a new paragraph 
does not result in the ending of commnds. 
\end{itemize}
Particularly, in case of \ketcindy , 
the input of commands are controlled 
by the following rules. 
\begin{itemize}
\item 
The names of global variables 
begin with uppercase letters. 
\item 
The names of local variables 
begin with lowercase letters. 
Local variables are declared at the beginning part 
of the definitions of functions 
along with the Cinderella command \verb|regional()|. 
\item 
The names of functions 
begin with uppercase letters. 
\end{itemize}


\subsection{Variables and constants}

The declaration of the attribute of each variable 
is not needed in Cindyscript 
since it is automatically decided 
according to the input. 
Moreover, 
the different kind of value 
can be input without any declaration.  \\

\noindent 
{\bf Example}

\verb|          a=10;|

\verb|          b=2;|

\verb|          c=a+sqrt(b);|

\verb|          a="the square root of"|

\verb|          println("The sum of"+a+b+''and 10 is''+c);|\\

In this example, 
the attribute of variable \verb|a| was firstly integer, 
and then changed to string at the fourth row. 

The strings should be input with double quotation marks. 
The mathematical operations 
which involve several kind of variables 
must be taken much care. 
Exceptionally, 
connecting string and number with \verb|+| 
results in the generation of one single string. 

The variable \verb|pi| is reserved in Cindyscript 
as the ratio of the circumference of a circle to its diameter. 
Also the variable \verb|i| is reserved 
as the imaginary unit. 
When \verb|i| is used as variable once, 
it is changed to the imaginary unit via the command 
\begin{center}
\verb|i=complex(0,1);|
\end{center}

There are also some reserved variables in \ketcindy . 
Among them, the following ones can be changed by users. 
\begin{tabbing}
12\=3456789012345\=678989012345678901234567890123\=\kill
\>\verb|Fhead|  \>the beginning part of the file name 
which can be set by  \verb|Setfiles()|\\
\>\verb|Texparent|  \>the name of parent file 
which can be set by \verb|Setparent()|\\
\>\verb|Dirhead|  \>the beginning part of the path\\
\>\verb|Dirlib|  \>the path to the library ketlib\\
\>\verb|Dirbin|  \>the path to ketbin\\
\>\verb|Dirwork|  \>the path to the working directory 
which can be set by \verb|Changework()|\\
\>\verb|Shellfile|  \>the name of shell file
\end{tabbing}
Contrarily, the reserved variables listed below are the global variables 
usend in the library of \ketcindy , whence cannot be changed 
by users. 

\vspace{\baselineskip}
\noindent 
ADDAXES, ArrowlineNumber, ArrowheadNumber, BezierNumber, COM0thlist, COM1stlist, COM2ndlist, Dq, FUNLIST, Fnamesc ,Fnamescibody,Fnameout,Fnametex, GDATALIST, GLIST, GCLIST, GOUTLIST, KCOLOR, KETPICCOUNT,KETPICLAYER, LETTERlist, LFmark, MilliIn, PenThick,PenThickInit,  POUTLIST, SCALEX, SCALEY, SCIRELIST, SCIWRLIST, TenSize, TenSizeInit, ULEN, XMAX, XMIN, YaSize, YaThick,   YMAX, YMIN, VLIST

\vspace{\baselineskip}

A list can be defined by putting its elements in a square bracket 
with commas separating each other. 
The attribute of each element does not matter. 
The $n$-th element can be referred by using an underbar. 
For instance, the commands 

\begin{verbatim}
    list=[1,2,3,4,5];
    list_2="a";
\end{verbatim}
make the second element be substituted by the letter \verb|"a"|. 


\subsection{Frequently used commands}

\noindent
{\bf Displaying the computed output}

\noindent 
The following commands 
make the current value of the variable 
on the console view. 

\begin{tabbing}
12345\=6789012345678989012345678901234567890\=123\=\kill
\>\verb|print(the name of variable);| \> without a line break\\
\>\verb|println(the name of variable);| \> with a line break\\  
\end{tabbing}

\noindent
{\bf Conditional branching}

\noindent
The commnad \verb|if(A,B,C)| executes \verb|B| if \verb|A| is true 
and \verb|C| otherwise. 
The followings are frequently used. 
Nested conditions can be interpreted. 

\begin{tabbing}
12345\=67890123456789890\=12345678901234567890123\=\kill
\>\verb|if(a>b,...);|\\
\>\verb|if(a<b,...);|\\
\>\verb|if(a>=b,...);| \> $a\geqq b$\\
\>\verb|if(a<=b,...);| \> $a\leqq b$\\  
\>\verb|if(a=b,...);|\\
\>\verb|if(a!=b,...);| \> $a\neq b$\\  
\end{tabbing}

\noindent
{\bf Loop program}

\noindent
The commnad \verb|for(n,operation)| executes the operation 
$n$ times. If the counter should be specified, 
modify the command as \verb|for(n,s,operation)|. 
where the value of $s$ is successively changed. 
Loop program with respect to some list instead of counter 
is also possible via the command as \verb|forall(list,operation)|. 
For example, the commands

\begin{verbatim}
    sglist=[[A,B],[C,D],[E,F]];
    forall(sglist,Listplot(#));
\end{verbatim}
have the same output as 
\begin{verbatim}
    Listplot([A,B]);
    Listplot([C,D]);
    Listplot([E,F]);
\end{verbatim}

\noindent
{\bf User's definition of functions}

\noindent
The format of definition is \verb|function name(argument):=(operation)|. 
For example, if we define the function \verb|sign(n)| by 
\begin{verbatim}
    sign(n):=(
      if(n>0,print("positive"),print("0 or negative"));
    );
\end{verbatim}
it can be used as 
\begin{verbatim}
    n=3;
    println(sign(n));
\end{verbatim}

\mbox{} 

\noindent
{\bf Reference to geometric elements}

\noindent
The position of a point can be specified 
with both its name and the list of its $x,y$-coordinates. 
Thus, both of the following formats are allowed. 
\begin{verbatim}
    Listplot("1",[[1,1],[4,5]]);
    Listplot("1",[A,B]);
\end{verbatim}
Also we can get the coordinate of a point explicitly 
via the commands 
like \verb|A.xy|, \verb|A.x|, and \verb|A.y|.

\mbox{} 

\noindent
{\bf List processing}

\noindent
The list of integers between $a$ and $b$ 
is generated via the command \verb|a..b|. 
For instance, the synchronized use with the command \verb|apply| 
as below gives the shape of pentagram. 
\begin{verbatim}
    r=2;
    pt=apply(0..5,r*[cos(pi/2+#*4*pi/5),sin(pi/2+#*4*pi/5)]);
    repeat(5,s,Listplot(text(s),[pt_s,pt_(s+1)]));
\end{verbatim}
Here the Cindyscript command \verb|text| 
is used to convert the number into string. 



% -------------- Calling other softwares --------------

\newpage

\section{Collaboration with other softwares}

\subsection{Overview}

\ketcindy\ has functionalies to call other softwares such as Maxima, Risa/Asir, R and C.
Here, we introduce how to call Maxima.\vspace{1mm}

The steps are as follows.\vspace{-2mm}

\begin{enumerate}
\item Generate the shell file to call a CAS.\vspace{-2mm}
\item Execute the file.\vspace{-2mm}
\item Return the result as text.\vspace{-2mm}
\item Use the result in \ketcindy .\vspace{-2mm}
\item Produce the PDF file.\vspace{-2mm}
\end{enumerate}

And the flowchart is  as follows:
\begin{center}
{\scalebox{0.9}{\input{Fig/calling.tex}}}

\end{center}

When interfacing with Maxima, commands \texttt{Mxfun}, \texttt{CalcbyM} and \texttt{Mxtex} are all we need to complete the task. \texttt{Mxfun} and \texttt{CalcbyM} are for calling single command and multi commands of Maxima respectively. \texttt{Mxtex} is used for code conversion to \LaTeX. The output of Maxima  is returned to \ketcindy\ as a string or a list of strings for further processing. 

The options of these commands are:\\
\hspace*{10mm}\Ltab{25mm}{{\tt "m/r"}}To decide whether the result file will be  made again or not. \\
\hspace*{10mm}\Ltab{25mm}{}If these options are not given, \ketcindy\ decides automatically.\\
\hspace*{10mm}\Ltab{25mm}{{\tt "Disp=y/n"}}To decide whether the result will be displayed in the console or not. \\
\hspace*{10mm}\Ltab{25mm}{}It is only availabe for \texttt{Mxfun} and \texttt{Mxtex}.
The default is "y".


\subsection{Commands related to Maxima}

\subsubsection*{Mxfun}

The arguments are name of variable in \ketcindy, name of a function of Maxima, and a list of arguments of the function.\\
\hspace*{10mm}\verb|Mxfun("1","diff",["sin(x)","x"]);|  // The return is "cos(x)", assgined to mx1.\\
The above is equivallent to\\
\hspace*{10mm}\verb|Mxfun("1","diff(sin(x),x)",[]);|


\subsubsection*{Mxtex}

The arguments are name of variable in \ketcindy, an expression in Maxima format.\\
\hspace*{10mm}\verb|Mxtex("1",mx1);|  // The return is \verb|"\cos x"|, assgined to tx1.\\
\hspace*{10mm}\verb|Expr([0,1],"e",tx1]);|

\begin{center}
\input{Fig/maxima1.tex}
\end{center}

\subsubsection*{CalcbyM}

The arguments are name of variable in \ketcindy, a list of commands and the arguments of Maxima.\\
\hspace*{10mm}\verb|fn="sin(x)^4";|\\
\hspace*{10mm}\verb|cmdL=[|\\
\hspace*{10mm}\verb|  "df:diff",[fn,"x"],|\\
\hspace*{10mm}\verb|  "df:ratsimp",["df"],|\\
\hspace*{10mm}\verb|  "F:integrate",[fn,"x"],|\\
\hspace*{10mm}\verb|  "F","ratsimp",["F"],|\\
\hspace*{10mm}\verb|  "df::F",[]|\\
\hspace*{10mm}\verb|];|\\
\hspace*{10mm}\verb|CalcbyM("ans",cmdL);|\vspace{2mm}\\
The returned value is a list of df and F as strings, though these are not displayed in the console. They can be used, for example,\vspace{2mm}\\
\hspace*{10mm}\verb|Plotdata("1",fn,"x",["Num=200","do"]);|\\
\hspace*{10mm}\verb|Plotdata("2",ans_1,"x",["Num=200","dr"]);|\\
\hspace*{10mm}\verb|Plotdata("3",ans_2,"x",["Num=200","da"]);|\\
\hspace*{10mm}\verb|Mxtex("1",fn);|\\
\hspace*{10mm}\verb|Mxtex("1",ans_1);|\\
\hspace*{10mm}\verb|Mxtex("2",ans_2);|\\
\hspace*{10mm}\verb|Expr([A,"e",tx1,B,"e",tx2,C,"w",tx3]);|

\vspace{2mm}

\begin{center}
\input{Fig/s10diffint.tex}
\end{center}

\noindent
{\bf Remark} See KeTCindyreferenceE.pdf for more information.

\subsection{Commands related to R}

\verb|Rfun| and \verb|CalcbyR| are simillar to \verb|Mxfun| and \verb|CalcbyM|.\\
 See \verb|KeTCindyreferenceE.pdf| or \verb|samples/s08R| for more information.

% -------------- 3d figures --------------

\newpage

\section{Three Dimentional figures of \ketcindy}

\subsection{Summary and Geometric Elements}

In KeTCindy's 3D-mode, there are two rectangular areas surrounded by a white frame on the Euclidean view.

The main area on the left side of the screen is simillar to that of two dimentional figures. Figures in this area will be drawn to the \TeX\ document. The view direction can be moved with sliders under the main area.  \verb|TH| and \verb|FI| mean angles $\theta$ and $\varphi$ respectively, which are polar cocordinates of the view direction.

Figures from the view direction $(0,\ \varphi)$ are displayed in the sub area on the right side.

 \hspace{40mm} mainarea \hspace{40mm} subarea
\begin{center}
\includegraphics[bb=0.00 0.00 863.04 378.52,width=12cm]{Fig/3dscreen.pdf}
\end{center}

With internal command \verb|Ptseg3data| which is called in \verb|Start3d|, 
a point put to the main area with the drawing tool of Cinderella is regarded as a 3D point by \ketcindy, and a correspoinding point is put in the sub area. 
Though the initial coordinate of $z$ is 0, we can change it moving the point in the sub area.

For example, if we put point \verb|A| on the main area, point \verb|Az| will be put in the sub area and the 3D coordinates calculated from \verb|A| and \verb|Az|  are assigned to varible \verb|A3d|.\vspace{-1mm}

\begin{description}
\item[\bf Remark]Note that point \verb|Az| will not be deleted automatically even if point \verb|A| is deleted. We should delete it manually.
\end{description}

Geometric segment in the main area generates the corresponding geometric segment in the sub area as well.

\subsection{Lines and Curves}

\ketcindy\ commands \verb|Spaceline| and \verb|Spacecurve| are used do draw lines and curves in the space. Additionally, \verb|Xyzax3data| is used to draw axis.

\begin{description}
\item[Examples]\mbox{}\\
\verb|Xyzax3data("","x=[-5,5]","y=[-5,5]","z=[-5,5]");|\\
\verb|Spacecurve("1","3*[cos(t),sin(t),0.1*t]","t=[0,4*pi]",["Num=200"]);|\\
\verb|pt1=[3,0,0]; pt2=[3,0,3*0.1*4*pi];|\\
\verb|Spaceline("1",[pt1,pt2]);|\\
\verb|Skeletonparadata("1");| 

\item[Remark]The last command skeleton elimination is for skeleton elimination.
Compare two figures below. The right one is with skeleton elimination.

\end{description}

\begin{center}
\input{Fig/spacelinecurve1.tex}\hspace{10mm}\input{Fig/spacelinecurve2.tex}
\end{center}

\subsection{Two Dimensional Figures}

Data of two dimensional figures such as polyhedra or planes are given in obj format.

\begin{description}
\item[Examples]\mbox{}\\
\verb|Start3d();|\\
\verb|vertex=[[2,2,-2],[2,-2,-2],[-2,-2,-2],[-2,2,-2]];|\\
\verb|Reflect3d1(``1'',vertex,[[0,0,0],[1,0,0],[0,1,0]];|\\
\verb|vertex=concat(vertex,ref3d1);|\\
\verb|edge=[[1,2,6,5],[1,5,8,4],[1,4,3,2],[2,3,7,6],[3,4,8,7],[5,6,7,8]];|\\
\verb|cube=[vertex,edge];|\\
\verb|plane=[[[-3,1,-3],[3,-1,-3],[-4,5,3],[2,3,3]],[[1,2,4,3]]];|\\
\verb|tmp=Concatobj([cubic,plane]);|\\
\verb|VertexEdgeFace("1",tmp,["Vtx=nogeo","Edg=nogeo"]);|\\
\verb|Nohiddenbyfaces("1","phf3d1");| // for the figure on the left

\item[Remark]\mbox{}\\
Command \verb|Concatobj| combines data in obj format.\\
Command \verb|VertexEdgeFace| assigns vertices to {\tt phv}, edges to {\tt phe} and faces to {\tt phf}.\\
Command \verb|Nohiddenbyfaces| is for hiddenline elimination.\\
Use \verb|Skeletonparadata("1")| if the figure on the right is desirable.
\end{description}

\vspace{-10mm}

\begin{center}
\input{Fig/polygonplane1.tex}\hspace{10mm}\input{Fig/polygonplane2.tex}
\end{center}

\noindent
{\bf Remark} See \verb|KeTCindyreferenceE.pdf| or \verb|samples/s05spacefigure| for more information.

\subsection{Surfaces}

Two variable function is defined as a list of one of the followings.

\begin{enumerate}[\hspace*{5mm}\bf 1.]
\item \verb|["z=f(x,y)","x=[a,b]","y=[c,d]"]|
\item \verb|["z=f(x,y)","x=x(u,v)","y(u,v)","u=[a,b]","v=[c,d]"]|
\item \verb|["p","x=x(u,v)","y=y(u,v)","z=z(u,v)","u=[a,b]","v=[c,d]"]|
\end{enumerate}

Optionally, you can add what boundaries should be drawn.
The default is "wesn". Here, for example, "w" means the boundary defined by $[a,t]\ (c\leqq t\leqq d)$.

\ketcindy\ calls C to speed up the calculation of hidden lines elimination.

\begin{description}
\item[Example]\mbox{}\\
\verb|Start3d();|\\
\verb|Xyzax3data("","x=[-5,5]","y=[-5,5]","z=[-5,5]");|\\
\verb|fd=["z=x^2-y^2","x=[-2,2]","y=[-2,2]","senw"];|\\
\verb|Startsurf();|\\
\verb|Sfbdparadata("1",fd);|\\
\verb|Crvsfparadata("1","ax3d","sfbd3d1",fd);|\\
\verb|ExeccmdC("1");|
\verb|Windispg();|

\begin{center}
\input{Fig/saddle1E.tex}\hspace{10mm}\input{Fig/saddle2E.tex}
\end{center}

\item[Remark]Wires can be added if necessary with command \verb|Wireparadata| as seen in the upper right side figure.
The line-style also can be changed.

See \verb|KeTCindyreferenceE.pdf| or \verb|samples/s09surfaceC| for more information.
\end{description}

\subsection{Generating Files in Obj Format}

\ketcindy\ can generate files of 3D figures in obj format. Moreover, \ketcindy\ also can call Meshlab which is a 3D viewer.

\begin{description}
\item[Examples]\mbox{}\\
\verb|Xyzax3data("","x=[-5,5]","y=[-5,5]","z=[-5,5]");|\\
\verb|fd=["p","x=4*sin(V)*cos(U)","y=4*sin(V)*sin(U)","z=4*cos(V)",|\\
\verb|     "U=[pi/2,4*pi/2]","V=[0,pi]","we"];|\\
\verb|Mkobjcmd("1",fd,[40,40,"-"]);|\\
\verb|Mkobjcrvcmd("2","ax3d",[0.05,"xy"]);|\\
\verb|Mkobjsymbcmd("x",0.2,0,[0,1,0],[5.2,0,0]);|\\
\verb|Mkobjsymbcmd("y",0.2,0,[1,0,0],[0,5.2,0]);|\\
\verb|Mkobjsymbcmd("z",0.2,0,[0,1,0],[0,0,5.2]);|\\
\verb|SetObj();|
\item[Remark]See \verb|KeTCindyreferenceE.pdf| or \verb|samples/s13meshlab| for more information.
\end{description}

% -------------- Making slide --------------

\newpage

\section{Making Slides}

\subsection{Outline}

\ketcindy\ has functions to make slides for presentation with the help of \verb|layer| environment which is defined in \verb|ketlayer.sty|.
See \verb|KeTpicStyleE.pdf| for details about \verb|layer|.

You need both a cindy file and a text file with the same header.  For simple preparation, copy \verb|template2slide.cdy| to your work folder, rename the name, for example \verb|makeslide.cdy|, double click the file and press the button \verb|title| in the screen, then \verb|makeslide.txt| will be generated.

The following chart shows the relation between them.

\begin{center}
\input{Fig/makeslideE}
\end{center}

If necessary, edit \verb|Settitle| in CindyScript editor, and press the gear mark. Open the text file, and write commands of \ketcindy\ Slide and \TeX\ as follows.

\begin{verbatim}
  title::slide0//
  main::Introduction//
  \slidepage[m]//
  new::Programming Language//
  %repeat=6,para// 
  \slidepage// 
  itemize// 
  item::Python// 
  %thin[2,-]::item::Ruby// 
  %thin[3,-]::item::Java// 
  %thin[4,-]::item::JavaScript// 
  %thin[5,-]::item::CindyScript// 
  %thin[6,-]::item::C// 
  end// 
\end{verbatim}

\begin{description}
\item[Remark]``//'' should be added to the end of all lines. Use ``||||'' when you want to write \verb|//|.
\end{description}

%\begin{center}
%\includegraphics[bb=0.00 0.00 743.00 632.00,height=60mm]{fig/slidescreen.pdf}\hspace{5mm}
%\includegraphics[bb=0.00 0.00 802.00 633.00,height=60mm]{fig/slidescript.pdf}
%\end{center}

Press the button \verb|Slide| in Cindy Screen, then \ketcindy\ will make \TeX\ file \verb|makeslide.tex|,
typeset it and displays the pdf file as follows. If there occurs an error, check the text file or the \TeX\ file.

\begin{center}
\fbox{\includegraphics[bb=0.00 0.00 542.00 385.00,height=35mm]{Fig/slidepdf1.pdf}}\hspace{5mm}%
\fbox{\includegraphics[bb=0.00 0.00 541.00 380.00,height=35mm]{Fig/slidepdf2.pdf}}\hspace{5mm}%
\fbox{\includegraphics[bb=0.00 0.00 543.00 382.00,height=35mm]{Fig/slidepdf3.pdf}}\hspace{5mm}%
\end{center}

\subsection{Commands of \ketcindy\ slide}

You can use the following commands.\\
\verb|    title::slide0 (::wallpaper)//|\\
\verb|        Rem) Put only once at the first line.|\\
\verb|    main::(main title)//|\\
\verb|    new::(page title)//|\\
\verb|    enumerate//|\\
\verb|           =\begin{enumerate}|\\
\verb|        Rem) Add the option such as [(1)] using :: .|\\
\verb|    itemize//|\\
\verb|           =\begin{itemize}|\\
\verb|    layer::{xsize}{ysize}//|\\
\verb|           =\begin{layer}{xsize}{ysize}|\\
\verb|         Rem) "layer" is an environment defined in ketlayer.sty.|\\
\verb|    item::sentence//|\\
\verb|           =\item sentence|\\
\verb|    putnote::dir{xpos}{ypos}::filename(,scale)//|\\
\verb|           =putnotedir{xpos}{ypos}{\input{fig/filename}}||\\
\verb|         Rem) "putnote" is a command defined in ketlayer.sty|\\
\verb|    end//|\\
\verb|           =\end{itemize,enumerate,layer}|\\
\verb|    ...//|\\
\verb|          To insert a blank line.|

\noindent
You can also use the following \TeX\ mcores added by \ketcindy.\\
\verb|    \slidepage,\slidepage[m]//|\\
\verb|          To display the number each page.|\\
\verb|            \slidepage[m] is used for the \verb|main| page.|\\
\verb|    \setthin{thickness}|\\
\verb|          To change the thickness of thin letters temporarily.|\\
\verb|    \inputsound, \inputmovie|\\
\verb|          To insert mp3/mp4 files.|


\begin{description}
\item[Remark]Any other \TeX\ macroes are available. Put \verb|%%| instead of \verb|%| to comment out .
\end{description}


\subsection{Display of Page step by step}

\begin{enumerate}[1)]
\item Put just after new,\\
\verb|    %repeat=number of steps//|
\item Put at the head of each line as\\
\verb|    %[2,-]::sentences|\\
\verb|           display at all steps from 2|\\
\verb|    %[-,2]::sentences|\\
\verb|           display at all steps until 2|\\
\verb|    %[1..3,5]::sentences|\\
\verb|           display at steps of 1,2,3 and 5|
\item  Use \verb|%thin| to display with thin letters.\\
\verb|    %thin::[2,-]::sentence|
\item The dencity can be changed with Setslidebody or \verb|\setthin|.
\end{enumerate}

\subsection{Making Flip Animation}

\begin{enumerate}[1)]
\item Define function \verb|Mf(s)|, the state at s.
\item Put command \verb|Setpara| in the script editor as\\ 
\verb|    Setpara(subfolder,funcitonstr(mf(s)),range,options);|\\
\verb|        options=["m/r", "Div=25"];|
\item Describe in the text file as\\
\verb|    %repeat=, para=subfolder:{0}:s{60}{10}:input(:scale)//|
\item Press buttons \verb|ParaF| and \verb|Flip|, then \verb|subfolder| will be generated.
\item Press button \verb|Slide|.
\end{enumerate}

\subsection{Making Animation}

\begin{enumerate}[1)]
\item Add the following in the script editor\\ 
\verb|    Addpackage(["[dvipdfmx]{animate}"]);|
\item Add in the second option of Setpara,\\
\verb|    "Frate=num of frame in the second,"Scale=scale,"OpA=option of animation" |
\item Press buttons \verb|ParaF| and \verb|Anime|, then \verb|subfolder| will be generated.
\item Use \verb|\input|, not layer, to display.
\end{enumerate}

\subsection{Commands to Insert a mp3/mp4 file}

To insert a mp3 or mp4 file, change the first line to\\
\verb|    title::slide0|\\
\verb|    ::\usepackage{ketmedia}|\\
\verb|    ::\usepackage[dvipdfmx]{media9}//|\vspace{2mm}

\noindent
Use \verb|\inputsound| or \verb|\inputsoundclick| for mp3 files.\\
\verb|    \inputsountclik[90]{folder/}{mp3file} %starts when the button clicked|\\
The arguments are horizontal position(default is 90) of buttons, the folder, the file name.
\vspace{2mm}

\noindent
Use \verb|\inputmovie| for mp4 files.\\
\verb|    \inputsountclik[90]{1}{0.4}{folder/}{mp4file} %starts when the button clicked|
The 2nd and 3rd arguments are width and height as the coefficiients of \verb|\linewidth|

\subsection{Changing Style}

The default styles such as size and color of letters can be changed.
See \verb|KeTCindyReferenceE,pdf| or \verb|samples/s07slides|.

\end{document}