Synctex not working


#1

Hi all,
I’ve been trying to figure out a way to make synctex work but I could not find any help anywhere else. RStudio documentation seems old in this case (https://support.rstudio.com/hc/en-us/articles/200552066-PDF-Preview-and-SyncTeX) and was not particularly helpful for my problem.

The Global Options “Always enable Rnw concordance” is marked. I tried using Evince and the Rstudio Preview, but synctex does not work in both cases. I realized that maybe this has to do with the fact that the option “Clean auxiliary output after compile” is marked, but when I tried to leave it unchecked, the files are still been deleted (I’m not using any make file or build option, just using the Knit button in the IDE).

Am I missing something important? Any suggestion?

Version 1.0.153 – © 2009-2017 RStudio, Inc.
Mozilla/5.0 (X11; N; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) RStudio Safari/538.1 Qt/5.4.2

R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_3.4.1 backports_1.1.0 bookdown_0.5 magrittr_1.5 rprojroot_1.2 htmltools_0.3.6 tools_3.4.1
[8] yaml_2.1.14 Rcpp_0.12.12 stringi_1.1.5 rmarkdown_1.6 knitr_1.17 stringr_1.2.0 digest_0.6.12
[15] evaluate_0.10.1


#2

Can you include your YAML header as a snippet here? Are you using any sort of template? I’m a far cry from an advanced LaTeX-user, but when I used the resume :package: by Jacek Pardyak, it begat synctex files (I believe) and didn’t delete them. You might be able to do some reverse engineering from there!


#3

Thanks a lot, Mara! I thought about it since in my working document I’m using a template. But this is not the case. If I create a Rmd file with the default R studio lines and only copy/paste the lines in order to get a multiple-page pdf to make easier to check if synctex is working, I still cannot do forward and inverse search.
In this case, the YAML has only the fields title and output: pdf_document.


#4

Hmm, yeah, sorry I can’t be of more help. I think someone suggested a possible Rmarkdown category, which would (obviously) be great for this. Then again, I don’t know the internals of the IDE either, so :woman_shrugging:! Sorry!


#5

Another thing I realized, it is that the option -synctec=-1 is not been passed during the knitting process.

This is the output I get in the R Markdown console after knitting the document:
/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS teste.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output teste.pdf --template /home/raphael/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable ‘geometry:margin=1in’

If I understand the documentation right (3rd bullet in the section "Specifying a Custom LaTeX Program"
here: https://support.rstudio.com/hc/en-us/articles/200532257), even when one customizes the Latex options, Rstudio should automatically include the synctec=-1 option.


#6

SyncTeX only works with Rnw files, not with Rmd files. This is because it only understands the mapping between LaTeX and PDF. When you knit an Rmd to PDF, you’re basically going through three layers of transformation:

Rmd => (knit) Markdown => (pandoc) LaTeX => PDF.

SynTeX can take you only one step backwards, so it isn’t possible to use it to map from the PDF file all the way back to the R Markdown file.


#7

Thanks so much Jonathan! Now, I understand why it does not work.

I have no idea how hard it would be to implement synTex-like behavior for Rmd files, but it would be great given that now it is a lot better to work with notebooks, bookdown, etc.