From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: [PATCH 0/3] synctex support for pdf export Date: Sun, 31 Mar 2013 23:14:58 -0400 Message-ID: <1364786101-16603-1-git-send-email-aaronecay@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:44146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMVDC-0002KU-Rq for emacs-orgmode@gnu.org; Sun, 31 Mar 2013 23:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMVDA-0003gY-Qu for emacs-orgmode@gnu.org; Sun, 31 Mar 2013 23:15:10 -0400 Received: from mail-qa0-f48.google.com ([209.85.216.48]:42578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMVDA-0003gU-Le for emacs-orgmode@gnu.org; Sun, 31 Mar 2013 23:15:08 -0400 Received: by mail-qa0-f48.google.com with SMTP id hu16so679288qab.7 for ; Sun, 31 Mar 2013 20:15:08 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This patch series is an attempt to add synctex support to org mode. With synctex, you can click on a spot in a document in a PDF viewer, and have emacs jump to the line of code that generated that part of the pdf. (See http://emacswiki.org/emacs/AUCTeX for tips on getting synctex set up with emacs). This is very useful when authoring documents -- you can notice a typo in the pdf, and click directly on it to fix the corresponding line in the tex file. This allows the same functionality with org files -- click on a spot in the generated PDF, and jump in emacs to the org source for that spot. This functionality is currently controled by the variable org-export-with-concordance (disabled by default). It also relies on the latex process generating a synctex file -- use \synctex=1 in the document header to enable that (you probably have to use pdflatex, xelatex, or lualatex -- not plain latex + dvipdf). I have not tested this code extensively, but it does work for me. I don't know if it works for async export or not, since I haven't set up a working environment for that. There are currently limitations. The granularity of the jumping is not great, because of the way the parser works. It will get you into the paragraph corresponding to the PDF location, but no closer (with pure latex, you will arrive at the exact line in the tex file). You also have to run org-latex-patch-synctex manually, unless you use the direct-to-pdf export option (C-c C-e l p). In regular latex, beamer documents have somewhat degraded synctex granularity (in general, you don't get to the exact source line, but only somewhere between \begin{frame} and \end{frame}). This may be compounded by the bad granularity of this patch -- I have not tested this combo very much. It should be possible to support the other direction of synchronization as well -- jumping from a location in the org file to a location in the PDF document (most pdf viewers show a highlight of some sort, to pick out the location requested). I haven't implemented that yet, but it should be easy. I have also not implemented support for multi-file org documents (with #+include). That is also in principle possible, however it will be difficult (or at least tedious) to implement in practice because it will require yet another round of text properties to be applied at some point in the export process. I'm releasing the code for comments on the implementation, which is somewhat dense. Because of the way the parser/exporter works, in order to track the line number from beginning to end I need to use 2 kinds of text properties. A change in the parser is also required, to attach line numbers to objects. (Though the implementation is dense, it was also not terribly difficult to code, once I understood the code I was modifying. The clear structure of Nicolas's exporter/parser is responsible for this fact, more than any cleverness of mine.) Comments on the code are welcome. Testers are also welcome. In order to test the code, you need to: 1) set up synctex to work with your emacs/pdf program 2) set org-export-with-concordance to t 3) make sure your latex program generates a .synctex.gz file 4) export your favorite org document to pdf (directly) 5) it should now work! Thanks, Aaron Aaron Ecay (3): Add :begin-line and :end-line to parser results Introduce machinery to ox.el for concordance generation Add synctex modification based on concordance lisp/org-element.el | 120 +++++++++++++++++++++++++++++++++++++++++ lisp/ox-latex.el | 64 +++++++++++++++++++--- lisp/ox.el | 151 +++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 297 insertions(+), 38 deletions(-) -- 1.8.2