I've started running while : ; do latexmk -lualatex main; sleep 1; done in the background to have my document recompiled whenever one of its files is saved. That works fine, but it would be nice to get notified on two occations: when a compilation is completed; and when there is an error that halts a compilation. On a Mac, the first could be an osascript -e 'beep' and the second a say compilation error. Any idea how that might be done?

  • 1
    Why the loop have you looked at the -pvc option? – daleif Mar 1 '16 at 18:09
  • @daleif, nice, I didn't know about that. – Toothrot Mar 1 '16 at 18:17
  • I think you'd end up being annoyed if it should beep every time it was finished compiling. I do two configurations: enable synctex and let latex stop on the first error. Just works. – daleif Mar 1 '16 at 18:20
  • @daleif, I'm using a visual bell, which isn't so annoying. what do you mean you let latex stop on the first error? what annoys me a bit is that, if an error occurs, I won't know about it untill I check. – Toothrot Mar 1 '16 at 20:34

A bit too long for a comment. First of, I have this in my .latexmkrc

$pdflatex = "pdflatex -synctex=1  -halt-on-error %O %S";

meaning that compilation will stop on the first error, and the go back and wait for me save changes.

I generally use an editor that covers 90% of the height of my screen, behind it I run latexmk -pdf -pvc ... at max size, that way I can usually visually see if the compilation went bad.

  • Thanks for the hint. I put $pdflatex = 'lualatex -halt-on-error %O %S; (( $? )) && say erreur' – Toothrot Mar 2 '16 at 0:32
  • @Lawrence That might break latexmk , I do not remember if latexmk looks at the exit code of the latex process – daleif Mar 2 '16 at 6:38
  • it works well so far. even added an else clause – Toothrot Mar 2 '16 at 8:47

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.