Hello,

I was trying to make a package with pstricks compile using pdflatex when I 
stumbled on the incompatibility between preview and hyperref. I thought I'd 
try to see whether I could do something about this issue, so I found a MWE 
somewhere that uses pdflatex -shell-escape with auto-pst-pdf, which reliably 
triggers this incompatibility:

\documentclass[12pt,letterpaper]{article}
\usepackage{hyperref}
\usepackage{pstricks}
\usepackage{auto-pst-pdf}

\begin{document}

Blah blah blah

\begin{pspicture}(4,4)
\psline(0,0)(4,0)
\end{pspicture}

\end{document}

I understand that the incompatibility with preview has started after the new 
latex hook management arrived and some packages began adding code to the new 
hooks shipout/firstpage and shipout/before. So I wrote a patch for preview.dtx 
that removes this code, relevant snippet is here:

 \let\pr@graphicstype=\z@
 \DeclareOption{dvips}{%
   \let\pr@graphicstype\@ne
-  \preview@delay{\AtBeginDvi{%
+  \RemoveFromHook {shipout/before}[beamerbasenavigation]
+  \RemoveFromHook {shipout/before}[hyperref]
+  \RemoveFromHook {shipout/firstpage}[hyperref]
+  \preview@delay{\AddToHook {shipout/firstpage}{%
       \special{!/preview@version(\pr@version)def}
       \special{!userdict begin/preview-bop-level 0 def%
       /bop-hook{/preview-bop-level dup load dup 0 le{/isls false def%

I uploaded a complete patch over here:
https://github.com/PJBrs/auctex/commit/
dcbe352eda9a31eaabe6816c7222357ec7cb93c7

I was wondering whether something like this could be a way forward for fixing 
this bug. On the positive side, this fixes compiling documents with pstricks, 
hyperref, (auto-)pst-pdf and pdflatex. On the negative, whenever the next 
package begins adding code to these shipout hooks might cause the same problem 
to begin again. A reverse strategy would be to remove all hooks except those 
that belong to packages needed by preview (pstricks for one, and maybe some 
others that I don't know about).

As a disclaimer, I should admit that I don't know very well what I'm doing 
here, nor do I know much about latex, let alone latex hooks, but it is nice to 
see that this patch works (at least, for my usecase with pst-pdf; I didn't 
test preview-latex functionality in emacs, nor would I know how to do that). 
Also, I just thought that this was a nice challenge :-)

Best,

PJ

        

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
bug-auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-auctex
              • ... Bruckmann, Tobias
              • ... Tassilo Horn
              • ... Ikumi Keita
              • ... Arash Esbati
              • ... Tassilo Horn
              • ... Bruckmann, Tobias
              • ... Tassilo Horn
              • ... Reinhard Kotucha
              • ... Tassilo Horn
              • ... Bruckmann, Tobias
  • bug#44578: incompab... PJBrs via bug-auctex via Bug reporting list for AUCTeX

Reply via email to