;--------------------------------------------------------------
;Creates sized IDL PS image when called before plotting.
PRO plotps,filename,xs=xs,ys=ys,font=fontkw,nodialog=ndkw,xo=xo,yo=yo,scale=scale, $
  encapsulated = encapsulated, latex = latex 
   ;print,'Sized PostScript image ...'
   verbose = 1
   IF keyword_set(ndkw) THEN verbose = 0
   IF not keyword_set(xo) then xo = 0
   IF not keyword_set(yo) then yo = 11
   IF not keyword_set(scale) then begin
       scale= .95
   endif
   IF not keyword_set(xs) then xs=11
   IF not keyword_set(ys) then ys=8.5

   if not keyword_set(encapsulated) then encapsulated = 0
   
   ;set scale of size
   xs = scale * xs
   ys = scale * ys

   IF verbose THEN print,'Creating sized PS image called '+strtrim(filename,2)
   set_plot,'ps'
;   xo	= 0.5*(8.5-xs)
;   yo	= 0.5*(11.-ys)

   IF keyword_set(fontkw) THEN BEGIN
      device,/portrait,/inches,set_font=fontkw, /tt_font,$
       xoffset=xo,xsize=xs,yoffset=yo,ysize=ys,$
       filename=filename, encapsulated = encapsulated
      IF verbose THEN print,'For TrueType fonts, be sure to use font=1 in plot statement'
   ENDIF ELSE BEGIN
      IF keyword_set(latex) THEN BEGIN
         encapsulated = 1
         device, /inches, $
         xoffset=xo,xsize=xs,yoffset=yo,ysize=ys, $
         filename=filename, encapsulated = encapsulated 
      ENDIF ELSE BEGIN   
         device,/landscape,/inches,$
         xoffset=xo,xsize=xs,yoffset=yo,ysize=ys,$
         filename=filename, encapsulated = encapsulated      
      ENDELSE
   ENDELSE

   device,/color
END
