diff scripts/plot/print.m @ 12199:3fc07861449b

Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
author Ben Abbott <bpabbott@mac.com>
date Fri, 28 Jan 2011 18:18:15 -0500
parents b0084095098e
children e81ddf9cacd5
line wrap: on
line diff
--- a/scripts/plot/print.m
+++ b/scripts/plot/print.m
@@ -577,9 +577,28 @@
   endif
 endfunction
 
-function latex_standalone (latexfile)
+function latex_standalone (opts)
+  n = find (opts.name == ".", 1, "last");
+  if (! isempty (n))
+    opts.name = opts.name(1:n-1);
+  endif
+  latexfile = strcat (opts.name, ".tex");
+  switch opts.devopt
+  case {"pdflatexstandalone"}
+    packages = "\\usepackage{graphicx,color}";
+    graphicsfile = strcat (opts.name, "-inc.pdf");
+  case {"pslatexstandalone"}
+    packages = "\\usepackage{epsfig,color}";
+    graphicsfile = strcat (opts.name, "-inc.ps");
+  otherwise
+    packages = "\\usepackage{epsfig,color}";
+    graphicsfile = strcat (opts.name, "-inc.eps");
+  endswitch
+  papersize = sprintf ("\\usepackage[papersize={%.2fbp,%.2fbp},text={%.2fbp,%.2fbp}]{geometry}",
+                       opts.canvas_size, opts.canvas_size);
   prepend = {"\\documentclass{minimal}";
-             "\\usepackage{epsfig,color}";
+             packages;
+             papersize;
              "\\begin{document}";
              "\\centering"};
   postpend = {"\\end{document}"};
@@ -591,6 +610,9 @@
       error ("print:errorclosingfile",
              "print.m: error closing file '%s'", latexfile);
     endif
+    ## TODO - should this be fixed in GL2PS?
+    latex = strrep (latex, "\\includegraphics{}", 
+                    sprintf ("\\includegraphics{%s}", graphicsfile));
   else
     error ("print:erroropeningfile",
            "print.m: error opening file '%s'", latexfile);