The Blatexpr
Unix shell and the programs Batexpr2
and
Blatexprs
are provided in order to help inserting Scilab graphics
in LATEX.
Taking the previous file foo.ps and typing the following statement under a Unix shell :
Blatexpr 1.0 1.0 foo.pscreates two files
foo.epsf
and foo.tex
. The original
Postscript file is left unchanged.
To include the figure in a LATEX document you should insert the following
LATEX code in your LATEX document :
\input foo.tex \dessin{The caption of your picture}{The-label}
You can also see your figure by using the Postscript
previewer ghostview
.
The program Blatexprs
does the same thing: it is used to insert
a set of Postscript figures in one LATEXpicture.
In the following example, we begin by using the Postscript driver Pos and then initialize successively 4 Postscript files fig1.ps, ..., fig4.ps for 4 different plots and at the end return to the driver Rec (X11 driver with record).
-->//multiple Postscript files for Latex -->driver('Pos') -->t=%pi*(-10:10)/10; -->plot3d1(t,t,sin(t)'*cos(t),35,45,'X@Y@Z',[2,2,4]); -->xend() -->contour(1:5,1:10,rand(5,10),5); -->xend() -->champ(1:10,1:10,rand(10,10),rand(10,10)); -->xend() -->t=%pi*(-10:10)/10; -->deff('[z]=surf(x,y)','z=sin(x)*cos(y)'); -->rect=[-%pi,%pi,-%pi,%pi,-5,1]; -->z=feval(t,t,surf); -->contour(t,t,z,10,35,45,'X@Y@Z',[1,1,0],rect,-5); -->plot3d(t,t,z,35,45,'X@Y@Z',[2,1,3],rect); -->title=['plot3d and contour ']; -->xtitle(title,' ',' '); -->xend() -->driver('Rec')
Then we execute the command :
Blatexprs multi fig1.ps fig2.ps fig3.ps fig4.ps
and we get 2 files multi.tex and multi.ps and you can include the result in a LATEX source file by :
\input multi.tex \dessin{The caption of your picture}{The-label}
Note that the second line dessin... is absolutely necessary and you have of course to give the absolute path for the input file if you are working in another directory (see below). The file multi.tex is only the definition of the command dessin with 2 parameters : the caption and the label; the command dessin can be used with one or two empty arguments `` `` if you want to avoid the caption or the label.
The Postscipt files are inserted in LATEX with the help of the
\special
command and with a syntax that works with the
dvips
program.
The program Blatexpr2
is used when you want two pictures side
by side.
Blatexpr2 Fileres file1.ps file2.ps
It is sometimes convenient to have a main LATEX document in a directory
and to store all the figures in a subdirectory. The proper way to
insert a picture file in the main document, when the picture
is stored in the subdirectory figures
, is the following :
\def\Figdir{figures/} % My figures are in the {\tt figures/ } subdirectory. \input{figures/fig.tex} \dessin{The caption of you picture}{The-label}
The declaration \def\Figdir{figures/}
is used twice, first to
find the file fig.tex (when you use latex
), and
second to produce a correct pathname for the
special
LATEX command found in fig.tex
. (used at
dvips level).
-WARNING : the default driver is Rec, i.e. all the graphic commands are recorded, one record corresponding to one window. The xbasc() command erases the plot on the active window and all the records corresponding to this window. The clear button has the same effect; the xclear command erases the plot but the record is preserved. So you almost never need to use the xbasc() or clear commands. If you use such a command and if you re-do a plot you may have a surprising result (if you forget that the environment is wiped out); the scale only is preserved and so you may have the ``window-plot'' and the ``paper-plot'' completely different.