all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 0/3] synctex support for pdf export
@ 2013-04-01  3:14 Aaron Ecay
  2013-04-01  3:14 ` [PATCH 1/3] Add :begin-line and :end-line to parser results Aaron Ecay
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Aaron Ecay @ 2013-04-01  3:14 UTC (permalink / raw)
  To: emacs-orgmode

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

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

end of thread, other threads:[~2013-04-18 16:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-01  3:14 [PATCH 0/3] synctex support for pdf export Aaron Ecay
2013-04-01  3:14 ` [PATCH 1/3] Add :begin-line and :end-line to parser results Aaron Ecay
2013-04-01  3:15 ` [PATCH 2/3] Introduce machinery to ox.el for concordance generation Aaron Ecay
2013-04-01  3:15 ` [PATCH 3/3] Add synctex modification based on concordance Aaron Ecay
2013-04-01  9:15 ` [PATCH 0/3] synctex support for pdf export Nicolas Goaziou
2013-04-01 15:33   ` Aaron Ecay
2013-04-04 13:19     ` Nicolas Goaziou
2013-04-18  8:29       ` Aaron Ecay
2013-04-18 16:27         ` Rasmus
2013-04-15  9:33   ` Andreas Leha
2013-04-15 11:50     ` Alan Schmitt
2013-04-15 15:37       ` Bastien

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.