1

In auctex I can run a command only on a certain region to speed up compiling. This works great, however if then I use the backward search to jump from the .pdf to the .tex source code, it opens the temporary _region_.tex file instead of my real tex file chapter2.tex.

I did search on the internet and in the auctex documentation, but did not find a hint how to set this up correctly.

Some hints about the configuration

LaTeX master file with included chapters

I'm using a master file (let's call it main.tex and then include a source file for each chapter with e. g.

\include{chapter2}

Region.tex file and corresponding log file

My _region_.tex file contains the following line directly after \begin{document)

\message{ !name(chapter2.tex) !offset(927) }

which I think should be used for exactly this purpose.

The _region_.log file contains a line, which refers to the master file, not the chapter:

**\input _region_.tex
(./_region_.tex  !name(main.tex)

PDF viewer sync settings

In the preferences of Skim.app (the pdf viewer) I'm using the following configuration:

  • command: emascsclient
  • arguments: --no-wait +%line "%file"

System and software versions

I'm using MacOS X 10.6 and TeXLive 2014, AUCTeX 11.88.
My pdf viewer is Skim.app and my source editor is Aquamacs.app (Version 3.2)

(I've updated to Aquamacs 3.2 which uses AUCTeX 11.88, but I still have the same problem)

  • 1
    IIRC, if you use Evince, the current development version of AUCTeX brings back to the original document. – giordano Jan 13 '15 at 10:20
  • thanks! How can I determine the installed version of auctex? I'm not using evince, but Skim.app on MacOS X – MostlyHarmless Jan 13 '15 at 10:28
  • C-h v AUCTeX-version, but you'd know if you were using the development version of AUCTeX, you'd have compiled it by yourself ;-) – giordano Jan 13 '15 at 10:42
  • thanks, no I'm not using the development version, but 11.87. So you mean, this just should not work in v 11.87? You're right, I did not compile it myself in this case, but you would not imagine what I've already done or configured and then forgot about having it done... :-) – MostlyHarmless Jan 13 '15 at 10:45
  • 1
    The development version is the version after the last stable one (11.88 currently). And I said it works only with Evince, you use Skim instead. Good to see you found a solution anyway. – giordano Mar 11 '15 at 9:44
1

I finally found a solution for that by configuring emacs (aquamacs):

source: http://article.gmane.org/gmane.emacs.auctex.general/4285

(defadvice server-goto-line-column (after server-visit-region.tex
                                         (line-col)
                                         activate)
 "When visiting _region_.tex from an external
source (e.g. inverse search), go to the original file so that any
changes made won't be lost."
 (when (string-match "_region_.tex\\'" (buffer-file-name))
   (if (save-excursion ;; in case we don't find the other file we at least want the right line...
         (re-search-backward
          "\message{ !name(\\([^)]+\\))\\(?: !offset(\\([-0-9]+\\))\\)?\\s *}" nil nil))
       (let ((file-name (match-string 1))
             (offset (match-string 2))
             (line (car (ad-get-arg 0)))
             (col (cdr (ad-get-arg 0))))
         (if offset (setq line (+ line (string-to-number offset))))
         (find-file file-name nil)
         ;; For some reason this doesn't actually go to the offset
         ;; line.  It's probably because of how advice works.
         (server-goto-line-column (cons line col))
         (message "Moved from _region_.tex to line %s of %s." line file-name)
         (forward-line offset))

     ;; else
     (message "This is _region_.tex, but I couldn't find the original file!"))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.