create account

synctex on mac by peeterjoot

View this thread on: hive.blogpeakd.comecency.com
· @peeterjoot · (edited)
synctex on mac
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](https://steemitimages.com/DQmYLSmRnSoYzs8t2qqWsdBF1Eb4LZyNo4q2WiWHXhaEWaY/Screen%20Shot%202018-01-03%20at%202.53.57%20PM.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:
* Install a synctex capable pdf viewer.
* Skim->preferences: 
![Screen Shot 2018-01-03 at 2.59.28 PM.png](https://steemitimages.com/DQmZzUvLktC3yH8JYJmX3Drj5zdp394o2oFG4ak5G9Uueng/Screen%20Shot%202018-01-03%20at%202.59.28%20PM.png)
* And download the mvim script to my machine from:
https://raw.githubusercontent.com/b4winckler/macvim/master/src/MacVim/mvim

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

References:
* http://mactex-wiki.tug.org/wiki/index.php/SyncTeX
* https://www.sumatrapdfreader.org/free-pdf-reader.html
* https://en.wikipedia.org/wiki/Inverse_search
properties (22)
authorpeeterjoot
permlinksynctex-on-mac
categorysynctex
json_metadata{"tags":["synctex","latex","skim","macvim","latexmk"],"image":["https://steemitimages.com/DQmYLSmRnSoYzs8t2qqWsdBF1Eb4LZyNo4q2WiWHXhaEWaY/Screen%20Shot%202018-01-03%20at%202.53.57%20PM.png","https://steemitimages.com/DQmZzUvLktC3yH8JYJmX3Drj5zdp394o2oFG4ak5G9Uueng/Screen%20Shot%202018-01-03%20at%202.59.28%20PM.png"],"links":["https://raw.githubusercontent.com/b4winckler/macvim/master/src/MacVim/mvim","http://mactex-wiki.tug.org/wiki/index.php/SyncTeX","https://www.sumatrapdfreader.org/free-pdf-reader.html","https://en.wikipedia.org/wiki/Inverse_search"],"app":"steemit/0.1","format":"markdown"}
created2018-01-03 20:03:27
last_update2018-01-03 20:21:18
depth0
children0
last_payout2018-01-10 20:03:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,521
author_reputation4,108,216,103
root_title"synctex on mac"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id26,858,404
net_rshares0