podar@sbcs.UUCP (Sunil Podar) (04/21/85)
*** BUT MY MESSAGE CAN'T FIT IN ONE LINE!!!!!????? *** Here is a program (in pascal!!) that can be used for plotting graphs using LaTeX. The program is like a preprocessor that generates LaTeX commands to plot the graph depending on a variety of options. Right now it can handle graphs of First Quadrant with origin at (0,0), and I'll let it be known if I make any modifications in future and if there is interest, although I don't think I'll be able to get to it for atleast another month. It is fairly easy to fix the program if you want other quadrants, but not so easy to handle all quadrants in one program, & will involve a bit of hacking. That is my next indulgence. I have not extensively tested the program, but it seems to work fine on a few examples that I tried. You are welcome to modify it, use it, claim it, sell it, pass it on, or junk it. Let me know if you are plaaning to do major modifications so I don't end up duplicating work. Initially I also thought that one could plot only circles in the pic environment of LaTeX, but as I learnt more tricks, I discoverd a variety of other characters one could plot & I was quite excited about it; to share my excitement with all of you, I've added a LaTeX file at the end. I am quite sure many people have discovered it too since the idea is quite simple, but in any case I added it for people who might not have. Before you start passing any judgements on the usefulness, originality, quality of programming, etc. I should say a few things: 0. We have LaTeX version 2.06a and it is desighed for that; can't say about prior or later versions. 1. I am not a very good programmer, don't know C yet. The code is rather sloppy , particularly in my handling of strings. 2. I don't know troff at all, hence the documentation is a plain text file; my apologies for that. 3. I don't know LaTeX very well yet, so please don't laugh at some of the constructs I've used. 4. It works; (I don't quite support such attitudes in programming.) 5. Even after all the above you feel like putting me down, you are welcome but try to be a little constructive; I am very open to comments that will enhance my knowledge. 6. Its not a great program, and I am sure many of you have written similar ones to suit your own purposes, & that's what I had done. Now I have attempted to make a fairly general utility. -- Sunil Podar SUNY at Stony Brook CSNET: podar@sbcs.csnet ARPA: podar%suny-sb.csnet@csnet-relay.arpa UUCP: {allegra, hocsd, philabs, ogcvax} !sbcs!podar ------cut-here-including-this-line-----------cut-here-including-this-line-- #!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # latexgraph.doc detailed documentation on using the program. # latexgraph.p pascal program. # newchars.tex the LaTeX file about a few new plottable chars.run it # through LaTeX in order to print it. # This archive created: Sat Apr 20 17:21:55 1985 export PATH; PATH=/bin:$PATH echo shar: extracting "'latexgraph.doc'" '(17346 characters)' if test -f 'latexgraph.doc' then echo shar: over-writing existing file "'latexgraph.doc'" fi cat << \SHAR_EOF > 'latexgraph.doc' PLOTTING GRAPHS WITH LaTeX -------------------------- sunil podar (podar@sbcs.csnet) last update: Apr 14 1985 This program provides an integrated (somewhat) system to plot graphs. Latex has a fairly powerful pic environment but it lacks any direct graph environment, and this program attempts to simulate one. You must have some knowledge of LaTeX, and in particular the pic environment if there is any need to change the output of this program. Actually if you know only the pic environment, you should be able to manage. The program can produce the graph as a complete document if you desire. The idea is that even non-LaTeX users can plot graphs and only graphs and it doesn't have to be part of regular text. The program, using the options given in the parameter list, produces a LaTeX file using all known-to-work and regular LaTeX commands and the file can easily be edited if needed. So, the moral is that one can plot graphs with being quite oblivious to the fact that LaTeX is being used to plot it; of course, you have to run LaTeX on the graph to print it. Please feel free to contact me (podar@sbcs) if there are any bugs, if it doesn't do what you want and can't figure out how to do it, or would like some other features in the program. I have not tested the program extensively so I can't promise it will work if you try to stretch it to its limits. I do not have complicated error-checking or error-recovery. If you make any modifications to this program, please let me know. The program generates LaTeX commands to do the following: 1. print the X-axis vector. 2. print the Y-axis vector. 3. put little vertical bars on the X-axis at regular intervals. 4. put little horizontal bars on the Y-axis at regular intervals. 5. put numbers along those bars on both axes. 6. prints a string like "X ------>" underneath the X-axis, if you desire and a similar one along the Y-axis. 7. sets up a legend box with info about X-axis, Y-axis and the various characters plotted on the graph; controlled by a variety of options. 8. reads input data in 3-tuples (character# X-coordinate Y-coordinate), scales the data according to given scale and generates commands to plot it. If there is no data, then it simply produces the skeleton graph. some quirks, limitations, suggestions, ideas regarding the program ------------------------------------------------------------------ The program is not a very powerful program and the code is rather sloppy, but I attempt to do things right as far as possible and if not then I give pointers to how one might have to edit the output file. Some of the commands that I generate are highly dependent on the font being used, the unitlength etc., so I can only make a reasonable attempt to get things right. In order to use this program , I suggest that you print out the file produced by the program and then see what needs fixing; in most cases the fixing will be limited to changing a few coordinates of some commands. You can of course use the program to generate a dummy skeleton graph even if all you need is a few things out of the 8 steps listed above and extract out of the file the desired portion. There are some limitations in the program as of now but there are ways of still exploiting it if what you need is not what it can handle. 1. I can only handle the first quadrant, meaning everything is positive. Moreover, the origin is always (0,0). I can't handle shifted origins. If you need other quadrants, you can still get a skeleton, change the coordinates of the commands that plot numbers and vertical bars and make arrows. The constructs remain valid and only where they are put would need to be changed. 2. I try to act smart when printing numbers along the axes. If I figure that the numbers are whole numbers (xx.00) then I print integers, otherwise I print real numbers with two significant digits. You can easily edit the file if you want more or less significant digits. 3. Since Pascal is very unfriendly when it comes to handling character strings the syntax of the parameters is a bit unfriendly too. Also the max string size that I can handle is 80 chars, and if you need more than that, you can give less to the program and then edit the output file without any difficulty. I give a lot of comments at appropriate places (all begin with a % since that is a latex comment char), you can safely get rid of them in your final document. 4. What I regard as a bug in LaTeX (could pass for just a quirk), the \caption command ALWAYS prints the "Figure 2.2" in normalsize no matter what your environment fonttype is or what you specify in the caption arguement. So, to get around it I have a command that explicitely puts a caption-look-alike caption at the bottom of the figure in the specified font. If you choose to print LaTeX caption then I force a normalsize caption but if you want everything in another font then use "explicit" option on the ??caption parameter. Since LaTeX decides the figure number by itself, I ignore the "fignumber" parameter if you chose the "LaTeX" option; on the other hand I ignore the "labelname" parameter if you chose the "explicit" option. If you need things other than what the program gives you you can explicitely edit the file. 5. From my experience & personal preference, font "small" or even smaller looks nice on the graph; normalsize comes out a bit too big and looks unwieldly, specially for printing large real numbers along the Y-axis. Syntax of the parameters: ------------------------- 1. All parameters are recognized by the string of 10 characters at the beginning and exactly 10 characters -- no more -- no less. They all begin with a % sign because that is the comment character for latex. 2. When the arguement for a parameter is an integer then there MUST be atleast one blank after the parameter name and for more than one integer, again blank char is the separater. 3. When the arguement for a parameter is a string then there MUST BE NO BLANK and instead it should be a /. The string that follows the / is taken exactly as it appears starting from the next character including any blanks. All that is important is that the 11th char be a /. 4. There should be no blank lines before or in the middle until the string '%%%%%%%%%%' . That string of 10 %'s ends the list of arguements. I don't think there should be any blank lines anywhere at all. 5. The list of parameters SHOULD be the first thing in the file , that is, right on the top followed by data, if any. Without any data, you will simply get the skeleton of the graph with all things laid out. This is one way to make use of this program if you already have explicit statements for plotting the points; first get the graph skeleton, and then insert your file with latex commands that plot points at the appropriate place. 6. There are 5 parameters for plotting chars at the specified coordinates. That means with this program you can have 5 kinds of data plotted in one graph. The parameters are %plotchar1 .. %plotchar5. Each parameter has a number at the end and that is very significant. The data to be plotted must have as its first argument a number 1..5 that directly corresponds to the plotchar# defined in the parameter list. E.g. the data line 2 20 30 => put plotchar2 at (X,Y)=(20,30) on the graph. The idea is that I imagine that you will have some program that produces numbers to be plotted and you can have that program produce the 3-tuples needed for this program very easily. 7. The syntax for running the program is latexgraph <inputfile >outputfile inputfile should have , besides the parameters, only the data lines with 3 numbers on each line: integer1 Xreal2 Yreal3 integer1: range= 1..5 it is the code for the kind of character to be plotted at the specified coordinates. Xreal2 : is the X-coordinate of the point to be plotted ,a real number. Yreal3 : is the Y-coordinate of the point to be plotted ,a real number. The options are as follows: command options explanation ------- ------- ----------- %pre&post?/ yes writes the preamble & post-amble alongwith the graph. idea is to have a standalone graph i.e. a complete document. no doesn't write any preamble or post-amble. starts with \begin{figure}...... & ends with \end{figure}. %unitlngth mm real the unitlength for the graph. %font-name/ {fontname} one of the many fontnames that LaTeX provides, such as normalsize,tt,small, etc. All the printed stuff on the graph will be in the specified font.MUST put the {} around fontname. %picheight integer units this is in graph units. max graph height about 200mm or so. %piclength integer units max graph width is about 240mm.for larger than about 170mm you need to do -L on dvi-imagen, which also means you have to print this page separately, since just a page can't be rotated by latex or dvi-imagen. %Xaxisstrg/ string max char 80.for xaxis to appear in the legend box and/or in the caption. It should be kept small so as not to make the box too large. %Yaxisstrg/ string for yaxis ................. same as above. %??caption/ LaTeX produce LaTeX command for making caption. explicit make an explicit box for a fake caption-look- alike caption. see discussion above. no no caption of whatever kind. %fignumber/ string max char = 10. the number you wish to give this graph to appear on the fake-caption at bottom. This is ignored if ??caption=LaTeX. %capstring/ YX string explicit string of less than 80 characters. option YX will print the string of 'Y vs. X' where Y & X are same as the ones specified in the Xaxisstrg & Yaxisstrg above. %labelname/ {labelname} the name of label you wish to give to the figure. This is ignored if you did not choose LaTeX option on ??caption. MUST have {} around the label name. Also LaTeX doesn't like blanks in the name of a label. no no \label statement desired. %legendloc/ tr this is for the placement of the standard legend-box. tr means topright corner tl tl means topleft a little away from the y-axis. ex Xinteger Yinteger ex means explicit location of the bottom-left corner of the box in terms of the X-coordinate (Xinteger) & Y-coordinate (Yinteger). no no means no box at all. %want-X^Y^/ no no: do not want the X & Y and their arrows along respective axes. yes yes: want them. %Xratiog:r integer1 real2 g:r means graph vs. reality; i.e. to say that integer1 # of units on graph represent real2 units of reality; e.g. 10 25 means each 10 units on graph = 25 reality units. this ratio is used to translate the data from reality numbers to graph units. %Xdeltabar integer this specifies the increment used for putting vertical bars (|) on the X-axis starting from 0 and can be different from Xdeltanum (see next parameter). should be specified in graph units. %Xdeltanum integer this specifies the increment used for putting numbers along the X-axis. can be different from Xdeltabar above. Although there is no restriction, but normally one puts them under the vertical bars and perhaps alternate bars. should be specified in graph units. translated to numbers using Xratiog:r. see example below. %Yratiog:r integer real %Ydeltabar integer same story for these three as above. %Ydeltanum integer %plotchar1/ {definition of character to be plotted} no %plotchar2/ {definition of character to be plotted} no %plotchar3/ {definition of character to be plotted} no %plotchar4/ {definition of character to be plotted} no %plotchar5/ {definition of character to be plotted} no these specify the LaTeX statement for the definition of the character to be put at the coordinates, e.g. {circle*{1.0}} no: means no character with the number associated with plotchar. see discussion above. %%%%%%%%%% THIS LINE OF 10 %'s IS A MUST. IT ACTS AS THE DELIMITER OF THE ABOVE PARAMETERS. data follows after above parameters. ----------------------------------------------------------------------------- An example of an inputfile: ----------------------------------------------------------------------------- %pre&post?/yes %unitlngth 1.0 %font-name/{small} %picheight 110 %piclength 130 %Xaxisstrg/Number of Hops. %Yaxisstrg/\%age of Hops %??caption/explicit %fignumber/3-9 %capstring/Half-Length of Symmetric Intervals as \%-age of Lifetime means(40 byte packets) %labelname/{my-graph-1} %legendloc/tl %want-X^Y^/yes %Xratiog:r 20 25 %Xdeltabar 10 %Xdeltanum 20 %Yratiog:r 10 10 %Ydeltabar 10 %Ydeltanum 10 %plotchar1/{\circle*{2.0}} %plotchar2/{\circle{2.0}} %plotchar3/{\makebox(0,0){$\otimes$}} %plotchar4/no %plotchar5/no %%%%%%%%%% 1 25.0 10.0 2 53.56 20.0 3 75.0 23.6789 ------------------------------------------------------------------------------ The output produced by the above input: ------------------------------------------------------------------------------ %pre&post?/ye %unitlngth 1.00 %font-name/{small} %picheight 110 %piclength 130 %Xaxisstrg/Number of Hops. %Yaxisstrg/\%age of Hops %??caption/explicit %fignumber/3-9 %capstring/Half-Length of Symmetric Intervals as \%-age of Lifetime means(40 byte packets) %labelname/{my-graph-1} %legendloc/tl %want-X^Y^/ye %Xratiog:r 20 25.00 %Xdeltabar 10 %Xdeltanum 20 %Yratiog:r 10 10.00 %Ydeltabar 10 %Ydeltanum 10 %plotchar1/{\circle*{2.0}} %plotchar2/{\circle{2.0}} %plotchar3/{\makebox(0,0){$\otimes$}} %plotchar4/no %plotchar5/no %%%%%%%%%% \documentstyle{article} \setlength{\topmargin}{0cm} \setlength{\headheight}{1cm} \setlength{\footskip}{3cm} \setlength{\oddsidemargin}{0cm} \setlength{\textwidth}{145.00mm} \renewcommand{\thepage}{} % => no page number \begin{document} \newcommand{\xaxis}{Number of Hops. } % the literal for X-axis \newcommand{\yaxis}{\%age of Hops } % the literal for Y-axis \newcommand{\plotcharone}{\circle*{2.0}} \newcommand{\plotchartwo}{\circle{2.0}} \newcommand{\plotcharthree}{\makebox(0,0){$\otimes$}} \begin{small} \begin{figure}[p] %you might want different options here \unitlength = 1.00mm \begin{picture}(140,120)(-10,-10) \thicklines \put(0,0){\vector(1,0){130}} \put(0,0){\vector(0,1){110}} \thinlines \put(0,-9){\makebox(130,2){X \hspace{0.6em} {\raisebox{0.6ex}{\vector(1,0){8}}}}} \put(-11,48){\makebox(2,2){Y}} \put(-10,54){\vector(0,1){8}} \multiput(0,-1)(10,0){13}{\line(0,1){2}} % Add a line similar to next one if 0 for X-axis at origin desired. \put(20,-5){\makebox(0,2){25}} \put(40,-5){\makebox(0,2){50}} \put(60,-5){\makebox(0,2){75}} \put(80,-5){\makebox(0,2){100}} \put(100,-5){\makebox(0,2){125}} \put(120,-5){\makebox(0,2){150}} \multiput(-1,0)(0,10){11}{\line(1,0){2}} % Add a line similar to next one if 0 for Y-axis at origin desired. \put(-7,10){\makebox(5,0)[r]{10}} \put(-7,20){\makebox(5,0)[r]{20}} \put(-7,30){\makebox(5,0)[r]{30}} \put(-7,40){\makebox(5,0)[r]{40}} \put(-7,50){\makebox(5,0)[r]{50}} \put(-7,60){\makebox(5,0)[r]{60}} \put(-7,70){\makebox(5,0)[r]{70}} \put(-7,80){\makebox(5,0)[r]{80}} \put(-7,90){\makebox(5,0)[r]{90}} \put(-7,100){\makebox(5,0)[r]{100}} % you might have to fix the box below to get the circles right. % also you'll have to fiddle with the X & Y coord of the box to % place it right. I have made an attempt at placement. % Change the AA,BB,....,EE in the box below to whatever you want % and try to keep it short; I don't expect other changes. \put(10,88){\fbox{\shortstack[l]{ {\makebox(4,2)[lb]{\put(2,1){\plotcharone}}}: AA\\ {\makebox(4,3)[lb]{\put(2,1){\plotchartwo}}}: BB\\ {\makebox(4,3)[lb]{\put(2,1){\plotcharthree}}}: CC\\ {\makebox(4,4)[b]{X}}: \xaxis \\ {\makebox(4,2)[b]{Y}}: \yaxis }}} \put(0,-18){\makebox(130,0)[t]{ Figure 3-9 $\!$:\hspace{0.5em} Half-Length of Symmetric Intervals as \%-age of Lifetime means(40 byte packets) }} % if the caption line is longer than the graphwidth, comment out % the previous stmt and use next one. you might have to fiddle % with the width of parbox. %\put(0,-18){\makebox(130,0)[tl]{ %Figure 3-9 $\!$:\hspace{0.5em}\parbox[t]{113.00mm}{ %Half-Length of Symmetric Intervals as \%-age of Lifetime means(40 byte packets) %}}} % beginning of data \put( 20.00000, 10.00000){\plotcharone} \put( 42.84800, 20.00000){\plotchartwo} \put( 60.00000, 23.67890){\plotcharthree} % end of data \end{picture} \end{figure} \end{small} \end{document} ------------------------------------------------------------------------------ END OF DOC. SHAR_EOF if test 17346 -ne "`wc -c 'latexgraph.doc'`" then echo shar: error transmitting "'latexgraph.doc'" '(should have been 17346 characters)' fi echo shar: extracting "'latexgraph.p'" '(17194 characters)' if test -f 'latexgraph.p' then echo shar: over-writing existing file "'latexgraph.p'" fi cat << \SHAR_EOF > 'latexgraph.p' (**************************************************************************) (* This program simulates a graph environment for LaTeX. Using a list of *) (* parameters, it generates LaTeX commands to produce a complete graph. *) (* see the latexgraph.doc file for detailed documentation. *) (* It is meant only for POSITIVE GRAPHS. *) (* author: Sunil Podar (podar@sbcs.csnet) *) (* last update: Apr 14, 1985 *) (**************************************************************************) program main (input,output); type wholeline = packed array[1..79] of char; tenchar = packed array[1..10] of char; twochar = packed array[1..2] of char; var error1 :boolean; piclength,picheight,position,Xdeltabar, Ydeltabar,i,Xlegloc,Ylegloc,Xdeltanum,Ydeltanum : integer; Xaxisstrg,Yaxisstrg,commandstr,capstring,blank79, labelname,fontname : wholeline; plotchar1,plotchar2,plotchar3,plotchar4,plotchar5 : wholeline; legendloc,wantXY,captiontwo,prepost : twochar; legendXcord,legendYcord : integer; Xscalegraph,Yscalegraph,Xtimes,Ytimes : integer; string,blank10,captiontype,fignumber : tenchar; unitlngth,textwidth : real; Xorig,Yorig : integer; Xscalereal,Yscalereal,xreality, yreality, xgraph, ygraph, Xdeln, Ydeln, Xnum, Ynum : real; plotcharnum : integer; itsreal : boolean; procedure strreadline; var charac:char; i : integer; endoffile, endofline:boolean; begin i:=1; endoffile :=false; endofline:=false; commandstr:=blank79; repeat begin read(charac);write(charac); commandstr[i] := charac; i := i+1; if eof then endoffile :=true else if eoln then endofline :=true; end until (endoffile or endofline); if not endoffile then begin readln;writeln; end; end; (*strreadline*) procedure strreadword; var charac:char; i : integer; begin i:=1; string:=blank10; read(charac);write(charac); repeat begin string[i] := charac; read(charac);write(charac); i := i+1 end until ((charac = '/') or (charac = ' ') or (i > 10) or eoln); (* so I'm reading the / without assigning it to string, neat *) if (eoln) then string[i]:= charac (* a kluge, to capture the last charac when using this procedure to read *) (* the argument. normally I use it only for parameters. *) end; (*strreadword*) procedure legendread; begin legendloc := ' '; read(legendloc[1]);write(legendloc[1]); read(legendloc[2]);write(legendloc[2]); if legendloc = 'ex' then begin readln(legendXcord,legendYcord); writeln(' ',legendXcord:1,' ',legendYcord:1) end else begin readln;writeln end (* take care of the 'no', 'tr' & 'tl' options later *) end; (* legendread *) begin(* main *) for i := 1 to 10 do blank10[i] := ' '; for i := 1 to 79 do blank79[i] := ' '; captiontype := blank10; fignumber := blank10; fontname := blank79; labelname := blank79; strreadword; while string <> '%%%%%%%%%%' do begin if string = '%pre&post?' then begin readln(prepost[1],prepost[2]); writeln(prepost[1],prepost[2]) end else if string = '%unitlngth' then begin readln(unitlngth); writeln(' ',unitlngth:3:2) end else if string = '%font-name' then begin strreadline; fontname:=commandstr end else if string = '%piclength' then begin readln(piclength); writeln(' ',piclength:1) end else if string = '%picheight' then begin readln(picheight); writeln(' ',picheight:1) end else if string = '%??caption' then begin strreadword;readln; captiontype:=string; writeln end else if string = '%fignumber' then begin strreadword;readln; fignumber:=string; writeln end else if string = '%Xaxisstrg' then begin strreadline; Xaxisstrg:=commandstr end else if string = '%Yaxisstrg' then begin strreadline; Yaxisstrg:=commandstr end else if string = '%capstring' then begin strreadline; capstring:=commandstr end else if string = '%labelname' then begin strreadline; labelname:=commandstr end else if string = '%legendloc' then legendread else if string = '%Xdeltabar' then begin readln(Xdeltabar); writeln(' ',Xdeltabar:1) end else if string = '%Xdeltanum' then begin readln(Xdeltanum); writeln(' ',Xdeltanum:1) end else if string = '%Ydeltabar' then begin readln(Ydeltabar); writeln(' ',Ydeltabar:1) end else if string = '%Ydeltanum' then begin readln(Ydeltanum); writeln(' ',Ydeltanum:1) end else if string = '%Xratiog:r' then begin readln(Xscalegraph,Xscalereal); writeln(' ',Xscalegraph:1,' ',Xscalereal:7:2) end else if string = '%Yratiog:r' then begin readln(Yscalegraph,Yscalereal); writeln(' ',Yscalegraph:1,' ',Yscalereal:7:2) end else if string = '%want-X^Y^' then begin readln(wantXY[1],wantXY[2]); writeln(wantXY[1],wantXY[2]) end else if string = '%plotchar1' then begin strreadline; plotchar1:=commandstr end else if string = '%plotchar2' then begin strreadline; plotchar2:=commandstr end else if string = '%plotchar3' then begin strreadline; plotchar3:=commandstr end else if string = '%plotchar4' then begin strreadline; plotchar4:=commandstr end else if string = '%plotchar5' then begin strreadline; plotchar5:=commandstr end else begin readln;writeln; writeln('**********************************************'); writeln('error1: unknown string :\',string,'\'); writeln('**********************************************'); error1:=true end; string := blank10; strreadword end; (* while *) readln; (* this readln is to finish reading the %%%%%.. line*) writeln; (* THE FUN BEGINS HERE *) if not error1 then begin textwidth := piclength*unitlngth + 15.0; (* in mm *) if textwidth >240 then begin writeln('% *****************************************************'); writeln('% max-possible-piclength is about 240mm which will have '); writeln('% to be in Landscape. You''ll have to reduce scales.'); writeln('% *****************************************************') end else if textwidth > 170 then begin writeln ('% *****************************************************'); writeln ('% THIS TEXT IS A BIT TOO WIDE FOR VERTICAL PAPER MODE.'); writeln ('% YOU WILL HAVE TO USE "dvi-imagen -L file" TO PRINT.'); writeln ('% *****************************************************') end; if prepost = 'ye' then begin writeln('\documentstyle{article}'); writeln('\setlength{\topmargin}{0cm}'); writeln('\setlength{\headheight}{1cm}'); writeln('\setlength{\footskip}{3cm}'); writeln('\setlength{\oddsidemargin}{0cm}'); writeln('\setlength{\textwidth}{',textwidth:6:2,'mm}'); writeln; writeln('\renewcommand{\thepage}{} % => no page number '); writeln('\begin{document}'); writeln; end; (* end prepost *) writeln('\newcommand{\xaxis}{',Xaxisstrg, '} % the literal for X-axis'); writeln('\newcommand{\yaxis}{',Yaxisstrg, '} % the literal for Y-axis'); if plotchar1[1] <> 'n' then writeln('\newcommand{\plotcharone}',plotchar1); if plotchar2[1] <> 'n' then writeln('\newcommand{\plotchartwo}',plotchar2); if plotchar3[1] <> 'n' then writeln('\newcommand{\plotcharthree}',plotchar3); if plotchar4[1] <> 'n' then writeln('\newcommand{\plotcharfour}',plotchar4); if plotchar5[1] <> 'n' then writeln('\newcommand{\plotcharfive}',plotchar5); writeln; writeln('\begin',fontname); (* fontname contains the {} *) writeln('\begin{figure}[p] %you might want different options here'); (* Xorig & Yorig refer to the actual origin of the graph and not to the *) (* origin of the pic box. *) Xorig:= 0; Yorig:= 0; writeln('\unitlength = ',unitlngth:3:2,'mm'); writeln('\begin{picture}(',(piclength+10):1,',',(picheight+10):1,')(', (Xorig-10):1,',',(Yorig-10):1,')'); (* need a box of +10 on both axes to account for -10 origins & to *) (* get proper centering *) writeln; writeln('\thicklines'); writeln('\put(',Xorig:1,',0){\vector(1,0){',piclength:1,'}}'); writeln('\put(',Xorig:1,',0){\vector(0,1){',picheight:1,'}}'); writeln('\thinlines'); (*********************************************************************) (* Following statements make the arrows and the X & Y *) (*********************************************************************) if wantXY = 'ye' then (* I only read first two char of 'yes' *) begin writeln('\put(',Xorig:1,',-9){\makebox(',piclength:1, ',2){X \hspace{0.6em} {\raisebox{0.6ex}{\vector(1,0){8}}}}}'); writeln('\put(',(Xorig-11):1,',',((picheight div 2) - 7):1, '){\makebox(2,2){Y}}'); writeln('\put(',(Xorig-10):1,',',(picheight div 2 - 1):1, '){\vector(0,1){8}}'); end; (* wantXY *) (*********************************************************************) (*the following writes statements for writing numbers & bars along X-axis*) (*********************************************************************) Xtimes := piclength div Xdeltabar; writeln('\multiput(',Xorig:1,',-1)(',Xdeltabar:1,',0){', Xtimes:1,'}{\line(0,1){2}}'); (* Xdelnum is in graph units *) Xdeln := (Xscalereal*Xdeltanum) / Xscalegraph; position := Xdeltanum; Xnum:=Xdeln; if (Xnum - trunc(Xnum)) > 0 then itsreal := true; writeln ('% Add a line similar to next one if 0 for X-axis at origin desired.'); while position < piclength do begin if itsreal then writeln('\put(',position:1,',-5){\makebox(0,2){',Xnum:7:2,'}}') else writeln('\put(',position:1,',-5){\makebox(0,2){',trunc(Xnum):1,'}}'); position := position + Xdeltanum; Xnum := Xnum + Xdeln (* first number is always 0 *) end; (*********************************************************************) (*the following writes statements for writing numbers & bars along Y-axis*) (*********************************************************************) Ytimes := picheight div Ydeltabar; writeln('\multiput(',(Xorig-1):1,',0)(0,',Ydeltabar:1,'){', Ytimes:1,'}{\line(1,0){2}}'); (* Ydelnum is in graph units *) Ydeln := ( Yscalereal*Ydeltanum) / Yscalegraph; position := Ydeltanum; Ynum:=Ydeln; if (Ynum - trunc(Ynum)) > 0 then itsreal := true; writeln ('% Add a line similar to next one if 0 for Y-axis at origin desired.'); while position < picheight do begin if itsreal then writeln('\put(',(Xorig-7):1,',', position:1,'){\makebox(5,0)[r]{',Ynum:7:2,'}}') else writeln('\put(',(Xorig-7):1,',', position:1,'){\makebox(5,0)[r]{',trunc(Ynum):1,'}}'); position := position + Ydeltanum; Ynum := Ynum + Ydeln end; if legendloc <> 'no' then begin (* and it is then obviously do nothing *) if legendloc = 'tr' then begin Xlegloc:= piclength - 10 - 30; Ylegloc:= picheight - 10 - 12 end else if legendloc = 'tl' then begin Xlegloc:= Xorig + 10; Ylegloc:= picheight - 10 -12 end else begin Xlegloc := legendXcord; Ylegloc := legendYcord end; (* the - 10 in above commands is to account for the shifted origin which*) (* as of now is fixed at (-10,-10) *) writeln('% you might have to fix the box below to get the circles right.'); writeln('% also you''ll have to fiddle with the X & Y coord of the box to'); writeln('% place it right. I have made an attempt at placement.'); writeln('% Change the AA,BB,....,EE in the box below to whatever you want'); writeln('% and try to keep it short; I don''t expect other changes.'); writeln('\put(',Xlegloc:1,',',Ylegloc:1, '){\fbox{\shortstack[l]{'); if plotchar1[1] <> 'n' then writeln(' {\makebox(4,2)[lb]{\put(2,1){\plotcharone}}}: AA\\'); if plotchar2[1] <> 'n' then writeln(' {\makebox(4,3)[lb]{\put(2,1){\plotchartwo}}}: BB\\'); if plotchar3[1] <> 'n' then writeln(' {\makebox(4,3)[lb]{\put(2,1){\plotcharthree}}}: CC\\'); if plotchar4[1] <> 'n' then writeln(' {\makebox(4,3)[lb]{\put(2,1){\plotcharfour}}}: DD\\'); if plotchar5[1] <> 'n' then writeln(' {\makebox(4,3)[lb]{\put(2,1){\plotcharfive}}}: EE\\'); writeln(' {\makebox(4,4)[b]{X}}: \xaxis \\'); writeln(' {\makebox(4,2)[b]{Y}}: \yaxis'); writeln(' }}}'); end; (* not 'no' *) captiontwo[1]:=capstring[1]; captiontwo[2]:=capstring[2]; if captiontype[1] = 'e' then (* "e"xplicit , anything else other than *) (* "L" for LaTeX => no *) if captiontwo = 'YX' then begin writeln('\put(',Xorig:1,',-18){\makebox(',piclength:1,',0)[t]{'); writeln('Figure ',fignumber,'$\!$:\hspace{0.5em}'); writeln('\yaxis \hspace{0.5em} vs. \hspace{0.5em} \xaxis}}'); writeln('% if the caption line is longer than the graphwidth, comment out'); writeln('% the previous stmt and use next one. you might have to fiddle'); writeln('% with the width of parbox.'); writeln('%\put(',Xorig:1,',-18){\makebox(',piclength:1,',0)[tl]{'); writeln('%Figure ',fignumber,'$\!$:\hspace{0.5em}\parbox[t]{', (textwidth-32):6:2,'mm}{'); writeln('%\yaxis \hspace{0.5em} vs. \hspace{0.5em} \xaxis}}}') end else (* means explicit string is specified *) begin writeln('\put(',Xorig:1,',-18){\makebox(',piclength:1,',0)[t]{'); writeln('Figure ',fignumber,'$\!$:\hspace{0.5em}'); writeln(capstring); writeln('}}'); writeln('% if the caption line is longer than the graphwidth, comment out'); writeln('% the previous stmt and use next one. you might have to fiddle'); writeln('% with the width of parbox.'); writeln('%\put(',Xorig:1,',-18){\makebox(',piclength:1,',0)[tl]{'); writeln('%Figure ',fignumber,'$\!$:\hspace{0.5em}\parbox[t]{', (textwidth-32):6:2,'mm}{'); writeln('%',capstring); writeln('%}}}') end; writeln('% beginning of data'); (* the following statements reads the stdin and simply *) (* copies them to stdout *) (* while not eof do *) (* begin *) (* commandstr:=blank79; *) (* strreadline; *) (* strreadline also does the writing *) (* end; *) while not eof do begin readln(plotcharnum,xreality,yreality); xgraph := (xreality*Xscalegraph)/Xscalereal; ygraph := (yreality*Yscalegraph)/Yscalereal; if plotcharnum = 1 then writeln('\put(',xgraph:10:5,',',ygraph:10:5,'){\plotcharone}') else if plotcharnum = 2 then writeln('\put(',xgraph:10:5,',',ygraph:10:5,'){\plotchartwo}') else if plotcharnum = 3 then writeln('\put(',xgraph:10:5,',',ygraph:10:5,'){\plotcharthree}') else if plotcharnum = 4 then writeln('\put(',xgraph:10:5,',',ygraph:10:5,'){\plotcharfour}') else if plotcharnum = 5 then writeln('\put(',xgraph:10:5,',',ygraph:10:5,'){\plotcharfive}') end; writeln('% end of data'); writeln('\end{picture}'); if captiontype[1] = 'L' then (* "L"aTeX . if it is not = 'L' or 'e'*) (* then interpreted as 'no' *) begin writeln('% if the caption line is longer than the graphwidth,use a'); writeln('% \parbox[t]{...mm}{.........} like statement for the argument'); writeln('% with suitable args for parbox to get the whole thing centered.'); if captiontwo = 'YX' then begin writeln('% You might want to do something to the [] in', 'following caption statement'); writeln('\caption[]{\normalsize \yaxis vs. \xaxis }') end else begin writeln('\caption{\normalsize '); writeln(capstring); writeln('}') end; if labelname[1] = '{' then (* anything else => 'no' *) writeln('\label',labelname) (* labelname contains the {} *) end; writeln('\end{figure}'); writeln; (* a blank line is supposedly needed before \end{fontname} *) (* so says the latex manual *) writeln('\end',fontname); (* fontname contains the {} *) writeln; if prepost = 'ye' then writeln('\end{document}'); end (* not error1 *) end. SHAR_EOF if test 17194 -ne "`wc -c 'latexgraph.p'`" then echo shar: error transmitting "'latexgraph.p'" '(should have been 17194 characters)' fi echo shar: extracting "'newchars.tex'" '(5086 characters)' if test -f 'newchars.tex' then echo shar: over-writing existing file "'newchars.tex'" fi cat << \SHAR_EOF > 'newchars.tex' \documentstyle{report} \setlength{\topmargin}{.25in} \setlength{\oddsidemargin}{0in} % needs negative value \setlength{\headheight}{.75in} \setlength{\headsep}{.5in} %\setlength{\footheight}{1in} %dont need them for qms, but %\setlength{\footskip}{1.5in} %for imagen, yes. \setlength{\textheight}{8in} \setlength{\textwidth}{5.5in} \setlength{\marginparwidth}{0in} \setlength{\marginparsep}{0in} \setlength{\marginparpush}{0in} \renewcommand{\baselinestretch}{1.5} % for kind of double spacing \begin{document} \newcommand{\circlems}{\circle{1.0}} \newcommand{\circlescs}{\circle{2.0}} \newcommand{\circlecs}{\circle*{1.0}} \setlength{\unitlength}{1mm} \section*{A Variety Of Characters For Latex} {\raggedleft Sunil Podar (podar@sbcs)} \medskip This document contains my experiments and their results at discovering new characters that can be plotted in the pic environment of LaTeX. My main motivation has been for plotting points on graphs but certainly the characters listed below and their construction is not limited to just graphs. These are in addition to the standard \verb+\circle+ and \verb+\circle*+ characters. Since for other characters one doesn't have explicit control over the size, one has to play around with the fonttypes, sizes, etc. and quite interestingly one can virtually get anything, or close to anything, desired. Somewhere hidden in THE manual is the important bit of information that the macros \verb+\makebox & \framebox+ are available outside the pic environment \& so is \verb+\shortstack+. \medskip The essential idea is using a \verb+\makebox(0,0){.........}+ so that the \verb+\put+ statement will put the specified box "right on the dot". The actual arguements for the box size might vary depending on document pointsize, unitlength, etc., particularly when it comes to centering circles in boxes. Using such a setup of boxes of size (0,0), one has a whole new range of mathematical symbols available; of course, the useful ones are the symmetric symbols. Some of the other possible candidates among the math symbols: \verb+\times, \ast, \star, \oplus, \Diamond, \bigoplus,+ etc. See pages 49-51 of THE manual. One interesting feature I discoverd is that one can use framebox of appropiate size around any object or no object at all. Also it seems not all the fonts can be used for characters since the characters are not necessarily centered in their own little ``font-boxes'' (I don't know what the technical term is, perhaps raster ); e.g. I tried the character {\tt +} in the tt font and it is a bit off-center; same story with the {\tt *}. Obviously the {\it italic} font is out of the question. \medskip The following are with all with unitlength = 1mm. Also they are all set in 10pt size, so other sizes will produce correspondingly bigger characters, I think. The characters seem to not get centered properly, but that is because they are getting lined up with the bottom of the line. I have tried them all in actual graphs and they all appear exactly on the coordinates specified. \newpage \medskip \begin{tabular}{@{}cl} \underline{\bf character} & \underline{\bf LaTeX command.}\\[2ex] {\makebox(0,0){$\bigotimes$}} & \verb+{\makebox(0,0){$\bigotimes$}}+ \\ {\makebox(0,0){\LARGE $\otimes$}} & \verb+{\makebox(0,0){\LARGE $\otimes$}}+ \\ {\makebox(0,0){\large $\otimes$}} & \verb+{\makebox(0,0){\large $\otimes$}}+\\ {\makebox(0,0){$\textstyle \otimes$}} & \verb+{\makebox(0,0){$\textstyle \otimes$}}+ \\ {\makebox(0,0){$\scriptstyle \otimes$}} & \verb+{\makebox(0,0){$\scriptstyle \otimes$}}+ \\ {\makebox(0,0){$\scriptscriptstyle \otimes$}} & \verb+{\makebox(0,0){$\scriptscriptstyle \otimes$}}+ \\ {\makebox(0,0){\framebox(1.5,1.5){}}} & \verb+{\makebox(0,0){\framebox(1.5,1.5){}}}+ \\ {\makebox(0,0){\framebox(2,2){$+$}}} & \verb={\makebox(0,0){\framebox(2,2){$+$}}}= \\ {\makebox(0,0){\framebox(2,2)[lb]{\put(1,1){\circlecs}}}} & \verb+{\makebox(0,0){\framebox(2,2)[lb]{\put(1,1){\circlecs}}}}+ \\ {\makebox(0,0){\framebox(1.5,1.5){.}}} & \verb+{\makebox(0,0){\framebox(1.5,1.5){.}}}+ \\ {\makebox(0,0){\framebox(1.5,1.5){\Large .}}} & \verb+{\makebox(0,0){\framebox(1.5,1.5){\Large .}}}+ \\ {\makebox(0,0){$\bigodot$}} & \verb+{\makebox(0,0){$\bigodot$}}+ \\ {\makebox(0,0){\LARGE $\odot$}} & \verb+{\makebox(0,0){\LARGE $\odot$}}+ \\ {\makebox(0,0){\large $\odot$}} & \verb+{\makebox(0,0){\large $\odot$}}+\\ {\makebox(0,0){$\textstyle \odot$}} & \verb+{\makebox(0,0){$\textstyle \odot$}}+ \\ {\makebox(0,0){$\scriptstyle \odot$}} & \verb+{\makebox(0,0){$\scriptstyle \odot$}}+ \\ {\makebox(0,0){$\scriptscriptstyle \odot$}} & \verb+{\makebox(0,0){$\scriptscriptstyle \odot$}}+ \\ {\makebox(0,0){\LARGE $\heartsuit$}} & \verb+{\makebox(0,0){\LARGE $\heartsuit$}}+ \\[1ex] {\makebox(0,0){$\textstyle \oplus$}} & \verb+{\makebox(0,0){$\textstyle \oplus$}}+ \\ {\makebox(0,0){$\textstyle \star$}} & \verb+{\makebox(0,0){$\textstyle \star$}}+ \\ {\makebox(0,0){\rule{2mm}{2mm}}} & \verb+{\makebox(0,0){\rule{2mm}{2mm}}}+ \\ & \end{tabular} \end{document} SHAR_EOF if test 5086 -ne "`wc -c 'newchars.tex'`" then echo shar: error transmitting "'newchars.tex'" '(should have been 5086 characters)' fi # End of shell archive exit 0