/* * $Id: epslatex.trm,v 1.1.2.4 2002/01/26 19:05:34 lhecking Exp $ */ /* GNUPLOT - epslatex.trm */ /*[ * Copyright 2000 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This terminal driver supports: * epslatex */ /* Written by Gregor Thalhammer * you'll find a lot of similarities with the pslatex, postscript and pstricks terminal drivers */ #include "driver.h" #ifdef TERM_REGISTER register_term(epslatex) #endif #ifdef TERM_PROTO TERM_PUBLIC void EPSL_options __PROTO((void)); TERM_PUBLIC void EPSL_init __PROTO((void)); TERM_PUBLIC void EPSL_graphics __PROTO((void)); TERM_PUBLIC void EPSL_text __PROTO((void)); TERM_PUBLIC void EPSL_reset __PROTO((void)); TERM_PUBLIC void EPSL_linetype __PROTO((int linetype)); TERM_PUBLIC void EPSL_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void EPSL_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void EPSL_arrow __PROTO((unsigned int xstart, unsigned int ystart, unsigned int xend, unsigned int yend, TBOOLEAN head)); TERM_PUBLIC void EPSL_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int EPSL_text_angle __PROTO((int ang)); TERM_PUBLIC int EPSL_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void EPSL_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC int EPSL_set_font __PROTO((char *font)); TERM_PUBLIC void EPSL_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height)); TERM_PUBLIC void EPSL_linewidth __PROTO((double linewidth)); TERM_PUBLIC void EPSL_pointsize __PROTO((double ptsize)); #ifdef PM3D /* Not needed --- PS terminal version reused: TERM_PUBLIC int EPSL_make_palette __PROTO((t_sm_palette *)); TERM_PUBLIC void EPSL_previous_palette __PROTO((void)); TERM_PUBLIC void EPSL_set_color __PROTO((double)); */ TERM_PUBLIC void EPSL_filled_polygon __PROTO((int, gpiPoint *)); #endif #define EPSL_SC (50) /* scale is 1pt = 10 units */ /* changed to 50, but gs now renders terribly slowly to display (x11alpha) !! */ #define EPSL_POINT_TYPES 8 /* never used! */ #define EPSL_XOFF 72 /* page offset in pts */ #define EPSL_YOFF 72 #define EPSL_XMAX (5*72*EPSL_SC) /* default plot size 5*3 inch */ #define EPSL_YMAX (3*72*EPSL_SC) #define EPSL_XLAST (EPSL_XMAX - 1) #define EPSL_YLAST (EPSL_YMAX - 1) #define EPSL_VTIC (6.0*EPSL_SC) #define EPSL_HTIC (6.0*EPSL_SC) #define EPSL_POINTSIZE (2.0*EPSL_SC) #define EPSL_LW (0.4*EPSL_SC) /* linewidth = 0.4 pts */ #define EPSL_VCHAR (11*EPSL_SC) /* default is 11 point characters */ #define EPSL_HCHAR (11*EPSL_SC*5/10) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #define EPSL_FLUSH_PATH \ if (EPSL_path_count) {fputs("Gpstroke\n",gpoutfile); EPSL_path_count = 0; EPSL_relative_ok = FALSE;} /* From version.c */ extern char gnuplot_version[]; extern char gnuplot_patchlevel[]; static char EPSL_font[MAX_ID_LEN + 1] = "default"; /* name of font */ static int EPSL_fontsize = 11; /* size of font in pts */ static TBOOLEAN EPSL_color = FALSE; /* don't use colors */ static TBOOLEAN EPSL_solid = FALSE; /* use solid lines */ static int EPSL_path_count = 0; /* count of lines in path */ static int EPSL_ang = 0; /* text angle */ static enum JUSTIFY EPSL_justify = LEFT; /* text is flush left */ /* static int x = 0; */ /* for testing */ /* char GPFAR * GPFAR EPSL_header[] = {"(prolog.ps) run\n", NULL}; */ char GPFAR *GPFAR EPSL_header[] = { " /hpt hpt_ def \n", " /vpt vpt_ def \n", " /Gppointsize_ 1 def \n", " /Gplinewidth_ 1 def \n", " \n", " /ArrowDict 25 dict def \n", " \n", " /M /moveto load def \n", " /L /lineto load def \n", " /R /rmoveto load def \n", " /V /rlineto load def \n", " /ED { exch def} bind def \n", " \n", " /Atan {/atan load stopped {pop pop 0} if } def \n", " /Div {dup 0 eq { pop } { div } ifelse } def \n", " /Pyth {dup mul exch dup mul add sqrt} def \n", " \n", " %Sizes \n", " /Gpsetlinewidth \n", " { \n", " dup \n", " % /Gplinewidth_ ED %save \n", " Gplinewidth mul setlinewidth \n", " } def \n", " \n", " /Gpsetpointsize \n", " { \n", " dup \n", " /Gppointsize_ ED %save \n", " dup \n", " vpt_ mul /vpt ED \n", " hpt_ mul /hpt ED \n", " } def \n", " \n", " %Color \n", " /SetHsbColor { Color {sethsbcolor} {pop pop pop} ifelse } def \n", " /SetCmykColor { Color {setcmykcolor} {pop pop pop pop} ifelse } def \n", " /SimpleSetColor {6 div 1 1 SetHsbColor} def \n", " /Black {0 0 0 0 SetCmykColor} def \n", " /Red {0 SimpleSetColor} def \n", " /Blue {1 1 0 0 SetCmykColor} def \n", " /Cyan {1 0 0 0 SetCmykColor} def \n", " /Magenta {0 1 0 0 SetCmykColor} def \n", " \n", " %Stroking \n", " /PathLength@ % z = z + sqrt{(x-xlast)^2 + (y-ylast)^2} \n", " { \n", " /z \n", " z \n", " y ylast sub \n", " x xlast sub \n", " Pyth \n", " add \n", " def \n", " /ylast y def \n", " /xlast x def \n", " } def \n", " \n", " /PathLength \n", " { \n", " flattenpath \n", " /z 0 def \n", " { %move \n", " /ystart ED \n", " /xstart ED \n", " /xlast xstart def \n", " /ylast ystart def \n", " } \n", " { %line \n", " /y ED \n", " /x ED \n", " PathLength@ \n", " } \n", " { %curve \n", " } \n", " { %close \n", " /x xstart def \n", " /y ystart def \n", " PathLength@ \n", " } \n", " /pathforall load \n", " stopped {pop pop pop pop} if \n", " z \n", " } def \n", " \n", " %dotsep DotLine \n", " /DotLine \n", " { \n", " PathLength /b ED \n", " /z ED \n", " /y currentlinewidth def \n", " /z y z add def \n", " [ 0 b b z Div round Div dup 0 le { pop 1 } if] 0 setdash \n", " 1 setlinecap \n", " } def \n", " \n", " /DashLine \n", " { \n", " PathLength /b ED \n", " /x ED \n", " /y ED \n", " /z y x add def \n", " b y sub z Div round z mul y add b exch Div \n", " dup \n", " y mul /y ED \n", " x mul /x ED \n", " x 0 gt y 0 gt and \n", " { [ y x ] 0 } \n", " { [ 1 0 ] 0 } \n", " ifelse \n", " setdash \n", " } def \n", " \n", " /DashLineTwo \n", " { \n", " PathLength /b ED \n", " /u ED \n", " /v ED \n", " /x ED \n", " /y ED \n", " /z y x add u add v add def \n", " b y sub z Div round z mul y add b exch Div \n", " dup \n", " y mul /y ED \n", " x mul /x ED \n", " x 0 gt y 0 gt and \n", " { [ y x v u] 0 } \n", " { [ 1 0 ] 0 } \n", " ifelse \n", " setdash \n", " } def \n", " \n", " \n", " /DotLineStroke \n", " { \n", " gsave \n", " Dashed {currentlinewidth 2 mul DotLine} if \n", " stroke \n", " grestore \n", " } def \n", " \n", " /SolidLineStroke \n", " { \n", " gsave \n", " [] 0 setdash \n", " stroke \n", " grestore \n", " } def \n", " \n", " /DashLineStroke \n", " { \n", " gsave \n", " Dashed {Gplinewidth 8 mul Gplinewidth 5 mul DashLine} if \n", " stroke \n", " grestore \n", " } def \n", " \n", " /DashDotLineStroke \n", " { \n", " gsave \n", " Dashed {Gplinewidth 8 mul Gplinewidth 5 mul 0 Gplinewidth 5 mul DashLineTwo} if \n", " stroke \n", " grestore \n", " } def \n", " \n", " /DashShortLineStroke \n", " { \n", " gsave \n", " Dashed {Gplinewidth 4 mul dup DashLine} if \n", " stroke \n", " grestore \n", " } def \n", " \n", " /ArrowHead \n", " { \n", " currentlinewidth mul add dup 2 div /w ED \n", " mul dup /h ED \n", " mul /a ED \n", " w neg h moveto \n", " 0 0 L \n", " w h L \n", " w neg a neg rlineto \n", " gsave fill grestore \n", " } def \n", " \n", " %/DrawArrowHead {1 dup scale 0.2 1.4 50 3 ArrowHead} def \n", " %%%%% \n", " %inset length dim num \n", " %arrowwidth = dim + num*linewidth \n", " %arrowlength = length*arrowwidth \n", " %arrowinset = width * inset \n", " \n", " /DrawArrowHead {0.2 1.4 Gplinewidth 3 mul 4 ArrowHead} def \n", " \n", " /Arrow \n", " { \n", " currentpoint \n", " 4 2 roll \n", " ArrowDict \n", " begin \n", " /@mtrx matrix currentmatrix def \n", " gsave \n", " 2 copy translate \n", " 2 index sub neg exch \n", " 3 index sub exch Atan \n", " rotate \n", " newpath \n", " DrawArrowHead \n", " @mtrx setmatrix \n", " currentpoint \n", " grestore \n", " end %ArrowDicht \n", " lineto \n", " Gpstroke \n", " } def \n", " \n", " %axis \n", " /LTa \n", " { \n", " Gpstroke \n", " newpath \n", " 0 setgray \n", " /Gpstroke {DotLineStroke newpath} def \n", " } def \n", " \n", " %border \n", " /LTb \n", " { \n", " Gpstroke \n", " newpath \n", " 0 setgray \n", " /Gpstroke {SolidLineStroke newpath} def \n", " } def \n", " \n", " /LT0 \n", " { \n", " Gpstroke \n", " newpath \n", " Red \n", " /Gpstroke {SolidLineStroke newpath} def \n", " } def \n", " \n", " /LT1 \n", " { \n", " Gpstroke \n", " newpath \n", " Blue \n", " /Gpstroke {DashLineStroke newpath} def \n", " } def \n", " \n", " /LT2 \n", " { \n", " Gpstroke \n", " newpath \n", " Cyan \n", " /Gpstroke {DashShortLineStroke newpath} def \n", " } def \n", " \n", " /LT3 \n", " { \n", " Gpstroke \n", " newpath \n", " Magenta \n", " /Gpstroke {DashDotLineStroke newpath} def \n", " } def \n", " \n", " /Pnt \n", " { \n", " gsave \n", " [] 0 setdash \n", " 1 setlinecap \n", " Gplinewidth Gppointsize_ mul setlinewidth \n", " M \n", " 0 0 V \n", " stroke \n", " grestore \n", " } def \n", " \n", " /DiaPath \n", " { \n", " [] 0 setdash \n", " Gplinewidth setlinewidth \n", " 2 copy \n", " newpath \n", " vpt add moveto \n", " hpt neg vpt neg rlineto \n", " hpt vpt neg rlineto \n", " hpt vpt rlineto \n", " hpt neg vpt rlineto \n", " closepath \n", " } def \n", " \n", " /Dia \n", " { \n", " gsave \n", " DiaPath \n", " stroke \n", " grestore \n", " } def \n", " \n", " /DaF \n", " { \n", " gsave \n", " DiaPath \n", " fill \n", " grestore \n", " } def \n", " \n", " /Crc \n", " { \n", " gsave \n", " [] 0 setdash \n", " Gplinewidth setlinewidth \n", " newpath \n", " vpt 0.85 mul 0 360 arc \n", " closepath \n", " stroke \n", " grestore \n", " } def \n", " \n", " \n", " /Crs \n", " { \n", " gsave \n", " [] 0 setdash \n", " Gplinewidth setlinewidth \n", " 0 setlinecap \n", " newpath \n", " vpt sub \n", " moveto \n", " 0 vpt 2 mul rlineto \n", " hpt vpt neg rmoveto \n", " hpt 2 mul neg 0 rlineto \n", " stroke \n", " grestore \n", " } def \n", " \n", " /CrX \n", " { \n", " gsave \n", " translate \n", " 45 rotate \n", " 0 0 Crs \n", " grestore \n", " } def \n", " \n", " /CcF \n", " { \n", " gsave \n", " [] 0 setdash \n", " Gplinewidth setlinewidth \n", " newpath \n", " vpt 0.85 mul 0 360 arc \n", " closepath \n", " fill \n", " grestore \n", " } def \n", " \n", " /Box \n", " { \n", " gsave \n", " translate \n", " 45 rotate \n", " 0 0 DiaPath \n", " stroke \n", " grestore \n", " } def \n", " \n", " /BxF \n", " { \n", " gsave \n", " translate \n", " 45 rotate \n", " 0 0 DiaPath \n", " fill \n", " grestore \n", " } def \n", " \n", " /Gpstroke {stroke} def \n", " 1 setlinecap \n", " 1 setlinejoin \n", NULL }; static int EPSL_pen_x, EPSL_pen_y; static int EPSL_taken; static int EPSL_linetype_last; static TBOOLEAN EPSL_relative_ok; static char *EPSL_texfilename = NULL; static FILE *EPSL_texfile; TERM_PUBLIC void EPSL_options() { if (!END_OF_COMMAND) { /* set all options to their default values */ if (almost_equals(c_token, "d$efault")) { EPSL_color = FALSE; EPSL_solid = FALSE; strcpy(EPSL_font, "default"); EPSL_fontsize = 11; term->v_char = (unsigned int) (EPSL_fontsize * EPSL_SC); term->h_char = (unsigned int) (EPSL_fontsize * EPSL_SC * 5 / 10); c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "m$onochrome")) { EPSL_color = FALSE; c_token++; } else if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) { EPSL_color = TRUE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "so$lid")) { EPSL_solid = TRUE; c_token++; } else if (almost_equals(c_token, "da$shed")) { EPSL_solid = FALSE; c_token++; } } if (!END_OF_COMMAND && isstring(c_token)) { quote_str(EPSL_font, c_token, MAX_ID_LEN); c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; EPSL_fontsize = (int) real(const_express(&a)); term->v_char = (unsigned int) (EPSL_fontsize * EPSL_SC); term->h_char = (unsigned int) (EPSL_fontsize * EPSL_SC * 5 / 10); } sprintf(default_font, "%s,%d", EPSL_font, EPSL_fontsize); /* 'default_font' declared in set.c */ sprintf(term_options, "%s %s \"%s\" %d", EPSL_color ? "color" : "monochrome", EPSL_solid ? "solid" : "dashed", EPSL_font, EPSL_fontsize); } /* the init fn for the epslatex driver */ TERM_PUBLIC void EPSL_init() { char *dotIndex=NULL; char *name; /* Why is EPSL_header global, and psi1, psi2 not? */ static char GPFAR psi1[] = "%%%%Creator: gnuplot %s patchlevel %s\n\ %%%%CreationDate: %s"; static char GPFAR psi2[] = "%%%%EndComments\n\ /Gpdict 100 dict def\n\ Gpdict begin\n\ /Color %s def\n\ /Dashed %s def\n\ /Gplinewidth %.3f def\n\ /hpt_ %.3f def\n\ /vpt_ %.3f def\n"; time_t now; unsigned int xmin_t, ymin_t, xmax_t, ymax_t; int i; term->xmax = EPSL_XMAX; term->ymax = EPSL_YMAX; xmin_t = EPSL_XMAX * xoffset / (EPSL_SC); xmax_t = EPSL_XMAX * (xsize + xoffset) / (EPSL_SC); ymin_t = EPSL_YMAX * yoffset / (EPSL_SC); ymax_t = EPSL_YMAX * (yoffset + ysize) / (EPSL_SC); fputs("%%!PS-Adobe-3.0 EPSF-3.0\n", gpoutfile); if (outstr) fprintf(gpoutfile, "%%%%Title: (%s)\n", outstr); time(&now); fprintf(gpoutfile, psi1, gnuplot_version, gnuplot_patchlevel, asctime(localtime(&now))); fprintf(gpoutfile, "%%%%BoundingBox: %d %d %d %d\n", EPSL_XOFF + xmin_t, EPSL_XOFF + ymin_t, EPSL_XOFF + xmax_t, EPSL_YOFF + ymax_t); fprintf(gpoutfile, psi2, EPSL_color ? "true" : "false", EPSL_solid ? "false" : "true", (double) EPSL_LW, (double) EPSL_POINTSIZE, (double) EPSL_POINTSIZE); for (i = 0; EPSL_header[i] != NULL; i++) fprintf(gpoutfile, "%s", EPSL_header[i]); fputs("end\n%%%%EndProlog\n", gpoutfile); EPSL_texfile = NULL; if (outstr && (dotIndex = strrchr(outstr, '.'))) { /* assume file name is ending in ".eps" */ if (EPSL_texfilename) free(EPSL_texfilename); EPSL_texfilename = gp_alloc(dotIndex - outstr + 5, "epslatex texfilename"); if (EPSL_texfilename) { /* including . */ safe_strncpy(EPSL_texfilename, outstr, dotIndex - outstr + 2); strcpy(EPSL_texfilename + (dotIndex - outstr) + 1, "tex"); if ((EPSL_texfile = fopen(EPSL_texfilename, "w")) == (FILE *) NULL) { fprintf(stderr, "Cannot open tex file %s for output\n", EPSL_texfilename); } } else { fprintf(stderr, "Cannot make LaTeX file name from %s\nTurning off LaTeX output\n", outstr); } } if (EPSL_texfile) { name = gp_alloc(dotIndex - outstr + 1, "epslatex temp filename"); safe_strncpy(name, outstr, dotIndex - outstr + 1); name[dotIndex - outstr] = 0; fprintf(EPSL_texfile, "%%GNUPLOT: LaTeX picture with Postscript\n\ \\begin{picture}(0,0)%%\n\ \\includegraphics{%s}%%\n\ \\end{picture}%%\n\ \\setlength{\\unitlength}{%.4fbp}%%\n", name, 1.0 / EPSL_SC); } #ifdef PM3D /* to optimize output for postscript terminals family */ postscript_gpoutfile = gpoutfile; #endif } TERM_PUBLIC void EPSL_graphics() { static char GPFAR psg1[] = "0 setgray\nnewpath\n"; struct termentry *t = term; fprintf(gpoutfile, "\ Gpdict begin\ngsave\n\ %d %d translate\n\ %.4f %.4f scale\n\ %s", EPSL_XOFF, EPSL_YOFF, 1.0 / EPSL_SC, 1.0 / EPSL_SC, psg1); EPSL_pointsize(pointsize); EPSL_linewidth(1.0); EPSL_path_count = 0; EPSL_relative_ok = FALSE; EPSL_pen_x = EPSL_pen_y = -4000; EPSL_taken = 0; EPSL_linetype_last = -1; if (EPSL_texfile) fprintf(EPSL_texfile, "\\begin{picture}(%d,%d)(0,0)%%\n", (int) (xsize * t->xmax), (int) (ysize * t->ymax)); } TERM_PUBLIC void EPSL_text() { EPSL_FLUSH_PATH; fputs("grestore\nend\nshowpage\n%%%%EOF\n", gpoutfile); if (EPSL_texfile) { fputs("\\end{picture}%\n\\endinput\n", EPSL_texfile); } } TERM_PUBLIC void EPSL_reset() { if (EPSL_texfile) { fclose(EPSL_texfile); EPSL_texfile = NULL; } } TERM_PUBLIC void EPSL_linetype(linetype) int linetype; { EPSL_FLUSH_PATH; linetype = (linetype % 4) + 2; if (linetype < 0) linetype = 0; EPSL_relative_ok = FALSE; #if 0 if (EPSL_linetype_last == linetype) return; #endif EPSL_linetype_last = linetype; fprintf(gpoutfile, "LT%c\n", "ba0123"[linetype]); EPSL_path_count = 0; } TERM_PUBLIC void EPSL_linewidth(linewidth) double linewidth; { EPSL_FLUSH_PATH; fprintf(gpoutfile, "%.3f Gpsetlinewidth\n", linewidth); } TERM_PUBLIC void EPSL_pointsize(ptsize) double ptsize; { fprintf(gpoutfile, "%.3f Gpsetpointsize\n", ptsize); } TERM_PUBLIC void EPSL_move(x, y) unsigned int x, y; { int dx, dy; /* Make this semi-dynamic and independent of architecture */ char abso[5 + 2 * INT_STR_LEN], rel[5 + 2 * INT_STR_LEN]; /*if (EPSL_path_count) {EPSL_FLUSH_PATH}; */ EPSL_FLUSH_PATH; dx = x - EPSL_pen_x; dy = y - EPSL_pen_y; /* can't cancel all null moves--need a move after stroke'ing */ if (dx == 0 && dy == 0 && EPSL_relative_ok) return; sprintf(abso, "%d %d M\n", x, y); sprintf(rel, "%d %d R\n", dx, dy); if (strlen(rel) < strlen(abso) && EPSL_relative_ok) { fputs(rel, gpoutfile); EPSL_taken++; } else fputs(abso, gpoutfile); EPSL_relative_ok = TRUE; EPSL_path_count += 1; EPSL_pen_x = x; EPSL_pen_y = y; } TERM_PUBLIC void EPSL_vector(x, y) unsigned int x, y; { int dx, dy; char abso[5 + 2 * INT_STR_LEN], rel[5 + 2 * INT_STR_LEN]; dx = x - EPSL_pen_x; dy = y - EPSL_pen_y; if (dx == 0 && dy == 0) return; sprintf(abso, "%d %d L\n", x, y); sprintf(rel, "%d %d V\n", dx, dy); if (strlen(rel) < strlen(abso) && EPSL_relative_ok) { fputs(rel, gpoutfile); EPSL_taken++; } else fputs(abso, gpoutfile); EPSL_relative_ok = TRUE; EPSL_path_count += 1; EPSL_pen_x = x; EPSL_pen_y = y; /* if (ps_path_count >= 400) { fprintf(gpoutfile,"currentpoint stroke M\n"); ps_path_count = 0; } */ } TERM_PUBLIC void EPSL_arrow(xstart, ystart, xend, yend, head) unsigned int xstart, ystart, xend, yend; TBOOLEAN head; { fprintf(gpoutfile, "%d %d M\n%d %d %s\n", xstart, ystart, xend, yend, head ? "Arrow" : "L Gpstroke"); } TERM_PUBLIC void EPSL_put_text(x, y, str) unsigned int x, y; char *str; { if (EPSL_texfile) { fprintf(EPSL_texfile, "\\put(%d,%d){", x, y); if (EPSL_ang) { fputs("\\rotatebox{90}{", EPSL_texfile); } if (((str[0] == '{') || (str[0] == '['))) { fprintf(EPSL_texfile, "\\makebox(0,0)%s", str); } else switch (EPSL_justify) { case LEFT: fprintf(EPSL_texfile, "\\makebox(0,0)[l]{\\strut{}%s}", str); break; case CENTRE: fprintf(EPSL_texfile, "\\makebox(0,0){\\strut{}%s}", str); break; case RIGHT: fprintf(EPSL_texfile, "\\makebox(0,0)[r]{\\strut{}%s}", str); break; } if (EPSL_ang) { fputs("}", EPSL_texfile); } fputs("}%\n", EPSL_texfile); } } TERM_PUBLIC int EPSL_text_angle(ang) int ang; { EPSL_ang = ang; return TRUE; } TERM_PUBLIC int EPSL_justify_text(mode) enum JUSTIFY mode; { EPSL_justify = mode; return TRUE; } TERM_PUBLIC int EPSL_set_font(font) /* Entry font added by DJL */ char *font; { char name[32]; int size, sep; sep = strcspn(font, ","); strncpy(name, font, sep); name[sep] = 0; size = EPSL_fontsize; sscanf(&(font[sep + 1]), "%d", &size); return TRUE; } TERM_PUBLIC void EPSL_point(x, y, number) unsigned int x, y; int number; { static char GPFAR *GPFAR pointFNS[] = { "Pnt", "Dia", "Crc", "Crs", "CrX", "Box", "DaF", "CcF", "BxF" }; EPSL_FLUSH_PATH; if (number < 0) number = -1; /* negative types are all 'dot' */ else number %= sizeof(pointFNS) / sizeof(pointFNS[0]) - 1; fprintf(gpoutfile, "%d %d %s\n", x, y, pointFNS[number + 1]); EPSL_relative_ok = 0; EPSL_path_count = 0; EPSL_linetype_last = -1; /* force next linetype change */ } TERM_PUBLIC void EPSL_fillbox(style, x1, y1, x2, y2) int style; unsigned int x1, y1, x2, y2; { /* ULIG: the style parameter is now used for the fillboxes style * (not implemented here), see the documentation */ EPSL_FLUSH_PATH fprintf(gpoutfile, "%d %d %d %d BoxFill\n", x1, y1, x2, y2); EPSL_relative_ok = 0; EPSL_linetype_last = -1; } #ifdef PM3D TERM_PUBLIC void EPSL_filled_polygon(points, corners) int points; gpiPoint *corners; { PS_filled_polygon(points, corners); EPSL_relative_ok = FALSE; } #endif /* PM3D */ #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(epslatex_driver) "epslatex", "LaTeX (Text) and encapsulated PostScript", EPSL_XMAX, EPSL_YMAX, EPSL_VCHAR, EPSL_HCHAR, EPSL_VTIC, EPSL_HTIC, EPSL_options, EPSL_init, EPSL_reset, EPSL_text, null_scale, EPSL_graphics, EPSL_move, EPSL_vector, EPSL_linetype, EPSL_put_text, EPSL_text_angle, EPSL_justify_text, EPSL_point, EPSL_arrow, EPSL_set_font, EPSL_pointsize, 0 /*flags */ , 0 /*suspend */ , 0 /*resume */ , EPSL_fillbox, EPSL_linewidth #ifdef PM3D #ifdef USE_MOUSE , 0, 0, 0, 0, 0 /* no mouse support for epslatex */ #endif , PS_make_palette, PS_previous_palette, PS_set_color, EPSL_filled_polygon #endif TERM_TABLE_END(epslatex_driver) #undef LAST_TERM #define LAST_TERM epslatex_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(post) "1 epslatex", "?commands set terminal epslatex", "?set terminal epslatex", "?set term epslatex", "?terminal epslatex", "?term epslatex", "?epslatex", " Two options may be set in the `epslatex` driver.", "", " Syntax:", " set terminal epslatex {default}", " {color | monochrome} {solid | dashed}", " {\"\"} {}", "", " `default` mode sets all options to their defaults: `monochrome`, `dashed`,", " \"default\" and 11pt.", " Default size of a plot is 5 inches wide and 3 inches high.", "", " `solid` draws all plots with solid lines, overriding any dashed patterns;", " `\"\"` is the name of font; and `` is", " the size of the font in PostScript points. Font selection isn't supported yet.", " Font size selection is supported only for the calculation of proper spacing.", " The actual LaTeX font at the point of inclusion is taken, so use LaTeX commands", " for changing fonts. If you use e.g. 12pt as font size for your LaTeX documents, ", " use '\"default\" 12' as options.", "", " All drivers for LaTeX offer a special way of controlling text positioning:", " If any text string begins with '{', you also need to include a '}' at the", " end of the text, and the whole text will be centered both horizontally", " and vertically by LaTeX. --- If the text string begins with '[', you need", " to continue it with: a position specification (up to two out of t,b,l,r),", " ']{', the text itself, and finally, '}'. The text itself may be anything", " LaTeX can typeset as an LR-box. \\rule{}{}'s may help for best positioning.", " See also the documenation of the pslatex terminal driver.", " To create multiline labels, use \\shortstack, example", " set ylabel '[r]{\\shortstack{first line \\\\ second line}}' ", "", " The driver produces two different files, one for the LaTeX part and one for", " the eps part of the figure. ", " The name of the LaTeX file is derived from the name of", " the eps file given on the `set output` command; it is determined by replacing", " the trailing `.eps` (actually just the final extent in the file name---and", " the option will be turned off if there is no extent) with `.tex` in the output", " file name. Remember to close the file before leaving `gnuplot`.", " There is no LaTeX output if no output file is given!", " In your LaTeX documents use '\\input{filename}' for inclusion of the figure.", " Include \\usepackage{graphics} in the preambel!", " Via 'epstopdf' (contained e.g. in the teTeX package, requires ghostscript)", " pdf files can made out of the eps files. If the graphics package is properly", " configured, the LaTeX files can also be processed by pdflatex without", " changes, and the pdf files are included instead of the eps files" END_HELP(post) #endif