tom-tan/auctex-latexmk

Support for xelatex breaks PDF viewing

Closed this issue · 10 comments

Calling xelatex via -xelatex breaks the viewing commands on my setup, probably because AUCTeX tries to view the .xdv file. This does not happen when setting the engine and compiling with AUCTeX's LaTeX command because only latexmk deliberately (their deliberation, not mine) generates first an .xdv file and then PDF. I am not sure whether this should be fixed in latexmk, AUCTeX or here, but would suffice to add:

                    ((and (eq TeX-engine 'xetex)
                          TeX-PDF-mode
                          auctex-latexmk-inherit-TeX-PDF-mode)
                     "-pdf -pdflatex=xelatex ")

in the engine command choice of auctex-latexmk.el to avoid that latexmk adds --no-pdf and then generation and viewing work as expected. This may be the cheapest fix. It may even be reasonable to choose this fix if [auctex-latexmk-inherit-]TeX-PDF-mode are nil because there is no XDV viewer anyway.

+1 for this issue

Sorry for late reply.

I try to reproduce this issue but I cannot.
Would you tell me more details for this issue? (your environment, what "breaks" means)

My environment:

  • MacOSX El Capitan
  • auctex-latexmk master
  • AUCTeX 11.90.0
\documentclass{article}
\usepackage{xltxtra}

\begin{document}
sample
\end{document}

I set TeX-engine to 'xetex and I did not use .latekmkrc.

I compiled this file with C-c C-c LatexMk and tried to openC-c C-c View.
I confirmed the compiled PDF is opened via preview.app.

Thanks for looking into this!

Environment 1:

  • Ubuntu 16.10
  • auctex-latexmk-20160923.7 (ELPA)
  • auctex 11.90.0

"breaking" means that compilation works, but preview does not. ("No matching viewer found.")

Environment 2:

  • MacOSX El Capitan
  • auctex-latexmk-20160923.7 (ELPA)
  • auctex 11.90.0

I had not tried the Mac before with this file, sorry. You are right that Preview is opened. However, my preference for viewing is set to Skim (or, as per AUCTeX options, "displayline", which allows SyncTex). This is, even on the Mac, the file is not viewed with the configured PDF viewer, but with another default viewer. If you look at AUCTeX's tex.el, they define open as a program for some files; maybe that leads to opening Preview for unknown files. (Although I wonder how it gets it right to open the PDF, not the XDV, but I am afraid I do not have time to track this right now, sorry.)

The advantage of using Skim on the Mac is that SyncTeX works for forward and backward search in the source, which is essential to my (but not only my) workflow; so I would still count opening the wrong viewer (Preview instead of Skim) as "breaking".

So, summing up:

  • Linux: latexmk breaks auctex viewing.
  • Mac: latexmk breaks viewer configuration.

Both are due to the fact that auctex does not handle the XDV route correctly ('XDV route' is short for: generating XDV only for the LaTeX runs and only after stabilization converting it to PDF, instead of doing the full conversion all the time). The workaround I suggested was to make latexmk use the PDF route again. As I said, one could argue that auctex should fix this, but then again, the support for latexmk is not part of auctex, so they do not have to support the XDV route.

Thank you for your reply.

I checked this issue in Linux machine by using the same instruction but I fonud that it can be successfully compiled and opened by evince viewer (my default viewer).
So this issue seems to be the problem of the user configuration.

You can configure the viewer via TeX-view-program-selection and you will see the possible options in TeX-view-program-list-builtin.
For example:

(setq TeX-view-program-selection '((output-pdf "Skim")))

Thank you for your reply. Are you sure that you re-compiled with LaTeXmk? For me, it works as follows:

  • Mac: Setting the viewer to "displayline" (and making displayline available in the path) I can indeed view the document, even after recompiling. I had some old configuration from before "displayline" was an official option; sorry for not noticing this, but it worked everywhere except with LaTeXmk now. Thank you very much for making me update my configuration!
  • Linux: I have not changed anything here, "Evince" is the default and only viewer; setting it explicitly makes no difference.
    1. compile with LaTeXmk
    2. "No matching viewer found"
    3. quit Emacs
    4. reopen file
    5. without recompiling(!), view document
    6. Evince opens.
    7. Change something and goto i.

Sorry for late reply.

I reproduced this issue and fix it as suggested in the first post.
If there still exsits the same issue, please reopen this issue.

Hi! Recently I have encountered exactly the same issue as teoric did. I'm using Emacs on MacOS. And I didn't change any of the viewing options of AucTeX.

The thing is the same as above: when I first open a tex file which has already been compiled to pdf before, with C-c C-v I can open the pdf with Preview directly. But after that, when I compile the tex file with auctex-latexmk, with C-c C-v I get "No matching viewer found". If I quit Emacs and reopen the tex file, C-c C-v works again.

Can you reproduce this, by not setting the viewer to Skim, and see if there's something wrong, please?

+1 to @liushihao456 's issue - I'm also facing this. Can you please reopen this issue?

Thank you @liushihao456 and @altosaar!
I will try to reproduce it.

Once it is reproduced in my environment, I will reopen this issue.

I am using auctex and auctex-latexmk on an Arch Linux machine. And I'm facing similar problem as @liushihao456 's issue.

I've set TeX-view-program-selection and the viewer can be opened once after I compiled the document with latex or it has been compiled before, but if I use latexmk to compile the tex file and then try C-c C-v, it shows "No matching viewer found".

To address this issue, I have to compile the doc twice with latexmk and latex in order. This might be stupid, but it is better than latex+bibtex+latex+latex or exit emacs and reopen with a much longer loading time.

Could you please try to reproduce it and find an elegant solution?