emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch] ox-latex.el: support for pgf files
@ 2013-05-20 10:11 Rasmus
  2013-05-20 10:28 ` Rasmus
  2013-05-21  6:23 ` Nicolas Goaziou
  0 siblings, 2 replies; 3+ messages in thread
From: Rasmus @ 2013-05-20 10:11 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

This patch adds support for pgf files.  pgf is the machine upon which
tikz is build.  For instance matplotlib (of Python) and printpgf (of
Octave) both produces pgf files.  It's just a question of recognizing
the extension.  With this patch the following document exports
correctly:

#+TITLE: PGF test
#+LATEX_HEADER: \usepackage{pgf}
#+BEGIN_SRC emacs-lisp :exports none
  (set (make-local-variable 'org-latex-pdf-process)
       '("xelatex -pdf %f"))
#+END_SRC
#+BEGIN_SRC python :results raw :exports results
  from matplotlib import pylab as plt
  x, y = plt.rand(2)
  plt.scatter(x, y)
  fig = "test.pgf"
  plt.savefig(fig) ## utf8 by default
  return("".join(["[[file:", fig, "]]"]))
#+END_SRC

–Rasmus

-- 
Hooray!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Support-for-pgf-files-in-ox-latex.el.patch --]
[-- Type: text/x-patch, Size: 1413 bytes --]

From ff4f43378779eb557213df1cd474a5232333af7d Mon Sep 17 00:00:00 2001
From: "rasmus.pank" <rasmus.pank@gmail.com>
Date: Mon, 20 May 2013 11:58:47 +0200
Subject: [PATCH] Support for pgf files in ox-latex.el

	* ox-latex.el: pgf is recognized as an inline image and
	treated the same way tikz files.

Python matplotlib and pgfprint for Octave generates pgf plots
rather than TiKZ plots.  They need just be included via \input{.}.

TINYCHANGE
---
 lisp/ox-latex.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 41cf1d0..fdada8b 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -420,7 +420,7 @@ environment."
   :type 'string)
 
 (defcustom org-latex-inline-image-rules
-  '(("file" . "\\.\\(pdf\\|jpeg\\|jpg\\|png\\|ps\\|eps\\|tikz\\)\\'"))
+  '(("file" . "\\.\\(pdf\\|jpeg\\|jpg\\|png\\|ps\\|eps\\|tikz\\|pgf\\)\\'"))
   "Rules characterizing image files that can be inlined into LaTeX.
 
 A rule consists in an association whose key is the type of link
@@ -1739,7 +1739,7 @@ used as a communication channel."
 		    (if (not (string-match "\\`\\[\\(.*\\)\\]\\'" opt)) opt
 		      (match-string 1 opt))))
 	 image-code)
-    (if (equal filetype "tikz")
+    (if (member filetype '("tikz" "pgf"))
 	;; For tikz images:
 	;; - use \input to read in image file.
 	;; - if options are present, wrap in a tikzpicture environment.
-- 
1.8.2.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [patch] ox-latex.el: support for pgf files
  2013-05-20 10:11 [patch] ox-latex.el: support for pgf files Rasmus
@ 2013-05-20 10:28 ` Rasmus
  2013-05-21  6:23 ` Nicolas Goaziou
  1 sibling, 0 replies; 3+ messages in thread
From: Rasmus @ 2013-05-20 10:28 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> For instance matplotlib (of Python) and printpgf (of Octave) both
> produces pgf files.

Looking over files, printpgf actually produces TiKZ and /not/ pgf
files, it seems.  My apology.  (But matplotlib does use pgf).

–Rasmus

-- 
I almost cut my hair, it happened just the other day

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] ox-latex.el: support for pgf files
  2013-05-20 10:11 [patch] ox-latex.el: support for pgf files Rasmus
  2013-05-20 10:28 ` Rasmus
@ 2013-05-21  6:23 ` Nicolas Goaziou
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Goaziou @ 2013-05-21  6:23 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

Hello,

Rasmus <rasmus@gmx.us> writes:

> This patch adds support for pgf files.  pgf is the machine upon which
> tikz is build.  For instance matplotlib (of Python) and printpgf (of
> Octave) both produces pgf files.  It's just a question of recognizing
> the extension.  With this patch the following document exports
> correctly:
>
> #+TITLE: PGF test
> #+LATEX_HEADER: \usepackage{pgf}
> #+BEGIN_SRC emacs-lisp :exports none
>   (set (make-local-variable 'org-latex-pdf-process)
>        '("xelatex -pdf %f"))
> #+END_SRC
> #+BEGIN_SRC python :results raw :exports results
>   from matplotlib import pylab as plt
>   x, y = plt.rand(2)
>   plt.scatter(x, y)
>   fig = "test.pgf"
>   plt.savefig(fig) ## utf8 by default
>   return("".join(["[[file:", fig, "]]"]))
> #+END_SRC

Applied. Thank you.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-21  6:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-20 10:11 [patch] ox-latex.el: support for pgf files Rasmus
2013-05-20 10:28 ` Rasmus
2013-05-21  6:23 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).