Note that there are some explanatory texts on larger screens.

plurals
  1. POEmacs + Synctex + Skim: How to correctly set up synchronization? [none of the existing methods worked properly]
    primarykey
    data
    text
    <p>I'm working with GNU Emacs 23.3 (9.0) on Mac OS X 10.7.2. I would like to use synctex to jump between .tex and .pdf files. Although there are many different approaches on the web, none worked properly (I tried 8 different approaches...). I finally ended up with the rather simple approach described here: <a href="http://sourceforge.net/apps/mediawiki/skim-app/index.php?title=TeX_and_PDF_Synchronization" rel="noreferrer">http://sourceforge.net/apps/mediawiki/skim-app/index.php?title=TeX_and_PDF_Synchronization</a></p> <p>So my .emacs contains:</p> <pre class="lang-lisp prettyprint-override"><code>'(LaTeX-command "latex -synctex=1") (require 'tex-site) (add-hook 'TeX-mode-hook (lambda () (add-to-list 'TeX-output-view-style '("^pdf$" "." "/Applications/Skim.app/Contents/SharedSupport/displayline -b %n %o %b"))) ) (server-start) </code></pre> <p>Of course, I also set up Skim (Preferences -> Sync -> checked "Check for file changes" and chose Preset: Emacs with command emacsclient and arguments --no-wait +%line "%file")</p> <p>As you can see, I included the <code>-b</code> option to displayline. I can call displayline from the terminal and it opens the .pdf and displays the corresponding line with a yellow/highlighted bar. Still, nothing is displayed on the current line if I compile the document with <code>latexmk -pvc -pdf</code> from a shell within Emacs.app.</p> <p>Question 1: How can I get this to work/How can I display the current line?</p> <p>Question 2: Is it possible to have a "proper" forward search by clicking the .tex and jumping to the corresponding line in the .pdf document? How can I "click" in emacs? The standard CMD + shift + click does not work in emacs. </p> <p>I also tried approaches using...</p> <pre class="lang-lisp prettyprint-override"><code>(setq TeX-source-correlate-method 'synctex) (add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode) </code></pre> <p>... but nothing changes.</p> <p>I can CMD + shift + click in the .pdf and jump to the .tex, so that works.</p> <p>The only directions which I haven't looked into are:</p> <ol> <li><p>is this a latexmk problem? Most likely not, since latexmk explicitly displays <code>pdflatex -interaction=nonstopmode -synctex=1</code> so synctex is recognized</p></li> <li><p>is it a wrong skim preference setting? Maybe I have to adjust the arguments to emacsclient there (?)</p></li> </ol> <p><strong>Solution</strong></p> <p>Indeed latexmk is the problem. I finally figured out the following settings:</p> <p><strong>~/.emacs</strong></p> <pre><code>;; make latexmk available via C-c C-c ;; Note: SyncTeX is setup via ~/.latexmkrc (see below) (add-hook 'LaTeX-mode-hook (lambda () (push '("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t :help "Run latexmk on file") TeX-command-list))) (add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk"))) ;; use Skim as default pdf viewer ;; Skim's displayline is used for forward search (from .tex to .pdf) ;; option -b highlights the current line; option -g opens Skim in the background (setq TeX-view-program-selection '((output-pdf "PDF Viewer"))) (setq TeX-view-program-list '(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b"))) (server-start); start emacs in server mode so that skim can talk to it </code></pre> <p><strong>~/.latexmkrc</strong></p> <pre><code>$pdflatex = 'pdflatex -interaction=nonstopmode -synctex=1 %O %S'; $pdf_previewer = 'open -a skim'; $clean_ext = 'bbl rel %R-blx.bib %R.synctex.gz'; </code></pre> <p>This perfectly allows to compile with latexmk as default on C-c C-c and C-c C-v opens Skim at the current line which is nicely highlighted. With CMD + shift + click in the .pdf, one can then jump back to the corresponding paragraph in the .tex file (thanks to <code>server-start</code>).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload