changeset 12279:18f7aac81ef0 release-3-4-x

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 52f6f2989fcd
children 6027fdbcb3d8
files scripts/ChangeLog scripts/plot/__fltk_print__.m scripts/plot/print.m
diffstat 3 files changed, 37 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@
+2011-01-28  Ben Abbott  <bpabbott@mac.com>
+
+	* plot/__fltk_print__.m, plot/print.m: Fix {eps,ps,pdf}latexstandalone
+	printing for fltk, bug 32262.
+
 2011-01-28  John W. Eaton  <jwe@octave.org>
 
 	* sparse/svds.m: Use "test" instead of "testif HAVE_ARPACK".
--- a/scripts/plot/__fltk_print__.m
+++ b/scripts/plot/__fltk_print__.m
@@ -65,10 +65,11 @@
     gl2ps_device = {sprintf("%snotxt", lower (suffix))};
     gl2ps_device{2} = "tex";
     if (dos_shell)
-      pipeline = {sprintf("copy con %s.%s", name, suffix)};
-      pipeline{2} = sprintf ("copy con %s.tex", name);
+      ## FIXME - this will only work on MinGW with the MSYS shell
+      pipeline = {sprintf("cat > %s-inc.%s", name, suffix)};
+      pipeline{2} = sprintf ("cat > %s.tex", name);
     else
-      pipeline = {sprintf("cat > %s.%s", name, suffix)};
+      pipeline = {sprintf("cat > %s-inc.%s", name, suffix)};
       pipeline{2} = sprintf ("cat > %s.tex", name);
     endif
   case "tikz"
@@ -161,5 +162,9 @@
     end_unwind_protect
   endfor
 
+  if (! isempty (strfind (opts.devopt, "standalone")))
+    opts.latex_standalone (opts);
+  endif
+
 endfunction
 
--- 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);