The problem is synctex in Arara does not work for me.

I am using MacTeX with TeXShop 4.26. A special documentclass is used (hope it does not affect). For months, I run this file by putting all the supporting files like chp1.tex into the same file folder and clicking command+T. Synchronising from pdf to tex and everything else is fine except synchronising from tex to pdf. Synchronising from tex to pdf works well in editing any other simple file using pdflatex directly (rather than using Arara). Is there anything wrong?

% !TEX TS-program = Arara
% arara: pdflatex
% arara: bibtex
% arara: makeindex
% arara: nomencl
% arara: pdflatex: {synctex: yes}
% arara: pdflatex: {synctex: on}
  • Hi, I will take a look soon. :) – Paulo Cereda Mar 7 at 22:40
  • ooh The duck has it under control :-) however it may be a red herring, that I note that most arara instructions tend to have a space before and after { and before } but as I don't have it installed can't test if that makes any difference – user170109 Mar 8 at 2:31
  • @KJO Thanks for the reminding. I tested it and the brace-spaces do not affect. – David Wang Mar 8 at 3:19
  • The syntax is correct, otherwise arara would complain about it. :) When running the tool with the --dry-run option, I see that the commands are correct. Are you sure the tool does not fail in any step before the two last directives? My suspicion is that the last two directives are not being reached due to a failed execution in previous directives (as arara halts the execution). We might need to inspect the log. Could you run arara with --log enabled and post the contents of arara.log? – Paulo Cereda Mar 9 at 12:02
  • Not trying to use the typical "not my fault" excuse, but arara is just a wrapper to the actual TeX programs. That's why I suspect there's a break in the compilation chain and the lines with SyncTeX are not reached. :) – Paulo Cereda Mar 9 at 12:04

I deliberately marked this answer as community wiki because it is not actually a direct answer, but along the lines of an elaborate comment which is too long to be posted as such. I really don't feel like harvesting reputation. :)

For starters, thanks for the log. :)

It is clear, from inspecting the log, that arara successfully goes through all the motions of executing the commands mapped from the directives. However, to me, there's no clear indication that the tool is to blame on the issue reported in this question. I will expand on that.

arara is just like a wrapper to ease the call for the actual programs like pdflatex and friends. In fact, if I take the provided code and run through the tool with --dry-run enabled, we can see what arara is actually executing on a normal scenario (in here, without an a call, surely, since this flag disables the actual execution):

$ arara --dry-run 478314.tex 
  __ _ _ __ __ _ _ __ __ _ 
 / _` | '__/ _` | '__/ _` |
| (_| | | | (_| | | | (_| |
 \__,_|_|  \__,_|_|  \__,_|

Processing '478314.tex' (size: 231 bytes, last modified:
03/10/2019 17:53:47), please wait.

[DR] (PDFLaTeX) PDFLaTeX engine
Authors: Marco Daniel, Paulo Cereda
About to run: [ pdflatex, 478314.tex ]

[DR] (BibTeX) The BibTeX reference management software
Authors: Marco Daniel, Paulo Cereda
About to run: [ bibtex, 478314 ]

[DR] (MakeIndex) The MakeIndex software
Authors: Marco Daniel, Paulo Cereda
About to run: [ makeindex, -t, 478314.ilg, 478314.idx, -o,
478314.ind ]

[DR] (Nomencl) The Nomenclature software
Authors: Marco Daniel, Nicola Talbot, Paulo Cereda
About to run: [ makeindex, 478314.nlo, -s, nomencl.ist, -o,
478314.nls ]

[DR] (PDFLaTeX) PDFLaTeX engine
Authors: Marco Daniel, Paulo Cereda
About to run: [ pdflatex, --synctex=1, 478314.tex ]

[DR] (PDFLaTeX) PDFLaTeX engine
Authors: Marco Daniel, Paulo Cereda
About to run: [ pdflatex, --synctex=1, 478314.tex ]

Total: 0.42 seconds

The last two calls to pdflatex have the --synctex=1 flag, which is expected to provide proper SyncTeX support. That's it.

However, little to nothing can be done without delving into the depths of your actual environment and code in order to see what is happening. My suggestion is to independently run

pdflatex --synctex=1 myfile.tex

in the command line and see what happens. I can think of some scenarios:

  1. The editor is not aware that there was a compilation chain that generated the resulting PDF, thus nothing is updated, or

  2. You have directives in your source code (not shown in this particular example) that get rid of synctex.gz files as a means to declutter the directory, or

  3. There are potential conflicts in the source code that are causing this issue.

Speaking of which, I noticed that the log file contains a lot of warning about cross references. Although SyncTeX is not directly related to it, maybe it's something worth checking. From my side, I tried a couple of documents of mine and they worked, so I really cannot reproduce this issue, I am so sorry.

Please try to run pdflatex as a standalone call instead of using arara and see if it works. Also, try other similar tools like latexmk. If the problem persists, we might need to get down to a minimal working example that reproduces the issue, otherwise I can only suppose.

Sorry for not being able to help you on this issue. Please keep me informed.

  • Thanks Paulo! An independent run of pdflatex --synctex=1 myfile.tex produces a pdf with the same problem. You are right there is a lot of cross-refs. I understand your 3 scenarios more or less, but am still quite confused about the direction that I should dig deeper. I'll try check the cross-refs so. Thanks for all and please let me know if the above result inspires anything new. – David Wang Mar 10 at 21:33
  • @DavidWang I am the one to thank you! :) I was getting worried that this could somehow be a corner case, a very specific scenario in which things were not behaving as expected. Thanks for testing. I think we can now cross items 1 and 2, since the issue is reproduceable without TeXShop and arara. Sadly, I won't be able to help you further, since SyncTeX is an uncharted territory to me. Perhaps changing this question a bit might help others investigate what's happening. – Paulo Cereda Mar 11 at 8:51

I found a solution: Add % !TEX root = main.tex at the beginning of the file for each chapter, such as that of the file chp1.tex. This command assigns a relative path so that the generated sync file finds the main file which contains a line of \include{chp1}. An alternative solution is to add an absolute path like % !TEX root = /Users/main.tex if /Users/main.tex is the location of the file main.tex on my Mac. The problem should be about editing a book in multi-files, rather than using Arara.

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.