synctex on mac

in synctex •  7 years ago  (edited)

Switching to a Mac from Windows was initially was a big hit on my productivity, as I had to figure out how to do the simplest things (like cut and paste), but after two years I have most things figured out. One kind of specialized task, exploiting reverse synctex support when writing latex documents, is something that I hadn't taken the time to figure out how to do on the mac.

On Windows I used to use the Sumatra pdf viewer. That viewer had synctex support, in particular reverse lookup support, so if I was compiling my latex -> pdf appropriately, then I could click on whatever was of interest in the pdf viewer and it would start a editor (vim in my case) session of the file in question, pointing me right at the line of the latex of interest.

Compiling appropriately means including a -synctex=1 option in the pdflatex command that builds the pdf. As I now use latexmk (which does dependency checking, auto-bib processing, ...), that indirect pdflatex command looks like the following for me:

max_print_line=1000 \
latexmk -pdf \
-latexoption='-file-line-error' \
-latexoption='-synctex=1' \
-latexoption='-shell-escape' \
-latexoption='--halt-on-error' \
GAelectrodynamics.tex

I really missed that feature, and have been making do with a poor-man's synctex:

grep -n pattern *.tex > o
vim -q o

However, I have finally taken the time to figure out how to do the same on the mac that I'm now using. Here's an example of what happens with shift-command-click using the Skim pdf viewer:

Screen Shot 2018-01-03 at 2.53.57 PM.png

The cursor is positioned on the line in the latex source associated with the click point, so that a correction can easily be made.

A couple steps are required to get this to work:

This script is apparently in the dmg image that comes with MacVim, but that's been long since deleted on my machine.

References:

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!