emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH 0/3] synctex support for pdf export


From: Aaron Ecay
Subject: [O] [PATCH 0/3] synctex support for pdf export
Date: Sun, 31 Mar 2013 23:14:58 -0400

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]